//seating of walkins /// <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, byte tableNumber, int customerCount, int waiterId) { var availableSeats = AvailableSeatingByDateTime(when.Date, when.TimeOfDay); using (var context = new eRestaurantContext()) { List <string> errors = new List <string>(); // Rule checking: // - 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 if (!availableSeats.Exists(x => x.Table == tableNumber)) { errors.Add("Table is currently not available"); } else if (!availableSeats.Exists(x => x.Table == tableNumber && x.Seating >= customerCount)) { errors.Add("Insufficient seating capacity for number of customers."); } if (errors.Count > 0) { throw new BusinessRuleException("Unable to seat customer", errors); } Bill seatedCustomer = new Bill() { BillDate = when, NumberInParty = customerCount, WaiterID = waiterId, TableID = context.Tables.Single(x => x.TableNumber == tableNumber).TableID }; context.Bills.Add(seatedCustomer); context.SaveChanges(); } }
public void SpecialEvents_Add(SpecialEvent item) { using (eRestaurantContext context = new eRestaurantContext()) { var added = context.SpecialEvents.Add(item); context.SaveChanges(); } }
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(); } }
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(); } }
public int Waiter_Add(Waiter item) { using (eRestaurantContext context = new eRestaurantContext()) { var added = context.Waiters.Add(item); context.SaveChanges(); return(added.WaiterID); } }
public void Bill_Delete(Bill item) { using (eRestaurantContext context = new eRestaurantContext()) { Bill existing = context.Bill.Find(item.BillID); context.Bill.Remove(existing); context.SaveChanges(); } }
public void Reservations_Delete(Reservations item) { using (eRestaurantContext context = new eRestaurantContext()) { Reservations existing = context.Reservations.Find(item.ReservationID); context.Reservations.Remove(existing); context.SaveChanges(); } }
public void Waiter_Delete(Waiter item) { using (eRestaurantContext context = new eRestaurantContext()) { Waiter existing = context.Waiters.Find(item.WaiterID); context.Waiters.Remove(existing); context.SaveChanges(); } }
public void SpecialEvents_Delete(SpecialEvent item) { using (eRestaurantContext context = new eRestaurantContext()) { SpecialEvent existing = context.SpecialEvents.Find(item.EventCode); context.SpecialEvents.Remove(existing); context.SaveChanges(); } }
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(); } }
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(); } }
public void SpecialEvent_Add(SpecialEvent item) { using (eRestaurantContext context = new eRestaurantContext()) { SpecialEvent added = null; added = context.SpecialEvents.Add(item); //comment is not used until it is actully save context.SaveChanges(); } }
public void SpecialEvents_Add(SpecialEvent item) { using (eRestaurantContext context = new eRestaurantContext()) { SpecialEvent added = null; added = context.SpecialEvents.Add(item); context.SaveChanges(); //Commits the add to the database. //Furthermore, this evaluates the annotations (validates) on the entity. //Included: [Required], [StringLength], [Range], etc. } }
public void Waiters_Update(Waiter item) { using (eRestaurantContext context = new eRestaurantContext()) { //indicate the updating instance, alter the modified status flag for this instance context.Entry <Waiter>(context.Waiters.Attach(item)).State = System.Data.Entity.EntityState.Modified; //command not executed until saved context.SaveChanges(); } }
public void SpecialEvents_Add(SpecialEvent item) { using (eRestaurantContext context = new eRestaurantContext()) { SpecialEvent added = null; added = context.SpecialEvents.Add(item); // commits the add to the database // evaluates the annotations (validations) on your entity // [Required],[StringLength],[Range],... context.SaveChanges(); } }
public void SpecialEvents_Delete(SpecialEvent item) { using (eRestaurantContext context = new eRestaurantContext()) { //lookup the instance on the database to check if it exsists SpecialEvent exisiting = context.SpecialEvents.Find(item.EventCode); //set up the delete requset command context.SpecialEvents.Remove(exisiting); //commit the action to happen context.SaveChanges(); } }
public void SpecialEvent_Delete(SpecialEvent item) { using (eRestaurantContext context = new eRestaurantContext()) { //lookup the item instance to determine if the instance exists SpecialEvent existing = context.SpecialEvents.Find(item.EventCode); //setup the delete request command context.SpecialEvents.Remove(existing); //commit the action to happen. context.SaveChanges(); } }
public void Waiter_Delete(Waiter item) { using (eRestaurantContext context = new eRestaurantContext()) { //lookup the instance on the database to check if it exsists Waiter exisiting = context.Waiters.Find(item.WaiterID); //set up the delete requset command context.Waiters.Remove(exisiting); //commit the action to happen context.SaveChanges(); } }
public void SpecialEvents_Update(SpecialEvent item) { using (eRestaurantContext context = new eRestaurantContext()) { //indicate the updating item instance //alter the Modified Status flag for this instanc context.Entry <SpecialEvent>(context.SpecialEvents.Attach(item)).State = System.Data.Entity.EntityState.Modified; //command is not executed until it is actually saved. context.SaveChanges(); } }
public void Waiters_Delete(Waiter item) { using (eRestaurantContext context = new eRestaurantContext()) { //lookup the instance and record if found Waiter existing = context.Waiters.Find(item.WaiterID); //setup the command to execute the delete context.Waiters.Remove(existing); //command is not executed until it is actually saved context.SaveChanges(); } }
public void Waiters_Delete(Waiter item) { using (eRestaurantContext context = new eRestaurantContext()) { //look up the item instance on the database to determi8nje if the instance exist Waiter existing = context.Waiters.Find(item.WaiterID); //set up the delete request command context.Waiters.Remove(existing); //commit the action to happen context.SaveChanges(); } }
public void SeatCustomer(DateTime when, byte tablenumber, int numberinparty, int waiterid) { //business logic checking should be done //before attempting to place data on the database //rule 1: is the seat available //rule 2: is the selected table capacity sufficient //get the available seats var availableseats = AvailableSeatingByDateTime(when.Date, when.TimeOfDay); //start my transaction using (eRestaurantContext context = new eRestaurantContext()) { //my transaction //create a holding list for possible business logic errors //this is needed for the MessageUserControl List <string> errors = new List <string>(); if (!availableseats.Exists(foreachseat => foreachseat.Table == tablenumber)) { //the table number is not available errors.Add("Table is currently not available"); } else if (!availableseats.Exists(foreachseat => foreachseat.Table == tablenumber && foreachseat.Seating >= numberinparty)) { //the table is available but not large enough errors.Add("insufficient seating capacity fro number of customers"); } //check if any errors to business rules exist if (errors.Count > 0) { //throw an exception which will terminate the transaction //BusinessRule Exception is part of the MessageUserControl setup throw new BusinessRuleException("Unable to seat customer", errors); } //assume your data is valid //create an instance of the Bill entity and fill with data Bill seatedcustomer = new Bill(); seatedcustomer.BillDate = when; seatedcustomer.NumberInParty = numberinparty; seatedcustomer.WaiterID = waiterid; seatedcustomer.TableID = tablenumber; //issue the command to add a record to the Bill entity context.Bills.Add(seatedcustomer); //save and commit the changes to the entity context.SaveChanges(); }//end of the transaction }
public void waiter_Delete(Waiter item) { using (eRestaurantContext context = new eRestaurantContext()) { //lookup the instance and record if found (set pointer to instance) Waiter existing = context.Waiters.Find(item.WaiterID); //Setup the comand to execute the delete context.Waiters.Remove(existing); context.SaveChanges(); } }//eofclass
public void Waiters_Delete(Waiter item) { using (eRestaurantContext context = new eRestaurantContext()) { //look the item instance on the database to determine if it exists //on the delete ensure you reference the P-Key Waiter existing = context.Waiters.Find(item); //set up the data request command context.Waiters.Remove(existing); //commit the action to happen context.SaveChanges(); } }
public void SpecialEvents_Delete(SpecialEvent item) { using (eRestaurantContext context = new eRestaurantContext()) { //lookup the instance and record if found (set pointer to instance) SpecialEvent existing = context.SpecialEvents.Find(item.EventCode); //setup the command to execute the delete context.SpecialEvents.Remove(existing); //command is not executed until it is actually saved. context.SaveChanges(); } }
public void Waiters_Delete(Waiter item) { using (eRestaurantContext context = new eRestaurantContext()) { // indicate the updateing item instance //alter the Modified Status flag for this instance Waiter existing = context.Waiters.Find(item.WaiterID); // set up the command to execute the delete context.Waiters.Remove(existing); //command is not executed until it it actually saved. context.SaveChanges(); } }
public void SpecialEvents_Add(SpecialEvent item) { using (eRestaurantContext context = new eRestaurantContext()) { //these methods are execute using an instance level item //set up a instance pointer and initialize to null SpecialEvent added = null; //setup the command to execute the add added = context.SpecialEvents.Add(item); //command is not executed until it is actually saved. context.SaveChanges(); } }
public int Waiters_Add(Waiter item) { using (eRestaurantContext context = new eRestaurantContext()) { Waiter added = null; added = context.Waiters.Add(item); //comment is not used until it is actully save context.SaveChanges(); //the waiter instence added contains the newly inserted //record to sql including the genrated pkey value return(added.WaiterID); } }
public void SpecialEvents_Delete(SpecialEvent item) { using (eRestaurantContext context = new eRestaurantContext()) { //look up the item instance on the database to determine if //the instance exists //on the delete make sure you reference the PK field name SpecialEvent existing = context.SpecialEvents.Find(item.EventCode); //setup the delete request command context.SpecialEvents.Remove(existing); //commit the action to happen context.SaveChanges(); } }
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(); } }