Beispiel #1
0
        // GET: LeaveTypeController/Delete/5
        public async Task <ActionResult> Delete(int id)
        {
            try
            {
                var leaveType = await _repo.FindById(id);

                if (leaveType == null)
                {
                    return(NotFound());
                }

                var isSuccess = await _repo.Delete(leaveType);

                if (!isSuccess)
                {
                    ModelState.AddModelError("", "Something went wrong");
                    return(BadRequest());
                }

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