public IPagedList <PortalLocationViewModel> SearchPortalLocation(PortalLocationSearchModel model) { try { var sortString = !string.IsNullOrEmpty(model.SortString) ? model.SortString : "CreatedDate DESC"; var query = (from l in _dbConfigContext.PortalLocationControls where l.Deleted == false && l.IsActive == true && (string.IsNullOrEmpty(model.PortalUniqueId) || l.PortalUniqueId == model.PortalUniqueId) && (model.CityCode == 0 || l.CityCode == model.CityCode) && (model.CountryCode == 0 || l.CountryCode == model.CountryCode) select new PortalLocationViewModel { Id = l.Id, PortalUniqueId = l.PortalUniqueId, DomainPortalFID = l.DomainPortalFid, CityName = l.CityName, CityCode = l.CityCode, CountryName = l.CountryName, CountryCode = l.CountryCode, FileStreamFID = l.FileStreamFid, CreatedBy = l.CreatedBy, CreatedDate = l.CreatedDate, LastModifiedBy = l.LastModifiedBy, LastModifiedDate = l.LastModifiedDate, Deleted = l.Deleted, IsActive = l.IsActive }).OrderBy(sortString); return(new PagedList <PortalLocationViewModel>(query, model.PageIndex, model.PageSize)); } catch { throw; } }
public IActionResult SearchPortalLocation([FromQuery] PortalLocationSearchModel searchModel) { try { var result = _portalLocationService.SearchPortalLocation(searchModel); return(Ok(result)); } catch (Exception ex) { return(BadRequest(ex.StackTrace.ToString())); } }