コード例 #1
0
 public void DeleteSpecialEvent(SpecialEvent item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         var existing = context.SpecialEvents.Find(item.EventCode);
         context.SpecialEvents.Remove(existing);
         context.SaveChanges();
     }
 }
コード例 #2
0
 public void AddSpecialEvent(SpecialEvent item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         // TODO: Validation rules...
         var added = context.SpecialEvents.Add(item);
         context.SaveChanges();
     }
 }
コード例 #3
0
 public void UpdateSpecialEvent(SpecialEvent item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         //TODO: Validation...
         var attached = context.SpecialEvents.Attach(item);
         var existing = context.Entry<SpecialEvent>(attached);
         existing.State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
コード例 #4
0
 public void UpdateEvent(SpecialEvent item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         //todo: Validation
         var attached = context.SpecialEvents.Attach(item);
         var matchingWithExistingValues = context.Entry<SpecialEvent>(attached);
         matchingWithExistingValues.State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
コード例 #5
0
 public string AddEvent(SpecialEvent item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         //TODO: Validation of waiter data...
         var added = context.SpecialEvents.Add(item);
         context.SaveChanges();
         return added.EventCode;
     }
 }
コード例 #6
0
 public void AddSpecialEvent(SpecialEvent item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         var added = context.SpecialEvents.Add(item);
         context.SaveChanges();
     }
 }