예제 #1
0
        public async Task <SearchResult <UserModel> > SearchCourier([FromQuery] ManagerSearchModel model)
        {
            var managers = await _userService.SearchCouriers(model.SearchString);

            return(new SearchResult <UserModel>(
                       managers.Count(),
                       SortManager.SortManagers(managers, model.Field, model.Direction, model.Count, model.Offset)));
        }
예제 #2
0
        public ActionResult ManagerSearch(ManagerSearchModel model)
        {
            var quotes = db.Quotes.Where(q => q.Submitted).ToList();

            if (model.Id != null)
            {
                quotes = quotes.Where(q => q.Id == model.Id).ToList();
            }
            if (!String.IsNullOrEmpty(model.CustomerFirstName))
            {
                quotes = quotes.Where(q => q.CustomerFirstName.StartsWith(model.CustomerFirstName)).ToList();
            }
            if (!String.IsNullOrEmpty(model.CustomerLastName))
            {
                quotes = quotes.Where(q => q.CustomerLastName.StartsWith(model.CustomerLastName)).ToList();
            }
            if (!String.IsNullOrEmpty(model.PhoneNumber))
            {
                quotes = quotes.Where(q => q.CustomerPhone.Contains(model.PhoneNumber)).ToList();
            }
            if (!String.IsNullOrEmpty(model.State))
            {
                quotes = quotes.Where(q => q.State == model.State).ToList();
            }
            if (model.Skip != null && model.Take != null)
            {
                //return Json(quotes.Skip(model.Skip.Value).Take(model.Take.Value));
                return(Json(quotes.Select(q => new
                {
                    Id = q.Id,
                    AIAUserId = q.AIAUserId,
                    Price = q.Price,
                    Submitted = q.Submitted,
                    SubmissionTime = q.SubmissionTime,
                    State = q.State,
                    MovingViolation = q.MovingViolation,
                    PreviousCarrier = q.PreviousCarrier,
                    ClaimInLastFive = q.ClaimInLastFive,
                    ForceMultiDiscount = q.ForceMultiDiscount,
                    CustomerFirstName = q.CustomerFirstName,
                    CustomerLastName = q.CustomerLastName,
                    CustomerAddress = q.CustomerAddress,
                    CustomerPhone = q.CustomerPhone,
                    CustomerSsn = q.CustomerSsn,
                    CustomerDob = q.CustomerDob
                })
                            .Skip(model.Skip.Value).Take(model.Take.Value)));
            }
            if (model.Skip != null && model.Take == null)
            {
                //return Json(quotes.Skip(model.Skip.Value));
                return(Json(quotes.Select(q => new
                {
                    Id = q.Id,
                    AIAUserId = q.AIAUserId,
                    Price = q.Price,
                    Submitted = q.Submitted,
                    SubmissionTime = q.SubmissionTime,
                    State = q.State,
                    MovingViolation = q.MovingViolation,
                    PreviousCarrier = q.PreviousCarrier,
                    ClaimInLastFive = q.ClaimInLastFive,
                    ForceMultiDiscount = q.ForceMultiDiscount,
                    CustomerFirstName = q.CustomerFirstName,
                    CustomerLastName = q.CustomerLastName,
                    CustomerAddress = q.CustomerAddress,
                    CustomerPhone = q.CustomerPhone,
                    CustomerSsn = q.CustomerSsn,
                    CustomerDob = q.CustomerDob
                }).Skip(model.Skip.Value)));
            }
            if (model.Skip == null && model.Take != null)
            {
                //return Json(quotes.Take(model.Take.Value));
                return(Json(quotes.Select(q => new
                {
                    Id = q.Id,
                    AIAUserId = q.AIAUserId,
                    Price = q.Price,
                    Submitted = q.Submitted,
                    SubmissionTime = q.SubmissionTime,
                    State = q.State,
                    MovingViolation = q.MovingViolation,
                    PreviousCarrier = q.PreviousCarrier,
                    ClaimInLastFive = q.ClaimInLastFive,
                    ForceMultiDiscount = q.ForceMultiDiscount,
                    CustomerFirstName = q.CustomerFirstName,
                    CustomerLastName = q.CustomerLastName,
                    CustomerAddress = q.CustomerAddress,
                    CustomerPhone = q.CustomerPhone,
                    CustomerSsn = q.CustomerSsn,
                    CustomerDob = q.CustomerDob
                })
                            .Take(model.Take.Value)));
            }
            else
            {
                //return Json(quotes);
                return(Json(quotes.Select(q => new
                {
                    Id = q.Id,
                    AIAUserId = q.AIAUserId,
                    Price = q.Price,
                    Submitted = q.Submitted,
                    SubmissionTime = q.SubmissionTime,
                    State = q.State,
                    MovingViolation = q.MovingViolation,
                    PreviousCarrier = q.PreviousCarrier,
                    ClaimInLastFive = q.ClaimInLastFive,
                    ForceMultiDiscount = q.ForceMultiDiscount,
                    CustomerFirstName = q.CustomerFirstName,
                    CustomerLastName = q.CustomerLastName,
                    CustomerAddress = q.CustomerAddress,
                    CustomerPhone = q.CustomerPhone,
                    CustomerSsn = q.CustomerSsn,
                    CustomerDob = q.CustomerDob
                })));
            }
        }