示例#1
0
        // GET: Customer
        public ActionResult Index(CustomerSearchModel customerSearchModel)
        {
            var result = db.Customers.AsQueryable();

            if (customerSearchModel != null)
            {
                if (!string.IsNullOrEmpty(customerSearchModel.CustomerID))
                {
                    result = result.Where(x => x.CustomerID.Contains(customerSearchModel.CustomerID));
                }
                else if (!string.IsNullOrEmpty(customerSearchModel.ContactName))
                {
                    result = result.Where(x => x.ContactName.Contains(customerSearchModel.ContactName));
                }
                else if (!string.IsNullOrEmpty(customerSearchModel.City))
                {
                    result = result.Where(x => x.City.Contains(customerSearchModel.City));
                }
                else if (!string.IsNullOrEmpty(customerSearchModel.Country))
                {
                    result = result.Where(x => x.Country.Contains(customerSearchModel.Country));
                }
                else
                {
                    result.ToList();
                }
            }
            return(View(result));
        }
示例#2
0
        public async Task GetBySearchCriteriaAsyncShouldWorkCorrectlyWithPersonalNumber()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var dbContext = new ApplicationDbContext(options);

            var customerRepo = new EfDeletableEntityRepository <Customer>(dbContext);

            var service = new CustomerService(customerRepo);

            var id = await service.CreateAsync <CustomerModel>(new CustomerModel
            {
                FirstName      = "ivan",
                LastName       = "ivanov",
                MiddleName     = "ivanov",
                PersonalNumber = "1234567890",
            });

            var model = new CustomerSearchModel
            {
                PersonalNumber = "1234567890",
            };

            var customers = await service.GetBySearchCriteriaAsync <CustomerModel, CustomerSearchModel>(model);

            Assert.Single(customers);
            Assert.Collection(
                customers,
                x => Assert.Equal("1234567890", x.PersonalNumber));
        }
        public IActionResult TicketCustomerSearch(CustomerSearchModel customerSearchModel)
        {
            var query = from c in _db.Users
                        select c;

            if (customerSearchModel.LastName != null && customerSearchModel.LastName != "")
            {
                query = query.Where(c => c.LastName.Contains(customerSearchModel.LastName));
            }
            if (customerSearchModel.AdvantageNumber != null)
            {
                query = query.Where(c => c.AdvantageNumber == (customerSearchModel.AdvantageNumber));
            }
            query = query.Where(c => c.AdvantageNumber != null);
            List <AppUser> SelectedUsers = query.ToList();

            try
            {
                ViewBag.TicketID = customerSearchModel.TicketID;
            }
            catch
            {
                ViewBag.TicketID = -1;
            }
            return(View("TicketUsersList", SelectedUsers));
        }
示例#4
0
 protected CustomerSearchModel AddNotes(CustomerSearchModel customer, IEnumerable <NoteSearchModel> notes)
 {
     customer.Notes = notes
                      .Where(n => n.CustomerId == customer.Id)
                      .ToArray();
     return(customer);
 }
        public ActionResult SearchResult(CustomerSearchModel customers)
        {
            /* Call the DAL and pass the values as a model back to the View */
            var customerList = customerDAO.SearchForCustomers(customers.Name, customers.SortType);

            return(View(customerList));
        }
示例#6
0
        public IQueryable <Customer> GetCustomers(CustomerSearchModel customerSearchModel)
        {
            var result = db.Customers.AsQueryable();

            if (customerSearchModel != null)
            {
                if (!string.IsNullOrEmpty(customerSearchModel.CustomerID))
                {
                    result = result.Where(x => x.CustomerID.Contains(customerSearchModel.CustomerID));
                }
                if (!string.IsNullOrEmpty(customerSearchModel.ContactName))
                {
                    result = result.Where(x => x.ContactName.Contains(customerSearchModel.ContactName));
                }
                if (!string.IsNullOrEmpty(customerSearchModel.City))
                {
                    result = result.Where(x => x.City.Contains(customerSearchModel.City));
                }
                if (!string.IsNullOrEmpty(customerSearchModel.Country))
                {
                    result = result.Where(x => x.Country.Contains(customerSearchModel.Country));
                }
            }
            return(result);
        }
