当前位置: 首页>>代码示例>>C#>>正文


C# eRestaurantContext.Entry方法代码示例

本文整理汇总了C#中eRestaurantSystem.DAL.eRestaurantContext.Entry方法的典型用法代码示例。如果您正苦于以下问题:C# eRestaurantContext.Entry方法的具体用法?C# eRestaurantContext.Entry怎么用?C# eRestaurantContext.Entry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eRestaurantSystem.DAL.eRestaurantContext的用法示例。


在下文中一共展示了eRestaurantContext.Entry方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SpecialEvents_Update

 public void SpecialEvents_Update(SpecialEvent item)
 {
     using (eRestaurantContext context = new eRestaurantContext())
     {
         context.Entry<SpecialEvent>(context.SpecialEvents.Attach(item)).State =System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
开发者ID:SeymoreThrottle,项目名称:DVCSExercise,代码行数:8,代码来源:eRestaurantController.cs

示例2: SpecialEvents_Update

        public void SpecialEvents_Update(SpecialEvent item)
        {
            using (eRestaurantContext context = new eRestaurantContext())
            {
                //Indicate the updating item instance
                //alter the modified status flag for this instance

                context.Entry<SpecialEvent>(context.SpecialEvents.Attach(item)).State = System.Data.Entity.EntityState.Modified;
                //command is not executed untill it is actually saved
                context.SaveChanges();
            }
        }
开发者ID:DilpreetSandhu,项目名称:InClassDemos-master,代码行数:12,代码来源:AdminController.cs

示例3: Waiters_Update

        public void Waiters_Update(Waiter item)
        {
            using (eRestaurantContext context = new eRestaurantContext())
            {

                // indicate the updateing item instance
                //alter the Modified Status flag for this instance
                context.Entry<Waiter>(context.Waiters.Attach(item)).State =
               System.Data.Entity.EntityState.Modified;
                //command is not executed until it it actually saved.
                context.SaveChanges();
            }
        }
开发者ID:swu18,项目名称:InClassDemo,代码行数:13,代码来源:AdminController.cs

示例4: SeatCustomer

        //seating of reservations
        public void SeatCustomer(DateTime when, int reservationId, List<byte> tables, int waiterId)
        {
            var availableSeats = AvailableSeatingByDateTime(when.Date, when.TimeOfDay);
            using (var context = new eRestaurantContext())
            {
                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.");

                //is there sufficient seating available for the reservation
                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 reseervation", 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 (ReservationTables) n adds depending on the number of tables assigned
                foreach (var tableNumber in tables)
                    reservation.Tables.Add(context.Tables.Single(x => x.TableNumber == tableNumber));

                // 3) Update the reservation status to arrived
                reservation.ReservationStatus = Reservation.Arrived;
                var updatable = context.Entry(context.Reservations.Attach(reservation));
                updatable.Property(x => x.ReservationStatus).IsModified = true;
                //updatable.Reference(x=>x.Tables).

                // 4) 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:swu18,项目名称:InClassDemo,代码行数:56,代码来源:AdminController.cs

示例5: Waiters_Update

        public void Waiters_Update(Waiter item)
        {
            using (eRestaurantContext context = new eRestaurantContext())
            {
                context.Entry<Waiter>(context.Waiters.Attach(item)).State = System.Data.Entity.EntityState.Modified;

                context.SaveChanges();

            }
        }
开发者ID:SuperBigL,项目名称:InClassDemos,代码行数:10,代码来源:AdminController.cs

示例6: waiter_Update

        public void waiter_Update(Waiter item)
        {
            using (eRestaurantContext context = new eRestaurantContext())
            {
                //indicate the updating item instance
                //alter the Modified status flag for this instance

                context.Entry<Waiter>(context.Waiters.Attach(item)).State =
                    System.Data.Entity.EntityState.Modified; //telling it update, SpecialEvent is the entity;
                //attach is passing in the the item

                context.SaveChanges();

            }
        }
开发者ID:sluo1nait,项目名称:InClassDemos,代码行数:15,代码来源:AdminController.cs

示例7: Bill_Update

        public void Bill_Update(Bill item)
        {
            using (eRestaurantContext context = new eRestaurantContext())
            {
                context.Entry<Bill>(context.Bill.Attach
                (item)).State = System.Data.Entity.EntityState.Modified;

                context.SaveChanges();
            }
        }
开发者ID:RelSavo,项目名称:Temp2,代码行数:10,代码来源:eRestaurantController.cs

示例8: Reservations_Update

        public void Reservations_Update(Reservations item)
        {
            using (eRestaurantContext context = new eRestaurantContext())
            {
                context.Entry<Reservations>(context.Reservations.Attach
                (item)).State = System.Data.Entity.EntityState.Modified;

                context.SaveChanges();
            }
        }
开发者ID:RelSavo,项目名称:Temp2,代码行数:10,代码来源:eRestaurantController.cs


注:本文中的eRestaurantSystem.DAL.eRestaurantContext.Entry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。