public async Task <ActionResult> Delete(string id) { try { Analytics.TrackEvent("ToDoController:Delete"); bool status = await _toDoService.Delete(id); if (!status) { Logger.Error("ToDoController : Delete : " + id + " id is not present in the database"); return(RedirectToAction("Index", "Error")); } } catch (Exception ex) { Logger.Error("ToDoController Unable to consume Delete:" + ex.Message + ex.StackTrace); return(RedirectToAction("Index", "Error")); } finally { //This is to dispose the object Dispose(); } return(RedirectToAction("Index")); }
public async Task <JsonResult> Delete(string id) { string result = ""; try { Analytics.TrackEvent("ToDoController:Delete"); bool status = await _toDoBL.Delete(id); if (!status) { Logger.Error("ToDoController : Delete : " + id + " id is not present in the database"); result = "Error"; } } catch (Exception ex) { Logger.Error("ToDoController Unable to consume Delete:" + ex.Message + ex.StackTrace); result = "Error"; } finally { //This is to dispose the object Dispose(); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public async Task <HttpResponseMessage> Delete(string id) { try { Logger.Information("ToDoController Request Delete:" + id); var status = await _toDoBL.Delete(id); if (status) { Logger.Information("ToDoController Response Delete:" + id); var message = Request.CreateResponse(HttpStatusCode.Accepted, "Record has been deleted"); return(message); } else { return(Request.CreateResponse(HttpStatusCode.NotFound)); } } catch (Exception ex) { Logger.Error("ToDoController Unable to consume Delete:" + ex.Message + ex.StackTrace); var message = Request.CreateResponse(HttpStatusCode.InternalServerError); return(message); } finally { Dispose(); } }
public JsonResult Delete(int id) { string result = string.Empty; try { Logger.Information("HomeController Request Delete:" + id); bool status = _toDoService.Delete(id); if (!status) { Logger.Error("HomeController : Passed id is not present in the database"); result = "error"; } Logger.Information("HomeController Response Delete:" + id); } catch (Exception ex) { Logger.Error("HomeController Unable to consume Delete:" + ex.Message + ex.StackTrace); result = "error"; } finally { Dispose(); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public HttpResponseMessage Delete(int id) { try { var status = _toDoBL.Delete(id); if (status) { var message = Request.CreateResponse(HttpStatusCode.OK, "Deleted Successfully"); return(message); } else { return(Request.CreateResponse(HttpStatusCode.NotFound)); } } catch (Exception ex) { Logger.Error("ToDoController Unable to consume Delete:" + ex.Message + ex.StackTrace); var message = Request.CreateResponse(HttpStatusCode.InternalServerError); return(message); } finally { Dispose(); } }