示例#7
0
    /// <summary>
    /// 高级查询按钮点击时调用此方法
    /// </summary>
    protected async Task ShowSearchDialog()
    {
        if (CustomerSearchModel != null && CustomerSearchTemplate != null)
        {
            await DialogService.ShowSearchDialog(CreateCustomerModelDialog());
        }
        else
        {
            await DialogService.ShowSearchDialog(CreateModelDialog());
        }

        SearchDialogOption <TItem> CreateModelDialog() => new()
        {
            Class              = "modal-dialog-table",
            IsScrolling        = ScrollingDialogContent,
            Title              = SearchModalTitle,
            Model              = SearchModel,
            DialogBodyTemplate = SearchTemplate,
            OnResetSearchClick = ResetSearchClick,
            OnSearchClick      = SearchClick,
            RowType            = SearchDialogRowType,
            ItemsPerRow        = SearchDialogItemsPerRow,
            LabelAlign         = SearchDialogLabelAlign,
            Size                     = SearchDialogSize,
            Items                    = Columns.Where(i => i.Searchable),
            IsDraggable              = SearchDialogIsDraggable,
            ShowMaximizeButton       = SearchDialogShowMaximizeButton,
            ShowUnsetGroupItemsOnTop = ShowUnsetGroupItemsOnTop
        };

        SearchDialogOption <ITableSearchModel> CreateCustomerModelDialog() => new()
        {
            IsScrolling        = ScrollingDialogContent,
            Title              = SearchModalTitle,
            Model              = CustomerSearchModel,
            DialogBodyTemplate = CustomerSearchTemplate,
            OnResetSearchClick = ResetSearchClick,
            OnSearchClick      = SearchClick,
            RowType            = SearchDialogRowType,
            ItemsPerRow        = SearchDialogItemsPerRow,
            Size       = SearchDialogSize,
            LabelAlign = SearchDialogLabelAlign
        };
    }

    /// <summary>
    /// 获得 <see cref="CustomerSearchModel"/> 中过滤条件 <see cref="SearchTemplate"/> 模板中的条件无法获得
    /// </summary>
    /// <returns></returns>
    protected IEnumerable <IFilterAction> GetCustomerSearchs()
    {
        var searchs = new List <IFilterAction>();

        // 处理自定义 SearchModel 条件
        if (CustomerSearchModel != null)
        {
            searchs.AddRange(CustomerSearchModel.GetSearchs());
        }
        return(searchs);
    }
示例#8
0
        /// <summary>
        /// Prepare customer search model
        /// </summary>
        /// <param name="searchModel">Customer search model</param>
        /// <returns>Customer search model</returns>
        public virtual CustomerSearchModel PrepareCustomerSearchModel(CustomerSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            searchModel.UsernamesEnabled     = _customerSettings.UsernamesEnabled;
            searchModel.AvatarEnabled        = _customerSettings.AllowCustomersToUploadAvatars;
            searchModel.DateOfBirthEnabled   = _customerSettings.DateOfBirthEnabled;
            searchModel.CompanyEnabled       = _customerSettings.CompanyEnabled;
            searchModel.PhoneEnabled         = _customerSettings.PhoneEnabled;
            searchModel.ZipPostalCodeEnabled = _customerSettings.ZipPostalCodeEnabled;

            //search registered customers by default
            var registeredRole = _customerService.GetCustomerRoleBySystemName(NopCustomerDefaults.RegisteredRoleName);

            if (registeredRole != null)
            {
                searchModel.SelectedCustomerRoleIds.Add(registeredRole.Id);
            }

            //prepare available customer roles
            _aclSupportedModelFactory.PrepareModelCustomerRoles(searchModel);

            //prepare page parameters
            searchModel.SetGridPageSize();

            return(searchModel);
        }
示例#9
0
        public ActionResult ListSeller(CustomerSearchModel model)
        {
            FillViewBag();

            ViewBag.Customers = CustomerDomain.ListCustomers(model.Name, model.GenderId, model.CityId, model.RegionId, model.LastPurchaseStart, model.LastPuchaseEnd, model.ClassificationId, int.Parse(User.Identity.Name)).Select(c => (CustomerListModel)c);

            return(View("List"));
        }
