public IHttpActionResult GetSector([FromUri] GetSectorRequest getSectorRequest) { var responses = new Responses(); try { if (Utility.UserId < 0) { return(BadRequest(Utility.INVALID_USER)); } if (getSectorRequest == null) { getSectorRequest = new GetSectorRequest(); } if (getSectorRequest.PageSize == null) { getSectorRequest.PageSize = Convert.ToInt32(ConfigurationManager.AppSettings["PageSize"]); } var sector = new Sector() { SectorId = getSectorRequest.SectorId, SearchText = getSectorRequest.SearchText, IsActive = getSectorRequest.IsActive, PageNumber = getSectorRequest.PageNumber, PageSize = Convert.ToInt32(getSectorRequest.PageSize), IsPagingRequired = (getSectorRequest.PageNumber != null) ? true : false, OrderBy = getSectorRequest.OrderBy, OrderByDirection = getSectorRequest.OrderByDirection }; var sectors = iSector.GetSector(sector); var sectorList = new List <GetSectorResponse>(); foreach (var sectorDetail in sectors) { sectorList.Add(new GetSectorResponse() { SectorId = Convert.ToInt32(sectorDetail.SectorId), Name = sectorDetail.Name, IsActive = Convert.ToBoolean(sectorDetail.IsActive), CreatedBy = sectorDetail.CreatedBy, TotalPageCount = sectorDetail.TotalPageCount, TotalRecord = sectorDetail.TotalRecord }); } responses.Status = Utility.SUCCESS_STATUS_RESPONSE; responses.Description = "Sector retrieved successfully"; responses.Response = sectorList.OrderBy(x => x.Name).ToList(); } catch (Exception ex) { responses.Status = Utility.ERROR_STATUS_RESPONSE; responses.Description = "Error while retrieving sector."; Utility.WriteLog("GetSector", getSectorRequest, "Error while retrieving sector. (SectorUserController)", ex.ToString()); } return(Ok(responses)); }