Exemple #1
0
        public async Task <IActionResult> Delete(int id)
        {
            var isDeleted = await _service.Delete(id);

            if (isDeleted)
            {
                return(RedirectToAction(nameof(Index)));
            }

            ModelState.AddModelError("", "Something went wrong...");
            return(RedirectToAction(nameof(Index)));
        }
Exemple #2
0
 // DELETE: api/LeaveTypes/5
 public HttpResponseMessage DeleteLeaveType(int id)
 {
     try
     {
         var message = Request.CreateErrorResponse(HttpStatusCode.NotFound, "404 : Data Not Found");
         var result  = iLeaveTypesService.Delete(id);
         if (result)
         {
             message = Request.CreateResponse(HttpStatusCode.OK, "200 : OK (Data Deleted)");
         }
         return(message);
     }
     catch (Exception e)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "500 : Internal Server Error"));
     }
 }