示例#10
0
        public IPagedList<MSDS_Customer> Search(CustomerSearchModel searchModel)
        {
            var query = _context.MSDS_Customer.Where(x => (string.IsNullOrEmpty(searchModel.KeyWord)
            || x.Name.ToLower().Contains(searchModel.KeyWord.ToLower()))).OrderByDescending(x => x.CreateBy);

            var count = query.Count();
            var result = query.Skip((searchModel.PageIndex - 1) * searchModel.PageSize).Take(searchModel.PageSize).ToList();
            return new PagedList<MSDS_Customer>(result, searchModel.PageIndex, searchModel.PageSize, count);
        }
示例#11
0
        private IQueryable <CustomerDto> GetCustomer(CustomerSearchModel searchModel = null)
        {
            IQueryable <CustomerDto> list = null;

            if (searchModel.IsNull())
            {
                list = _customerService.GetAll();
            }
            else
            {
                var predicate      = PredicateBuilder.True <CustomerDto>();
                var hasOtherFilter = false;

                if (!searchModel.CustomerCode.IsNull())
                {
                    hasOtherFilter = true;
                    predicate      = predicate.And(c => c.CustomerCode.Contains(searchModel.CustomerCode));
                }

                if (!searchModel.FirstName.IsNull())
                {
                    hasOtherFilter = true;
                    predicate      = predicate.And(c => c.FirstName.Contains(searchModel.FirstName));
                }

                if (!searchModel.LastName.IsNull())
                {
                    hasOtherFilter = true;
                    predicate      = predicate.And(c => c.LastName.Contains(searchModel.LastName));
                }

                if (!searchModel.Address.IsNull())
                {
                    hasOtherFilter = true;
                    predicate      = predicate.And(c => c.Address.Contains(searchModel.Address));
                }

                if (!searchModel.isActive.IsNull())
                {
                    hasOtherFilter = true;
                    if (searchModel.isActive == "true")
                    {
                        predicate = predicate.And(a => a.IsActive);
                    }
                    else
                    {
                        predicate = predicate.And(a => !a.IsActive);
                    }
                }

                list = _customerService.GetAll().AsExpandable().Where(predicate);
            }


            return(list);
        }
示例#12
0
        private void SearchOrders(CustomerSearchViewModel model)
        {
            CustomerSearchModel searchModel = new CustomerSearchModel {
                PageIndex = model.PageIndex,
                PageSize  = model.PageSize,
                KeyWord   = model.Keyword
            };

            model.ViewList = _customerService.Search(searchModel);
        }
        public IActionResult TicketCustomerSearch(Int32 TicketID)
        {
            Ticket t = _db.Tickets.Find(TicketID);
            CustomerSearchModel csm = new CustomerSearchModel
            {
                ExistingCustomer = true,
                TicketID         = t.TicketID
            };

            return(View(csm));
        }
示例#14
0
 public List <CustomerModel> Search(CustomerSearchModel searchModel)
 {
     foreach (var func in _search)
     {
         var list = func(searchModel, _customerService);
         if (list != null)
         {
             return(list);
         }
     }
     return(_customerService.GetCustomers());
 }
示例#15
0
        public CustomerSearchModel Post(CustomerSearchModel model)
        {
            IQueryable <CustomerInfo> searchResults;

            searchResults = CustomerInfo.GetBySearchFields(model); // Find matches based on all fields
            if (searchResults.Any() == true)
            {
                model.Results.FillRange(searchResults.ToList());
            }

            return(model);
        }
        public CustomerSearchModel Post(CustomerSearchModel model)
        {
            IQueryable <CustomerInfo> searchResults;

            searchResults = CustomerInfo.GetByAny(model).Take(25);
            if (searchResults.Any() == true)
            {
                model.Results.FillRange(searchResults.ToList());
            }

            return(model);
        }
