public ActionResult Edit(Customer customer, int id) { if (ModelState.IsValid) { HSSContext db = new HSSContext(); var x = db.Customer.Single(u => u.CustomerId == id); x.Name = customer.Name; x.Surname = customer.Surname; x.Date_from = customer.Date_from; x.Date_to = customer.Date_to; x.Room = customer.Room; db.SaveChanges(); return(RedirectToAction("Manage")); } return(View(customer)); }
public ActionResult Delete(int id) { string hotelName = HotelName.GetHotelName(User.Identity.GetUserName()); var customer = db.Customer.Single(x => x.CustomerId == id); if (customer.HotelName == hotelName) { HSSContext db = new HSSContext(); var x = db.Customer.First(u => u.CustomerId == id); db.Customer.Remove(x); db.SaveChanges(); return(View()); } else { return(RedirectToAction("Manage")); } }