本文整理汇总了C#中eStationCore.Model.StationContext.Set方法的典型用法代码示例。如果您正苦于以下问题:C# StationContext.Set方法的具体用法?C# StationContext.Set怎么用?C# StationContext.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eStationCore.Model.StationContext
的用法示例。
在下文中一共展示了StationContext.Set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveChat
/// <summary>
/// Creer Nouvelle Conversation
/// </summary>
/// <param name="newChat"></param>
/// <returns></returns>
public bool SaveChat (Chat newChat) {
using (var db = new StationContext()) {
if(newChat.Persons.Count < 2)
throw new InvalidOperationException("CONVERSATION_MUST_HAVE_AT_LEAST_TWO_PERSONS");
if(newChat.ChatGuid==Guid.Empty)
newChat.ChatGuid=Guid.NewGuid();
newChat.DateAdded =DateTime.Now;
newChat.AddUserGuid =Guid.Empty;
newChat.LastEditUserGuid =Guid.Empty;
newChat.LastEditDate =DateTime.Now;
//foreach (var talker in newConversation.Persons)
//{
// if(talker.PersonGuid==Guid.Empty)
// talker.PersonGuid=Guid.NewGuid();
// db.Set<Person>().Add(talker);
//}
foreach(var talk in newChat.Messages.Where(talk => talk.MessageGuid==Guid.Empty))
talk.MessageGuid=Guid.NewGuid();
db.Set<Chat>().Add(newChat);
return db.SaveChanges()>0;
}
}
示例2: GetPersonDocuments
/// <summary>
/// La list des Documents d'une Personne
/// </summary>
/// <param name="personGuid"></param>
/// <param name="maxResult"></param>
/// <returns></returns>
public IEnumerable GetPersonDocuments(Guid personGuid, int maxResult = 7)
{
using (var db = new StationContext()) {
return (db.Set<Person>().Find(personGuid).Documents).Select(
d => new Document {DocumentGuid = d.DocumentGuid, DocumentName = d.DocumentName, Description = d.Description, FileType = d.FileType }).OrderBy(d=> d.DateAdded);
}
}
示例3: SaveDocument
/// <summary>
/// Represente un enseignant, proff, staff, qui a la possibilite de se connecter a l'Eschool
/// </summary>
/// <param name="document"></param>
/// <returns></returns>
//[PrincipalPermission(SecurityAction.Demand, Role = Clearances.StaffWrite)]
public bool SaveDocument (Document document) {
using (var db = new StationContext()) {
if(document.DocumentGuid==Guid.Empty)
document.DocumentGuid=Guid.NewGuid();
db.Set<Document>().Add(document);
return db.SaveChanges()>0;
}
}
示例4: Put
public bool Put(FuelPrelevement myPrelevement)
{
using (var db = new StationContext())
{
myPrelevement.LastEditDate = DateTime.Now;
db.Set<FuelPrelevement>().Attach(myPrelevement);
db.Entry(myPrelevement).State = EntityState.Modified;
return db.SaveChanges() > 0;
}
}
示例5: UpdateStaff
public bool UpdateStaff(Staff mStaff)
{
using (var db = new StationContext())
{
db.Staffs.Attach(mStaff);
db.Entry(mStaff).State = EntityState.Modified;
db.Set<Person>().Attach(mStaff.Person);
db.Entry(mStaff.Person).State = EntityState.Modified;
return db.SaveChanges() > 0;
}
}
示例6: PushChat
/// <summary>
/// Envoyer Un Chat
/// </summary>
/// <param name="newMessage"></param>
/// <returns></returns>
public bool PushChat (Message newMessage) {
using (var db = new StationContext()) {
if(db.Set<Person>().Find(newMessage.SenderGuid)==null)
throw new InvalidOperationException("SENDER_REFERENCE_NOT_FOUND");
if(newMessage.MessageGuid==Guid.Empty)
newMessage.MessageGuid=Guid.NewGuid();
if(db.Set<Chat>().Find(newMessage.ChatGuid)==null)
throw new InvalidOperationException("CONVERSATION_REFERENCE_NOT_FOUND");
newMessage.DateAdded =DateTime.Now;
newMessage.AddUserGuid = Guid.Empty;
newMessage.LastEditUserGuid = Guid.Empty;
newMessage.LastEditDate =DateTime.Now;
if (newMessage.Attachement == null) return db.SaveChanges() > 0;
if(newMessage.Attachement.DocumentGuid==Guid.Empty)
newMessage.Attachement.DocumentGuid=Guid.NewGuid();
db.Set<Document>().Add(newMessage.Attachement);
db.Set<Message>().Add(newMessage);
return db.SaveChanges()>0;
}
}
示例7: AddStaff
public async Task<bool> AddStaff(Staff myStaff)
{
using (var db = new StationContext())
{
if (myStaff.StaffGuid == Guid.Empty)
myStaff.StaffGuid = Guid.NewGuid();
if (myStaff.Person.PersonGuid == Guid.Empty)
myStaff.Person.PersonGuid = Guid.NewGuid();
await myStaff.Person.Validate();
db.Set<Person>().Add(myStaff.Person);
db.Staffs.Add(myStaff);
return await db.SaveChangesAsync() > 0;
}
}
示例8: UpdateCustomer
/// <summary>
///
/// </summary>
/// <param name="myCustomer"></param>
/// <returns></returns>
//[PrincipalPermission(SecurityAction.Demand, Role = SecurityClearances.StaffWrite)]
public bool UpdateCustomer(Customer myCustomer)
{
using (var db = new StationContext())
{
// ReSharper disable once PossibleNullReferenceException
var userTrace = (Guid)Membership.GetUser().ProviderUserKey;
myCustomer.LastEditDate = DateTime.Now;
myCustomer.LastEditUserGuid = userTrace;
db.Customers.Attach(myCustomer);
db.Entry(myCustomer).State = EntityState.Modified;
db.Set<Person>().Attach(myCustomer.Person);
db.Entry(myCustomer.Person).State = EntityState.Modified;
return db.SaveChanges() > 0;
}
}
示例9: Post
public async Task<bool> Post(Fuel myFuel)
{
using (var db = new StationContext())
{
if (myFuel.FuelGuid == Guid.Empty) myFuel.FuelGuid = Guid.NewGuid();
myFuel.DateAdded = DateTime.Now;
myFuel.LastEditDate = DateTime.Now;
db.Fuels.Add(myFuel);
if (!myFuel.Prices.Any()) return db.SaveChanges() > 0;
if (myFuel.Prices.First().PriceGuid == Guid.Empty) myFuel.Prices.First().PriceGuid = Guid.NewGuid();
myFuel.Prices.First().ProductGuid = myFuel.FuelGuid;
myFuel.Prices.First().FromDate = DateTime.Now;
db.Set<Price>().Add(myFuel.Prices.First());
return await db.SaveChangesAsync() > 0;
}
}
示例10: Post
public async Task<bool> Post(FuelPrelevement myPrelevement)
{
using (var db = new StationContext())
{
if (myPrelevement.PrelevementGuid == Guid.Empty) myPrelevement.PrelevementGuid = Guid.NewGuid();
var citerneGuid = db.Pompes.Find(myPrelevement.PompeGuid).CiterneGuid;
if (citerneGuid != null)
myPrelevement.CiterneGuid = (Guid)citerneGuid;
else
throw new ArgumentException("CAN_NOT_FIND_CITERNE");
myPrelevement.CurrentPrice = (await FuelManager.GetFuelCurrentPrice(db.Pompes.Find(myPrelevement.PompeGuid).Citerne.FuelGuid));
myPrelevement.DateAdded = DateTime.Now;
myPrelevement.LastEditDate = DateTime.Now;
db.Set<FuelPrelevement>().Add(myPrelevement);
return await db.SaveChangesAsync() > 0;
}
}
示例11: AddCustomer
/// <summary>
/// Represente un client
/// </summary>
/// <param name="newCustomer"></param>
/// <exception cref="InvalidOperationException">CAN_NOT_CREAT_STAFF_PROFILE</exception>
/// <returns></returns>
//[PrincipalPermission(SecurityAction.Demand, Role = SecurityClearances.CustomerWrite)]
public bool AddCustomer(Customer newCustomer)
{
Guard.WhenArgument(newCustomer.Person.FullName, "CUSTOMER_NAME_CAN_NOT_BE_EMPTY").IsNullOrEmpty().IsEqual("Inconnue").Throw();
using (var db = new StationContext())
{
if (newCustomer.CustomerGuid == Guid.Empty)
newCustomer.CustomerGuid = Guid.NewGuid();
if (newCustomer.Person.PersonGuid == Guid.Empty)
newCustomer.Person.PersonGuid = Guid.NewGuid();
// ReSharper disable once PossibleNullReferenceException
var userTrace = (Guid) Membership.GetUser().ProviderUserKey;
newCustomer.DateAdded = DateTime.Now;
newCustomer.AddUserGuid = userTrace;
newCustomer.LastEditDate = DateTime.Now;
newCustomer.LastEditUserGuid = userTrace;
db.Set<Person>().Add(newCustomer.Person);
db.Customers.Add(newCustomer);
return db.SaveChanges() > 0;
}
}
示例12: GetPrelevement
public FuelPrelevement GetPrelevement(Guid prelevGuid)
{
using (var db = new StationContext())
return db.Set<FuelPrelevement>().Find(prelevGuid);
}
示例13: GetPerson
public Person GetPerson(Guid personGuid)
{
using (var db = new StationContext())
return db.Set<Person>().Find(personGuid);
}
示例14: DownloadDocument
/// <summary>
/// Telecharger un document
/// </summary>
/// <param name="documentGuid"></param>
/// <returns></returns>
public Document DownloadDocument (Guid documentGuid) {
using (var db = new StationContext()) {
return db.Set<Document>().Find(documentGuid);
}
}
示例15: DeleteDocument
/// <summary>
/// Supprimer definitivement un document
/// </summary>
/// <returns></returns>
//[PrincipalPermission(SecurityAction.Demand, Role = Clearances.StaffDelete)]
public bool DeleteDocument (Guid documentGuid) {
using (var db = new StationContext()) {
db.Set<Document>().Remove(db.Set<Document>().Find(documentGuid));
return db.SaveChanges()>0;
}
}