// GET: LeaveTypesController/Details/5 public async Task <ActionResult> Details(int id) { if (!(await _repo.Exists(id))) { return(NotFound()); } var leaveTypeVM = _mapper.Map <LeaveTypeViewModel>(await _repo.FindById(id)); return(View(leaveTypeVM)); }
// GET: LeaveTypesController/Details/5 public ActionResult Details(int id) { if (!_repo.Exists(id)) { return(NotFound()); } var leaveType = _repo.FindById(id); var model = _mapper.Map <LeaveTypeVM>(leaveType); return(View(model)); }
// GET: LeaveTypesController/Details/5 public ActionResult Details(int id) { if (!repo.Exists(id)) { return(NotFound()); } LeaveType leaveType = repo.FindById(id); LeaveTypeVM model = mapper.Map <LeaveTypeVM>(leaveType); return(View(model)); }
// GET: LeaveTypesController/Details/5 public async Task <ActionResult> Details(int id) { var isExists = await _repo.Exists(id); if (!isExists) { return(NotFound()); } var obj = await _repo.FindById(id); var objVm = _mapper.Map <LeaveTypeVM>(obj); return(View(objVm)); }
// GET: LeaveTypes/Details/5 public async Task <ActionResult> Details(int id) { var exists = await _repo.Exists(id); // is awaiting here any different than if (!_repo.Exists(id).Result) ? if (!exists) { return(NotFound()); } var leaveType = await _repo.FindById(id); var model = _mapper.Map <LeaveTypeVM>(leaveType); return(View(model)); }
public ActionResult Edit(LeaveTypeViewModel model) { try { if (ModelState.IsValid) { //check if leave with id passed exists if (!_leaveTypeRepo.Exists(model.Id)) { return(NotFound()); } var leaveType = _mapper.Map <LeaveType>(model); if (_leaveTypeRepo.Update(leaveType)) { return(RedirectToAction(nameof(Index))); } ModelState.AddModelError("", "Something went wrong..."); } return(View(model)); } catch { ModelState.AddModelError("", "Something went wrong..."); return(View(model)); } }