示例#1
0
        public async Task <ActionResult> Edit(LeaveTypeViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                var leaveType = _mapper.Map <LeaveType>(model);

                var isSuccess = await _repo.Update(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 Edit(LeaveTypeVM model)
 {
     try
     {
         var leavetype = _mapper.Map <LeaveType>(model);
         leavetype.DateCreated = DateTime.Now;
         var isSuccess = _repo.Update(leavetype);
         if (!isSuccess)
         {
             ModelState.AddModelError("", "somethig went wrong...");
             return(View(model));
         }
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         ModelState.AddModelError("", "somethig went wrong...");
         return(View(model));
     }
 }
 public async Task <bool> Update(LeaveType entity)
 {
     return(await _repo.Update(entity));
 }