public JsonResult CreateSector(string sectorName) { if (_sectorSvc.AddSector(sectorName) == true) { return(Json("Success", JsonRequestBehavior.AllowGet)); } return(Json("Failure", JsonRequestBehavior.AllowGet)); }
public IHttpActionResult AddSector(AddSectorRequest addSectorRequest) { var responses = new Responses(); try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var sector = new Sector() { Name = addSectorRequest.Name, CreatedBy = Utility.UserId }; int result = iSector.AddSector(sector); if (result > 0) { responses.Status = Utility.SUCCESS_STATUS_RESPONSE; responses.Description = "Sector added successfully."; } else if (result == -2) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Sector alread exists."; } else { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while adding sector."; } } catch (Exception ex) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while adding sector."; Utility.WriteLog("AddSector", addSectorRequest, "Error while adding sector. (SectorAdminController)", ex.ToString()); } return(Ok(responses)); }