當前位置: 首頁>>代碼示例>>C#>>正文


C# RestaurantContext.Entry方法代碼示例

本文整理匯總了C#中eRestaurant.DAL.RestaurantContext.Entry方法的典型用法代碼示例。如果您正苦於以下問題:C# RestaurantContext.Entry方法的具體用法?C# RestaurantContext.Entry怎麽用?C# RestaurantContext.Entry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在eRestaurant.DAL.RestaurantContext的用法示例。


在下文中一共展示了RestaurantContext.Entry方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: UpdateWaiter

 public void UpdateWaiter(Waiters item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         var attached = context.Waiters.Attach(item);
         var existing = context.Entry<Waiters>(attached);
         existing.State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
開發者ID:tciarroni,項目名稱:eRestaurant-Sample,代碼行數:10,代碼來源:RestaurantAdminController.cs

示例2: UpdateWaiter

 public void UpdateWaiter(Waiter item)
 {        
     using (RestaurantContext context = new RestaurantContext())
     {
         //TODO: Validation
         var attached = context.Waiters.Attach(item);
         var matchingWithExistingValues = context.Entry<Waiter>(attached);
         matchingWithExistingValues.State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
開發者ID:mmayo2,項目名稱:DMIT2018InClass,代碼行數:11,代碼來源:RestaurantAdminController.cs

示例3: SeatCustomer

 /// <summary>
 /// Seats a customer that is a walk-in
 /// </summary>
 /// <param name="when">A mock value of the date/time (Temporary - see remarks)</param>
 /// <param name="tableNumber">Table number to be seated</param>
 /// <param name="customerCount">Number of customers being seated</param>
 /// <param name="waiterId">Id of waiter that is serving</param>
 public void SeatCustomer(DateTime when, int reservationId, List<byte> tables, int waiterId)
 {
     var availableSeats = AvailableSeatingByDateTime(when.Date, when.TimeOfDay);
     using (var context = new RestaurantContext())
     {
         List<string> errors = new List<string>();
         // Rule checking:
         // - Reservation must be in Booked status
         // - Table must be available - typically a direct check on the table, but proxied based on the mocked time here
         // - Table must be big enough for the # of customers
         var reservation = context.Reservations.Find(reservationId);
         if (reservation == null)
             errors.Add("The specified reservation does not exist");
         else if (reservation.ReservationStatus != Reservation.Booked)
             errors.Add("The reservation's status is not valid for seating. Only booked reservations can be seated.");
         var capacity = 0;
         foreach (var tableNumber in tables)
         {
             if (!availableSeats.Exists(x => x.Table == tableNumber))
                 errors.Add("Table " + tableNumber + " is currently not available");
             else
                 capacity += availableSeats.Single(x => x.Table == tableNumber).Seating;
         }
         if (capacity < reservation.NumberInParty)
             errors.Add("Insufficient seating capacity for number of customers. Alternate tables must be used.");
         if (errors.Count > 0)
             throw new BusinessRuleException("Unable to seat customer", errors);
         // 1) Create a blank bill with assigned waiter
         Bill seatedCustomer = new Bill()
         {
             BillDate = when,
             NumberInParty = reservation.NumberInParty,
             WaiterID = waiterId,
             ReservationID = reservation.ReservationID
         };
         context.Bills.Add(seatedCustomer);
         // 2) Add the tables for the reservation and change the reservation's status to arrived
         foreach (var tableNumber in tables)
             reservation.Tables.Add(context.Tables.Single(x => x.TableNumber == tableNumber));
         reservation.ReservationStatus = Reservation.Arrived;
         var updatable = context.Entry(context.Reservations.Attach(reservation));
         updatable.Property(x => x.ReservationStatus).IsModified = true;
         //updatable.Reference(x=>x.Tables).
         // 3) Save changes
         context.SaveChanges();
     }
     //string message = String.Format("Not yet implemented. Need to seat reservation {0} for waiter {1} at tables {2}", reservationId, waiterId, string.Join(", ", tables));
     //throw new NotImplementedException(message);
 }
開發者ID:mmayo2,項目名稱:DMIT2018InClass,代碼行數:56,代碼來源:SeatingController.cs

示例4: UpdateTable

 public void UpdateTable(Table item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         //TODO: Validation...
         var attached = context.Tables.Attach(item);
         var existing = context.Entry<Table>(attached);
         existing.State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
開發者ID:punq,項目名稱:DMIT2018inclass,代碼行數:11,代碼來源:RestaurantAdminController.cs

示例5: UpdateTable

 public void UpdateTable(Table item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         var attached = context.Tables.Attach(item);
         var matchingWithExistedValues = context.Entry<Table>(attached);
         matchingWithExistedValues.State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
開發者ID:rsxlancer,項目名稱:DMIT2018-In-Class,代碼行數:10,代碼來源:RestaurantAdminController.cs

示例6: UpdateEvent

 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();
     }
 }
開發者ID:rsxlancer,項目名稱:DMIT2018-In-Class,代碼行數:11,代碼來源:RestaurantAdminController.cs

示例7: UpdateSpecialEvent

 public void UpdateSpecialEvent(SpecialEvent item)
 {
     //TODO: Validation rules...
     using (RestaurantContext context = new RestaurantContext())
     {
         var attached = context.SpecialEvents.Attach(item);
         var existing = context.Entry<SpecialEvent>(attached);
         existing.State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
開發者ID:Shaun83,項目名稱:InClass,代碼行數:11,代碼來源:RestaurantAdminController.cs

示例8: UpdateReseravtion

 public void UpdateReseravtion(Reservation item)
 {
     using (RestaurantContext context = new RestaurantContext())
     {
         var attached = context.Reservations.Attach(item);
         var matchingWithExistingValues = context.Entry<Reservation>(attached);
         matchingWithExistingValues.State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
開發者ID:mklause1,項目名稱:DMIT2018-In-Class,代碼行數:10,代碼來源:RestaurantAdminController.cs


注:本文中的eRestaurant.DAL.RestaurantContext.Entry方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。