Beispiel #1
0
        public async Task <QuoteRequestSearchResult> SearchAsync(QuoteRequestSearchCriteria searchCriteria)
        {
            var requestUrl = CreateRequestUri(RelativePaths.QuoteRequests, searchCriteria.GetQueryString());

            var response = await GetAsync <QuoteRequestSearchResult>(requestUrl).ConfigureAwait(false);

            return(response);
        }
Beispiel #2
0
        public async Task<QuoteRequestSearchResult> SearchAsync(QuoteRequestSearchCriteria searchCriteria)
        {
            var requestUrl = CreateRequestUri(RelativePaths.QuoteRequests, searchCriteria.GetQueryString());

            var response = await GetAsync<QuoteRequestSearchResult>(requestUrl).ConfigureAwait(false);

            return response;
        }
Beispiel #3
0
        public GenericSearchResult <QuoteRequest> Search(QuoteRequestSearchCriteria criteria)
        {
            var retVal = new GenericSearchResult <QuoteRequest>();

            using (var repository = _repositoryFactory())
            {
                var query = repository.QuoteRequests;
                if (criteria.CustomerId != null)
                {
                    query = query.Where(x => x.CustomerId == criteria.CustomerId);
                }
                if (criteria.StoreId != null)
                {
                    query = query.Where(x => x.StoreId == criteria.StoreId);
                }

                if (criteria.Number != null)
                {
                    query = query.Where(x => x.Number == criteria.Number);
                }
                else if (criteria.Keyword != null)
                {
                    query = query.Where(x => x.Number.Contains(criteria.Keyword));
                }

                if (criteria.Tag != null)
                {
                    query = query.Where(x => x.Tag == criteria.Tag);
                }
                if (criteria.Status != null)
                {
                    query = query.Where(x => x.Status == criteria.Status);
                }
                var sortInfos = criteria.SortInfos;
                if (sortInfos.IsNullOrEmpty())
                {
                    sortInfos = new[] { new SortInfo {
                                            SortColumn = ReflectionUtility.GetPropertyName <QuoteRequest>(x => x.CreatedDate), SortDirection = SortDirection.Descending
                                        } };
                }
                query = query.OrderBySortInfos(sortInfos);

                retVal.TotalCount = query.Count();

                var ids = query.Select(x => x.Id).Skip(criteria.Skip).Take(criteria.Take).ToArray();

                var quotes = GetByIds(ids);
                retVal.Results = quotes.AsQueryable <QuoteRequest>().OrderBySortInfos(sortInfos).ToList();
            }
            return(retVal);
        }
Beispiel #4
0
        public async Task <ActionResult> Quotes(int?p)
        {
            var searchCriteria = new QuoteRequestSearchCriteria
            {
                CustomerId = Context.CustomerId,
                Skip       = ((p ?? 1) - 1) * 20,
                StoreId    = Context.StoreId,
                Tag        = null,
                Take       = 20
            };

            Context.Customer.Quotes = await QuoteService.SearchAsync(searchCriteria);

            return(View("customers/quotes"));
        }
        public QuoteRequestSearchResult Search(QuoteRequestSearchCriteria criteria)
        {
            QuoteRequestSearchResult retVal = null;

            using (var repository = _repositoryFactory())
            {
                var query = repository.QuoteRequests;
                if (criteria.CustomerId != null)
                {
                    query = query.Where(x => x.CustomerId == criteria.CustomerId);
                }
                if (criteria.StoreId != null)
                {
                    query = query.Where(x => x.StoreId == criteria.StoreId);
                }

                if (criteria.Number != null)
                {
                    query = query.Where(x => x.Number == criteria.Number);
                }
                else if (criteria.Keyword != null)
                {
                    query = query.Where(x => x.Number.Contains(criteria.Keyword));
                }

                if (criteria.Tag != null)
                {
                    query = query.Where(x => x.Tag == criteria.Tag);
                }
                if (criteria.Status != null)
                {
                    query = query.Where(x => x.Status == criteria.Status);
                }
                var ids = query.OrderByDescending(x => x.CreatedDate)
                          .Skip(criteria.Start)
                          .Take(criteria.Count)
                          .Select(x => x.Id)
                          .ToArray();

                retVal = new QuoteRequestSearchResult
                {
                    TotalCount    = query.Count(),
                    QuoteRequests = GetByIds(ids).ToList()
                };
            }
            return(retVal);
        }
