public void DeleteToys(int id) { var data = toys.Toys.SingleOrDefault(s => s.ToyId == id); toys.Remove(data); toys.SaveChanges(); }
public void DeleteCustomer(int id) { var data = customer.Customers.SingleOrDefault(s => s.CustomerId == id); customer.Remove(data); customer.SaveChanges(); }
void IDeleteBooking.DeleteBooking(string toyname, string customername) { var custid = context.ToysPeople.Include(s => s.Toy).Include(s => s.Customer).SingleOrDefault (s => s.Customer.CustomerName == customername && s.Toy.ToyName == toyname); if (custid != null) { context.ToysPeople.Remove(custid); context.SaveChanges(); } else { throw new Exception("Data is not Found"); } }
void IBooking.bookingdata(string toyName, string custName) { var customerid = c1.Customers.Single(s => s.CustomerName == custName); var toyida = c1.Toys.Single(s => s.ToyName == toyName); List <ToysPerson> bookingdata = new List <ToysPerson>() { new ToysPerson() { CustomerId = customerid.CustomerId, ToyId = toyida.ToyId } }; foreach (var item in bookingdata) { c1.ToysPeople.Add(item); c1.SaveChanges(); } }