/// <summary> /// Showing UI based on passed search Text /// </summary> /// <param name="search"></param> /// <param name="searchText"></param> /// <returns></returns> private ActionResult ShowCustomerPage(SearchTextType search, string searchText) { var bucketSummary = _service.GetBucketSummary(search, searchText); var query = from bucket in Map(bucketSummary) group bucket by bucket.BucketStatus into g orderby g.Key select new { Status = g.Key, // Inactive customers are displayed last Buckets = (from item in g orderby item.DcCancelDateRange.From, item.IsCustomerActive ? 0 : 1 select item).ToArray() }; var model = new CustomerViewModel { IsCustomerFilterApplied = search == SearchTextType.CustomerId, IsUserNameFilterApplied = search == SearchTextType.UserName }; if (model.IsUserNameFilterApplied) { model.SearchUserName = searchText; } if (model.IsCustomerFilterApplied) { model.SearchCustomerId = searchText; } foreach (var item in query) { model.BucketsByStatus.Add(item.Status, item.Buckets); } model.ImportedOrders = (from item in _service.GetImportedOrderSummary(search, searchText) orderby item.MinDcCancelDate, item.DollarsOrdered descending select new ImportedOrderSummaryModel { CustomerId = item.CustomerId, CustomerName = item.CustonerName, IsCustomerActive = item.IsActiveCustomer, PickslipCount = item.PickslipCount, PiecesOrdered = item.PiecesOrdered, DollarsOrdered = (double)item.DollarsOrdered, DcCancelDateRange = new DateRange { From = item.MinDcCancelDate, To = item.MaxDcCancelDate }, ImportDateRange = new DateRange { From = item.MinPickslipImportDate, To = item.MaxPickslipImportDate }, InternationalFlag = item.InternationalFlag }).ToArray(); return(View(Views.Customer, model)); }
public IEnumerable <ImportedOrderSummary> GetImportedOrderSummary(SearchTextType filterType, string filterText) { switch (filterType) { case SearchTextType.Unknown: return(_repos.GetImportedOrderSummary(null)); case SearchTextType.BucketId: // We don't expect to show a summary for a single bucket throw new NotSupportedException(); case SearchTextType.CustomerId: return(_repos.GetImportedOrderSummary(filterText)); case SearchTextType.UserName: return(Enumerable.Empty <ImportedOrderSummary>()); default: throw new NotImplementedException(); } }