public IHttpActionResult Delete(int id) { ApiResData res = new ApiResData(); try { if (!ModelState.IsValid) { rs.SetErrorStatus(eFunc.fg.SFailed); resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Delete, new Exception(eFunc.fg.DataNf))); return(Content(HttpStatusCode.NotFound, resObj)); } rs = repo.Delete(id, "System", CurrentUser.GetCurrentDateTime()); if (rs.IsSuccess) { rs.SetSuccessStatus(); } else { rs.SetErrorStatus(eFunc.fg.SFailed); } resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Delete, null)); return(Content(HttpStatusCode.OK, resObj)); } catch (Exception ex) { rs.SetErrorStatus(ex.Message); resObj = JObject.FromObject(res.ResCUD(new object[] { rs }, eFunc.fg.Delete, new Exception(eFunc.fg.DFailed))); return(Content(HttpStatusCode.BadRequest, resObj)); } }
public ActionResult ActionDelete(int id) { try { string userId = Session["UserId"].ToString(); DateTime dt = DateTime.Now; rs = repo.Delete(id); if (rs.IsSuccess) { rs.SetSuccessStatus("Data has been deleted successfully"); TempData["msgSuccess"] = rs.MessageText; } else { rs.SetErrorStatus("Data failed to deleted"); TempData["msgError"] = rs.MessageText; } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); rs.SetErrorStatus("Data failed to deleted"); TempData["msgError"] = rs.MessageText; } return(RedirectToAction("Index")); }