private string GetFilterString(TenantSearchModel searchModel) { var filterString = string.Empty; if (searchModel != null) { filterString = ODataFilterConstant.Expand + $"Person,Property"; if (!string.IsNullOrWhiteSpace(searchModel.TenantCode)) { filterString += ODataFilterConstant.Filter + $"TenantCode eq '{searchModel.TenantCode}'"; } else if (!string.IsNullOrWhiteSpace(searchModel.PropertyCode)) { filterString += ODataFilterConstant.Filter + $"Property/PropertyCode eq '{searchModel.PropertyCode}'"; } if (!string.IsNullOrWhiteSpace(searchModel.FilterText)) { if (string.IsNullOrWhiteSpace(filterString)) { filterString += ODataFilterConstant.Filter + $"contains(Person/Forename,'{searchModel.FilterText}') eq true"; } else { filterString += $" or contains(Person/Forename,'{searchModel.FilterText}') eq true"; } filterString += $" or contains(Person/Surname,'{searchModel.FilterText}') eq true"; } AddPageSizeNumberAndSortingInFilterString(searchModel, ref filterString); } return(filterString); }
public IActionResult Grid(TenantSearchModel model) { model = InitializeModel(model); var result = _customerFacadeApiClient.GetTenants(model).Result; return(PartialView(result)); }
public IActionResult Tenant(TenantSearchModel model) { model = InitializeTenantModel(model); if (Request.IsAjaxRequest()) { var result = _customerApiClient.GetTenants(model).Result; result.PropertyCode = result.TenantSearchResult.First()?.Property?.PropertyCode; return(PartialView(result)); } return(View(model)); }
public async Task <TenantSearchModel> GetTenants(TenantSearchModel model) { var url = ODataApiUri + "/Tenant?" + GetFilterStringForTenant(model); var result = await GetOdataResultFromApi(url); var searchResultCount = 0; if (result.Count != null) { int.TryParse(result.Count.ToString(), out searchResultCount); } model.TotalRows = searchResultCount; model.TenantSearchResult.Clear(); model.TenantSearchResult.AddRange(result.Items.Select(item => JsonConvert.DeserializeObject <TenantDto>(item.ToString()))); return(model); }
private string GetFilterStringForTenant(TenantSearchModel searchModel) { var filterString = string.Empty; if (searchModel != null) { if (!string.IsNullOrWhiteSpace(searchModel.PropertyCode)) { filterString = ODataFilterConstant.Filter + $"Property/PropertyCode eq '{searchModel.PropertyCode}'"; } filterString += GetFilterStringForAssociatedEntities(new List <string> { "Property", "Person" }); AddPageSizeNumberAndSortingInFilterString(searchModel, ref filterString); } return(filterString); }
private TenantSearchModel InitializeModel(TenantSearchModel model) { if (model == null) { model = new TenantSearchModel { SortColumn = "TenantCode", SortDirection = "Asc", PageSize = 8, PageNumber = 1 }; } else { if (string.IsNullOrWhiteSpace(model.SortColumn)) { model.SortColumn = "TenantCode"; model.SortDirection = "Asc"; } } model.TargetGridId = "TenantGrid"; return(model); }
public async Task <TenantSearchModel> GetTenants(TenantSearchModel model) { return(await _tenantApiClient.GetTenants(model)); }
private TenantSearchModel InitializeTenantGridModel(TenantSearchModel model) { model = InitializeSearchModel(model, "TenantGrid", "TenantCode", "Desc"); return(model); }
public IActionResult Tenant(TenantSearchModel model) { model = InitializeTenantGridModel(model); model = _propertyFacadeApiClient.GetTenants(model).Result; return(PartialView(model)); }