public JsonResult DeleteSector(long sectorId) { if (_sectorSvc.DeleteSector(sectorId) == true) { return(Json("Success", JsonRequestBehavior.AllowGet)); } return(Json("Failure", JsonRequestBehavior.AllowGet)); }
public IHttpActionResult DeleteSector(DeleteSectorRequest deleteSectorRequest) { var responses = new Responses(); try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (Utility.UserId < 0) { return(BadRequest(Utility.INVALID_USER)); } var sector = new Sector() { SectorId = deleteSectorRequest.SectorId, ModifiedBy = Utility.UserId }; int result = iSector.DeleteSector(sector); switch (result) { case 1: responses.Status = Utility.SUCCESS_STATUS_RESPONSE; responses.Description = "Sector deleted successfully."; break; case -2: responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Sector doesn't exist."; break; default: responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while deleting sector."; break; } } catch (Exception ex) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while deleting sector."; Utility.WriteLog("DeleteSector", deleteSectorRequest, "Error while deleting sector. (SectorAdminController)", ex.ToString()); } return(Ok(responses)); }