public async Task <IActionResult> Edit(GuestEditViewModel model) { if (ModelState.IsValid) { var guest = _guestService.GetById(model.Id); if (guest == null) { return(NotFound()); } guest.MobileNo = model.MobileNo; guest.Email = model.Email; guest.Address = model.Address; guest.RoomType = model.RoomType; guest.TotalCharges = _guestService.GetTotalCharges(model.FromDate, model.ToDate, _guestService.PerDayCharges(model.RoomType)); guest.FromDate = model.FromDate; guest.ToDate = model.ToDate; await _guestService.UpdateAsync(guest); return(RedirectToAction(nameof(Index))); } return(View()); }
public IActionResult Edit(int id) { var guest = _guestService.GetById(id); if (guest == null) { return(NotFound()); } var model = new GuestEditViewModel() { Id = guest.Id, FirstName = guest.FirstName, LastName = guest.LastName, MobileNo = guest.MobileNo, Email = guest.Email, Address = guest.Address, RoomType = guest.RoomType, FromDate = guest.FromDate, ToDate = guest.ToDate }; return(View(model)); }