public ActionResult List(GridCommand command, LocationSearchModel searchModel) { SearchCacheModel searchCacheModel = this.ProcessSearchModel(command, searchModel); ViewBag.PageSize = base.ProcessPageSize(command.PageSize); return(View()); }
public ActionResult List() { if (userContext.ContextName != UserContext.UserContextName.Provider) { return(RedirectToAction("Index", "Home")); } Provider provider = db.Providers.Find(userContext.ItemId); if (provider == null) { return(HttpNotFound()); } var model = new LocationSearchModel(); foreach ( Location v in db.Locations.Include("Address") .Include("RecordStatu") .Where(x => x.ProviderId == userContext.ItemId) .OrderByDescending(x => x.ModifiedDateTimeUtc ?? x.CreatedDateTimeUtc)) { model.Locations.Add(new ListLocationModel(v)); } ViewBag.CanProviderCreateNewLocation = CanProviderCreateNewLocation(provider, out Int32 maxNumberOfLocations); ViewBag.MaxNumberOfLocations = maxNumberOfLocations.ToString("N0"); return(View(model)); }
/// <summary> /// Search locations /// </summary> /// <param name="model"></param> /// <returns></returns> private IQueryable <Location> SearchLocations(LocationSearchModel model) { if (model.LocationTypeIds == null) { model.LocationTypeIds = new List <int>(); } return(Fetch(location => (string.IsNullOrEmpty(model.Keyword) || (!string.IsNullOrEmpty(location.Name) && location.Name.Contains(model.Keyword)) || (!string.IsNullOrEmpty(location.AddressLine1) && location.AddressLine1.Contains(model.Keyword)) || (!string.IsNullOrEmpty(location.AddressLine2) && location.AddressLine2.Contains(model.Keyword)) || (!string.IsNullOrEmpty(location.State) && location.State.Contains(model.Keyword)) || (!string.IsNullOrEmpty(location.Suburb) && location.Suburb.Contains(model.Keyword)) || (!string.IsNullOrEmpty(location.Postcode) && location.Postcode.Contains(model.Keyword)) || (!string.IsNullOrEmpty(location.Country) && location.Country.Contains(model.Keyword)) || (!string.IsNullOrEmpty(location.ContactName) && location.ContactName.Contains(model.Keyword)) || (!string.IsNullOrEmpty(location.ContactTitle) && location.ContactTitle.Contains(model.Keyword)) || (!string.IsNullOrEmpty(location.Email) && location.Email.Contains(model.Keyword)) || (!string.IsNullOrEmpty(location.Phone) && location.Phone.Contains(model.Keyword)) || (!string.IsNullOrEmpty(location.Fax) && location.Fax.Contains(model.Keyword)) || (!string.IsNullOrEmpty(location.TrainingAffiliation) && location.TrainingAffiliation.Contains(model.Keyword))) && (!model.LocationTypeIds.Any() || location.LocationLocationTypes.Any( locationLocationType => model.LocationTypeIds.Contains(locationLocationType.LocationTypeId))) && (!model.AssociateId.HasValue || location.AssociateLocations.Any(associateLocation => associateLocation.AssociateId == model.AssociateId)))); }
/// <summary> /// Search the Locations. /// </summary> /// <returns></returns> public JqGridSearchOut SearchLocations(JqSearchIn si, LocationSearchModel model) { var data = SearchLocations(model); var locations = Maps(data); return(si.Search(locations)); }
/// <summary> /// Export Locations /// </summary> /// <param name="si"></param> /// <param name="gridExportMode"></param> /// <param name="model"></param> /// <returns></returns> public ActionResult Exports(JqSearchIn si, GridExportMode gridExportMode, LocationSearchModel model) { var workbook = _locationService.Exports(si, gridExportMode, model); var output = new MemoryStream(); workbook.Write(output); return(File(output.ToArray(), "application/vnd.ms-excel", "Locations.xls")); }
/// <summary> /// Export Locations /// </summary> /// <param name="si"></param> /// <param name="model"></param> /// <param name="gridExportMode"></param> /// <returns></returns> public HSSFWorkbook Exports(JqSearchIn si, GridExportMode gridExportMode, LocationSearchModel model) { var data = gridExportMode == GridExportMode.All ? GetAll() : SearchLocations(model); var locations = Maps(data); var exportData = si.Export(locations, gridExportMode); return(ExcelUtilities.CreateWorkBook(exportData)); }
public ActionResult _AjaxList(GridCommand command, LocationSearchModel searchModel) { searchModel.IsActive = true; if (searchModel.IsIncludeInActive) { searchModel.IsActive = false; } SearchStatementModel searchStatementModel = this.PrepareSearchStatement(command, searchModel); return(PartialView(GetAjaxPageData <Location>(searchStatementModel, command))); }
public async Task <LocationListModel> PrepareShelfLocationFormatListModel(LocationSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } var shelfLocationFormats = await _locationService.GetAllShelfLocationFormatsAsync(); if (shelfLocationFormats == null) { throw new ArgumentNullException(nameof(shelfLocationFormats)); } var model = new LocationListModel { //Data = shelfLocationFormats.Select(shelfLocationFormat => //{ // var shelfLocationFormatsModel = shelfLocationFormat.ToModel<LocationModel>(); // return shelfLocationFormatsModel; //}), Data = shelfLocationFormats.PaginationByRequestModel(searchModel).Select(shelfLocationFormat => { var shelfLocationFormatsModel = shelfLocationFormat.ToModel <LocationModel>(); return(shelfLocationFormatsModel); }), Total = shelfLocationFormats.Count }; // sort if (searchModel.Sort != null && searchModel.Sort.Any()) { foreach (var s in searchModel.Sort) { model.Data = await model.Data.Sort(s.Field, s.Dir); } } // filter if (searchModel.Filter != null && searchModel.Filter.Filters != null && searchModel.Filter.Filters.Any()) { var filter = searchModel.Filter; model.Data = await model.Data.Filter(filter); model.Total = model.Data.Count(); } return(model); }
public void Verify_Search_WithPaging_Should_ReturnAListOfLocationsWithDataMatchingSearchParameters() { // Arrange Mock <IDbSet <Location> > mockSetLocations; var mockContext = LocationsMockingSetup.DoMockingSetupForContext(true, out mockSetLocations); var repository = new LocationsRepository(mockContext.Object); var searchModel = new LocationSearchModel { Paging = new Paging { Skip = 1, Take = 1 } }; // Act var locations = repository.Search(searchModel /*.Object*/).ToArray(); // Assert Assert.Equal(1, locations.Length); Assert.Equal(2, locations[0].Id); Assert.Equal("/TEST/NIVEN-LARRY", locations[0].ApiDetailUrl); // Stephen King was filtered out because he was Skipped }
/// <summary> /// Search Statement /// </summary> /// <param name="command">Telerik GridCommand</param> /// <param name="searchModel">Location Search Model</param> /// <returns>Search Statement</returns> private SearchStatementModel PrepareSearchStatement(GridCommand command, LocationSearchModel searchModel) { string whereStatement = string.Empty; IList <object> param = new List <object>(); HqlStatementHelper.AddLikeStatement("SAPLocation", searchModel.SAPLocation, HqlStatementHelper.LikeMatchMode.Start, "u", ref whereStatement, param); HqlStatementHelper.AddLikeStatement("Code", searchModel.Code, HqlStatementHelper.LikeMatchMode.Start, "u", ref whereStatement, param); HqlStatementHelper.AddLikeStatement("Name", searchModel.Name, HqlStatementHelper.LikeMatchMode.Start, "u", ref whereStatement, param); HqlStatementHelper.AddEqStatement("Region", searchModel.Region, "u", ref whereStatement, param); HqlStatementHelper.AddEqStatement("IsActive", searchModel.IsActive, "u", ref whereStatement, param); if (searchModel.AllowNegaInv) { HqlStatementHelper.AddEqStatement("AllowNegative", searchModel.AllowNegaInv, "u", ref whereStatement, param); } if (searchModel.IsMRP) { HqlStatementHelper.AddEqStatement("IsMRP", searchModel.IsMRP, "u", ref whereStatement, param); } if (searchModel.AllowNegativeConsignment) { HqlStatementHelper.AddEqStatement("AllowNegativeConsignment", searchModel.AllowNegativeConsignment, "u", ref whereStatement, param); } if (searchModel.IsSource) { HqlStatementHelper.AddEqStatement("IsSource", searchModel.IsSource, "u", ref whereStatement, param); } string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors); SearchStatementModel searchStatementModel = new SearchStatementModel(); searchStatementModel.SelectCountStatement = selectCountStatement; searchStatementModel.SelectStatement = selectStatement; searchStatementModel.WhereStatement = whereStatement; searchStatementModel.SortingStatement = sortingStatement; searchStatementModel.Parameters = param.ToArray <object>(); return(searchStatementModel); }
public void Verify_Search_WithModifiedSince_Should_ReturnAListOfLocationsWithDataMatchingSearchParameters() { // Arrange Mock <IDbSet <Location> > mockSetLocations; var mockContext = LocationsMockingSetup.DoMockingSetupForContext(true, out mockSetLocations, true); var repository = new LocationsRepository(mockContext.Object); var createDate = new System.DateTime(2015, 05, 28, 10, 45, 00).AddDays(1).AddMinutes(-1); //var searchModel = new Mock<ILocationSearchModel>(); //searchModel.Setup(m => m.ModifiedSince).Returns(() => createDate); var searchModel = new LocationSearchModel { ModifiedSince = createDate }; // Act var locations = repository.Search(searchModel /*.Object*/).ToArray(); // Assert Assert.Equal(1, locations.Length); Assert.Equal(2, locations[0].Id); Assert.Equal("/TEST/NIVEN-LARRY", locations[0].ApiDetailUrl); // Stephen King was filtered out because he was created before the modified since date }
public string _AjaxBinding(JqSearchIn si, LocationSearchModel model) { return(JsonConvert.SerializeObject(_locationService.SearchLocations(si, model))); }
public async Task <IActionResult> SearchByLocation(LocationSearchModel model) { var result = await DocumentDBRepository <Property> .GetItemsAsync(p => p.Location.Distance(new Point(model.Longitude, model.Latitude)) < model.Radius); return(Json(result)); }
public async Task <LocationSearchModel> PrepareShelfLocationFormatSearchModel(LocationSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //prepare page parameters searchModel.SetGridPageSize(); return(await Task.FromResult(searchModel)); }
public void Verify_Search_WithPaging_Should_ReturnAListOfLocationsWithDataMatchingSearchParameters() { // Arrange Mock<IDbSet<Location>> mockSetLocations; var mockContext = LocationsMockingSetup.DoMockingSetupForContext(true, out mockSetLocations); var repository = new LocationsRepository(mockContext.Object); var searchModel = new LocationSearchModel { Paging = new Paging { Skip = 1, Take = 1 } }; // Act var locations = repository.Search(searchModel/*.Object*/).ToArray(); // Assert Assert.Equal(1, locations.Length); Assert.Equal(2, locations[0].Id); Assert.Equal("/TEST/NIVEN-LARRY", locations[0].ApiDetailUrl); // Stephen King was filtered out because he was Skipped }
public void Verify_Search_WithModifiedSince_Should_ReturnAListOfLocationsWithDataMatchingSearchParameters() { // Arrange Mock<IDbSet<Location>> mockSetLocations; var mockContext = LocationsMockingSetup.DoMockingSetupForContext(true, out mockSetLocations, true); var repository = new LocationsRepository(mockContext.Object); var createDate = new System.DateTime(2015, 05, 28, 10, 45, 00).AddDays(1).AddMinutes(-1); //var searchModel = new Mock<ILocationSearchModel>(); //searchModel.Setup(m => m.ModifiedSince).Returns(() => createDate); var searchModel = new LocationSearchModel { ModifiedSince = createDate }; // Act var locations = repository.Search(searchModel/*.Object*/).ToArray(); // Assert Assert.Equal(1, locations.Length); Assert.Equal(2, locations[0].Id); Assert.Equal("/TEST/NIVEN-LARRY", locations[0].ApiDetailUrl); // Stephen King was filtered out because he was created before the modified since date }