示例#17
0
        public ActionResult LoadAllData(DTParameters param, CustomerSearchModel model)
        {
            var SearchValue = Request.Form.GetValues("search[value]")[0];
            var parameters  = param.GetSearchParameters();

            parameters.SearchText = SearchValue;

            var listResult = _customerService.GetAll(parameters, model);

            var result = GetListResult <CustomerListModel>(param, listResult);

            return(Json(result));
        }
示例#18
0
        public ActionResult GetCustomersByTagType(CustomerSearchModel searchModel)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("~/Views/Home/Partials/_Customers.cshtml", new CustomersModel()));
            }

            var model = new CustomersModel
            {
                Customers = _customerService.GetByAny(searchModel.Tags, searchModel.GetKeywords())
            };

            return(PartialView("~/Views/Home/Partials/_Customers.cshtml", model));
        }
示例#19
0
        public void Model_CustomerSearch_GetBySearchFields()
        {
            var searchChar  = "i";
            var searchModel = new CustomerSearchModel()
            {
                FirstName = searchChar, LastName = searchChar
            };
            var results = CustomerInfo.GetByAny(searchModel);

            Assert.IsTrue(results.Count() > 0);
            searchModel.Results.FillRange(results);
            Assert.IsTrue(searchModel.FirstName == searchChar && searchModel.LastName == searchChar);
            Assert.IsTrue(searchModel.Results.Count() > 0);
        }
示例#20
0
        public CustomerSearchModel CustomerSearch
            (string CustomerSearchVal, string SearchParam, int PageNumber, int RowCount)
        {
            CustomerSearchModel oReturn = new CustomerSearchModel();

            int oTotalRows;

            oReturn.RelatedCustomer = DocumentManagement.Customer.Controller.Customer.CustomerSearch
                                          (SearchParam, PageNumber, RowCount, out oTotalRows);

            oReturn.TotalRows = oTotalRows;


            return(oReturn);
        }
示例#21
0
        public void Model_CustomerSearch_GetBySearchFields()
        {
            var searchChar  = "i";
            var searchModel = new CustomerSearchModel()
            {
                FirstName = searchChar, LastName = searchChar
            };
            var reader  = new EntityReader <CustomerInfo>();
            var results = reader.GetByWhere(x => x.Key == searchModel.Key || x.FirstName.Contains(searchModel.FirstName) || x.LastName.Contains(searchModel.LastName) || x.BirthDate == searchModel.BirthDate);

            Assert.IsTrue(results.Count() > 0);
            searchModel.Results.FillRange(results);
            Assert.IsTrue(searchModel.FirstName == searchChar && searchModel.LastName == searchChar);
            Assert.IsTrue(searchModel.Results.Count() > 0);
        }
示例#22
0
        public IActionResult Post([FromBody] CustomerModel data)
        {
            var model         = new CustomerSearchModel();
            var reader        = new EntityReader <CustomerInfo>();
            var searchResults = reader.GetByWhere(x => x.Key == data.Key || x.FirstName.Contains(data.FirstName) || x.LastName.Contains(data.LastName) || x.BirthDate == data.BirthDate);
            var form          = Request.ReadFormAsync();

            model.Fill(data);
            if (searchResults.Any())
            {
                model.Results.FillRange(searchResults);
            }

            return(Ok(model));
        }
示例#23
0
        public async Task Customer_Cloud_CustomerSearchGet()
        {
            CustomerSearchModel returnData = new CustomerSearchModel();
            HttpRequestGet <CustomerSearchModel> request;
            string urlRoot = new ConfigurationManagerFull().AppSettingValue("MyWebService");
            string urlFull = TypeExtension.DefaultString;

            // Find customer by first name. -1 for ID does not exist, and empty string Last Name doesnt exist
            urlFull    = String.Format("{0}/{1}/{2}?firstName={3}&lastName={4}", urlRoot, "CustomerSearch", -1, "i", "");
            request    = new HttpRequestGet <CustomerSearchModel>(urlFull);
            returnData = await request.SendAsync();

            Assert.IsTrue(returnData.Results.Count > 0, "Customer did not get.");
            Assert.IsTrue(returnData.FirstName != TypeExtension.DefaultString, "Customer did not get.");
        }
