Esempio n. 1
0
        public async Task <ActionResult> Delete(int id, LeaveTypeViewModel model)
        {
            try
            {
                var leavetype = await _repo.FindById(id);

                if (leavetype == null)
                {
                    return(NotFound());
                }
                var isSuccess = await _repo.Delete(leavetype);

                if (!isSuccess)
                {
                    return(View(model));
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View(model));
            }
        }
 public ActionResult Edit(LeaveTypeViewModel model)
 {
     try
     {
         // TODO: Add update logic here
         if (!ModelState.IsValid)
         {
             return(View(model));
         }
         var leaveType = _mapper.Map <LeaveType>(model);
         var isSuccess = _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());
     }
 }
 public ActionResult Create(LeaveTypeViewModel model)
 {
     return(View());
 }