Beispiel #6
0
        public static string GetQueryString(this QuoteRequestSearchCriteria criteria)
        {
            var parts = new List <string>();

            parts.Add("count=" + criteria.Count);

            if (!string.IsNullOrEmpty(criteria.CustomerId))
            {
                parts.Add("customer=" + criteria.CustomerId);
            }

            if (criteria.EndDate.HasValue)
            {
                parts.Add("endDate=" + criteria.EndDate.Value);
            }

            if (!string.IsNullOrEmpty(criteria.Keyword))
            {
                parts.Add("q=" + criteria.Keyword);
            }

            parts.Add("start=" + criteria.Start);

            if (criteria.StartDate.HasValue)
            {
                parts.Add("startDate=" + criteria.StartDate.Value);
            }

            if (!string.IsNullOrEmpty(criteria.Status))
            {
                parts.Add("status=" + criteria.Status);
            }

            if (!string.IsNullOrEmpty(criteria.StoreId))
            {
                parts.Add("site=" + criteria.StoreId);
            }

            if (!string.IsNullOrEmpty(criteria.Tag))
            {
                parts.Add("tag=" + criteria.Tag);
            }

            return(string.Join("&", parts));
        }
        public async Task<ItemCollection<QuoteRequest>> SearchAsync(QuoteRequestSearchCriteria criteria)
        {
            var searchCriteria = new DataContracts.Quotes.QuoteRequestSearchCriteria
            {
                Count = criteria.Take,
                CustomerId = criteria.CustomerId,
                Start = criteria.Skip,
                Status = criteria.Status,
                StoreId = criteria.StoreId,
                Tag = criteria.Tag
            };

            var quotesResponse = await _quoteClient.SearchAsync(searchCriteria);

            ItemCollection<QuoteRequest> quoteRequests = null;

            if (quotesResponse != null)
            {
                quoteRequests = new ItemCollection<QuoteRequest>(quotesResponse.QuoteRequests.Select(qr => qr.ToViewModel()));
            }

            return quoteRequests;
        }
        public async Task <ItemCollection <QuoteRequest> > SearchAsync(QuoteRequestSearchCriteria criteria)
        {
            var searchCriteria = new DataContracts.Quotes.QuoteRequestSearchCriteria
            {
                Count      = criteria.Take,
                CustomerId = criteria.CustomerId,
                Start      = criteria.Skip,
                Status     = criteria.Status,
                StoreId    = criteria.StoreId,
                Tag        = criteria.Tag
            };

            var quotesResponse = await _quoteClient.SearchAsync(searchCriteria);

            ItemCollection <QuoteRequest> quoteRequests = null;

            if (quotesResponse != null)
            {
                quoteRequests = new ItemCollection <QuoteRequest>(quotesResponse.QuoteRequests.Select(qr => qr.ToViewModel()));
            }

            return(quoteRequests);
        }
        public async Task <QuoteRequestSearchResult> SearchAsync(QuoteRequestSearchCriteria criteria)
        {
            var result   = new QuoteRequestSearchResult();
            var cacheKey = CacheKey.With(GetType(), nameof(SearchAsync), criteria.GetCacheKey());

            return(await _platformMemoryCache.GetOrCreateExclusiveAsync(cacheKey, async cacheEntry =>
            {
                cacheEntry.AddExpirationToken(QuoteSearchCacheRegion.CreateChangeToken());
                using (var repository = _repositoryFactory())
                {
                    var query = repository.QuoteRequests;
                    if (criteria.CustomerId != null)
                    {
                        query = query.Where(x => x.CustomerId == criteria.CustomerId);
                    }
                    if (criteria.StoreId != null)
                    {
                        query = query.Where(x => x.StoreId == criteria.StoreId);
                    }

                    if (criteria.Number != null)
                    {
                        query = query.Where(x => x.Number == criteria.Number);
                    }
                    else if (criteria.Keyword != null)
                    {
                        query = query.Where(x => x.Number.Contains(criteria.Keyword) ||
                                            (x.CustomerName != null && x.CustomerName.Contains(criteria.Keyword)) ||
                                            (x.Status != null && x.Status.Contains(criteria.Keyword)));
                    }

                    if (criteria.Tag != null)
                    {
                        query = query.Where(x => x.Tag == criteria.Tag);
                    }
                    if (criteria.Status != null)
                    {
                        query = query.Where(x => x.Status == criteria.Status);
                    }
                    var sortInfos = criteria.SortInfos;
                    if (sortInfos.IsNullOrEmpty())
                    {
                        sortInfos = new[] { new SortInfo {
                                                SortColumn = ReflectionUtility.GetPropertyName <QuoteRequest>(x => x.CreatedDate), SortDirection = SortDirection.Descending
                                            } };
                    }

                    result.TotalCount = await query.CountAsync();
                    if (criteria.Take > 0)
                    {
                        var ids = await query.OrderBySortInfos(sortInfos).ThenBy(x => x.Id)
                                  .Select(x => x.Id)
                                  .Skip(criteria.Skip).Take(criteria.Take)
                                  .ToArrayAsync();

                        result.Results = (await GetByIdsAsync(ids)).OrderBy(x => Array.IndexOf(ids, x.Id)).ToList();
                    }
                }
                return result;
            }));
        }
        public async Task <ActionResult <QuoteRequestSearchResult> > Search([FromBody] QuoteRequestSearchCriteria criteria)
        {
            var retVal = await _quoteRequestService.SearchAsync(criteria);

            return(Ok(retVal));
        }
        public async Task<ActionResult> Quotes(int? p)
        {
            var searchCriteria = new QuoteRequestSearchCriteria
            {
                CustomerId = Context.CustomerId,
                Skip = ((p ?? 1) - 1) * 20,
                StoreId = Context.StoreId,
                Tag = null,
                Take = 20
            };

            Context.Customer.Quotes = await QuoteService.SearchAsync(searchCriteria);

            return View("customers/quotes");
        }