public async Task <ActionResult> Edit(EditLeaveAllocationVm model) { try { if (!ModelState.IsValid) { return(View(model)); } var record = await _AllocationRepo.FindById(model.Id); record.NumberOfDays = model.NumberOfDays; var isSuccess = await _AllocationRepo.Update(record); if (!isSuccess) { ModelState.AddModelError("", "Something Went Wrong...."); return(View(model)); } return(RedirectToAction(nameof(Details), new { id = model.EmployeeId })); } catch { ModelState.AddModelError("", "Something Went Wrong...."); return(View(model)); } }
public ActionResult Edit(EditLeaveAllocationVm model) { try { if (!ModelState.IsValid) { return(View(model)); } var record = _leaveallocationrepo.FindById(model.Id); record.NumberOfDays = model.NumberOfDays; var isSuccess = _leaveallocationrepo.Update(record); if (!isSuccess) { ModelState.AddModelError("", "Error while saving"); } return(RedirectToAction(nameof(Details), new { id = model.EmployeeId })); } catch { return(View(model)); } }