/// <summary> /// Showing UI based on passed search Text /// </summary> /// <param name="search"></param> /// <param name="searchText"></param> /// <returns></returns> private ActionResult ShowHomePage(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 IndexViewModel { 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.Customer.CustomerId, CustomerName = item.Customer.Name, IsCustomerActive = item.Customer.IsActive, 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.Index, model)); }
public virtual ActionResult Index() { var customerList = _service.GetImportedOrderSummary(SearchTextType.Unknown, null); var model = new IndexViewModel { ImportedOrders = customerList.Select(p => new CustomerListModel { CustomerId = p.CustomerId, CustomerName = p.CustonerName, IsCustomerActive = p.IsActiveCustomer, PickslipCount = p.PickslipCount, ImportDateRange = new DateRange { From = p.MinPickslipImportDate, To = p.MaxPickslipImportDate }, InternationalFlag = p.InternationalFlag }).ToList(), RecentBuckets = _service.GetRecentCreatedBucket(20).Select(p => new IndexBucketModel(p)).ToList(), ExpediteBuckets = _service.GetBucketToExpedite(20).Select(p => new IndexBucketModel(p)).ToList() }; return(View(Views.Index, model)); }