本文整理汇总了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();
}
}
示例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();
}
}
示例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);
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}