public async Task <ActionResult> Create(LeaveTypeViewModel model) { try { if (!ModelState.IsValid) { return(View(model)); } var leaveType = _mapper.Map <LeaveType>(model); leaveType.DateCreated = DateTime.Now; var isSuccess = await _repo.Create(leaveType); if (!isSuccess) { ModelState.AddModelError("", "Something went wrong."); return(View(model)); } return(RedirectToAction(nameof(Index))); } catch { ModelState.AddModelError("", "Something went wrong."); return(View(model)); } }
public ActionResult Create(LeaveTypeVM model) { try { if (!ModelState.IsValid) { return(View(model)); } var leavetype = _mapper.Map <LeaveType>(model); leavetype.DateCreated = DateTime.Now; var isSuccess = _repo.Create(leavetype); if (!isSuccess) { ModelState.AddModelError("", "somethig went wrong..."); return(View(model)); } return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public async Task <bool> Create(LeaveType entity) { return(await _repo.Create(entity)); }