示例#24
0
        public async Task <IActionResult> Search(CustomerSearchModel model, CancellationToken cancellationToken)
        {
            if (!model.Search.HasAnyParameters())
            {
                return(View(model));
            }

            var results = await mediator.Send(model.Search, cancellationToken);

            return(View(new CustomerSearchModel
            {
                Search = model.Search,
                Results = results,
                SearchPerformed = true,
            }));
        }
示例#25
0
        public ActionResult List(CustomerSearchModel customerSearchModel)
        {
            int pageIndex = customerSearchModel.Page ?? 1;

            var data = _customerService.GetCustomerDetailAll().Where(x =>
                                                                     (string.IsNullOrEmpty(customerSearchModel.CustomerName) || x.Name.ToLower().Trim()
                                                                      .Contains(customerSearchModel.CustomerName.Trim().ToLower()))).ToList();
            var customerDetail = _mapper.Map <List <CustomerDetailModel> >(data);

            customerSearchModel.CustomerDetailModelList = customerDetail.OrderByDescending(x => x.Id).ToPagedList(pageIndex, 10);
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_customerList", customerSearchModel));
            }
            return(View(customerSearchModel));
        }
        public CustomerSearchModel Get(string id = "-1", string firstName = "", string lastName = "")
        {
            CustomerSearchModel model = new CustomerSearchModel()
            {
                ID = id.TryParseInt32(), FirstName = firstName, LastName = lastName
            };
            IQueryable <CustomerInfo> searchResults;

            searchResults = CustomerInfo.GetByAny(model).Take(25);
            if (searchResults.Any() == true)
            {
                model.Results.FillRange(searchResults);
            }

            return(model);
        }
示例#27
0
        public void Model_CustomerSearch_Serialization()
        {
            var searchChar     = "i";
            var originalObject = new CustomerSearchModel()
            {
                FirstName = searchChar, LastName = searchChar
            };
            var resultObject = new CustomerSearchModel();
            var resultString = Defaults.String;
            var serializer   = new JsonSerializer <CustomerSearchModel>();

            resultString = serializer.Serialize(originalObject);
            Assert.IsTrue(resultString != Defaults.String);
            resultObject = serializer.Deserialize(resultString);
            Assert.IsTrue(resultObject.FirstName == searchChar);
            Assert.IsTrue(resultObject.LastName == searchChar);
        }
示例#28
0
        public CustomerSearchModel Get(string id, string firstName, string lastName)
        {
            Int32 idStrong            = id.TryParseInt32();
            CustomerSearchModel model = new CustomerSearchModel()
            {
                ID = idStrong, FirstName = firstName, LastName = lastName
            };
            IQueryable <CustomerInfo> searchResults;

            searchResults = CustomerInfo.GetBySearchFields(model); // Find matches based on all fields
            if (searchResults.Any() == true)
            {
                model.Results.FillRange(searchResults);
            }

            return(model);
        }
        public IActionResult CustomerSearch(CustomerSearchModel customerSearchModel)
        {
            var query = from c in _db.Users
                        select c;

            if (customerSearchModel.LastName != null && customerSearchModel.LastName != "")
            {
                query = query.Where(c => c.LastName.Contains(customerSearchModel.LastName));
            }
            if (customerSearchModel.AdvantageNumber != null && customerSearchModel.AdvantageNumber != null)
            {
                query = query.Where(c => c.AdvantageNumber == (customerSearchModel.AdvantageNumber));
            }
            List <AppUser> SelectedUsers = query.Include(c => c.UserID).ToList();

            return(View(SelectedUsers));
        }
示例#30
0
        public IActionResult Get(string key = "-1", string firstName = "", string lastName = "")
        {
            var model = new CustomerSearchModel()
            {
                Id = key.TryParseInt32(), Key = key.TryParseGuid(), FirstName = firstName, LastName = lastName
            };
            var reader        = new EntityReader <CustomerInfo>();
            var searchResults = reader.GetByWhere(x => x.Key == model.Key || x.FirstName.Contains(model.FirstName) || x.LastName.Contains(model.LastName) || x.BirthDate == model.BirthDate);


            if (searchResults.Any())
            {
                model.Results.FillRange(searchResults);
            }

            return(Ok(model));
        }