예제 #1
0
        public IEnumerable<StuffItemViewModel> Build(StuffParameters stuffParameters)
        {
            using (_profilerWrapper.Step("Build Stuff View Model List"))
            {
                var allItems = _stuffItemRepository.GetAll();

                using (_profilerWrapper.Step("Order stuff items by name"))
                {
                    allItems = allItems.OrderBy(si => si.Name);
                }

                using (_profilerWrapper.Step("Filter Stuff View Model List"))
                {
                    if (stuffParameters.Categories.Any())
                    {
                        allItems = FilterItemsByCategory(stuffParameters.Categories, allItems);
                    }

                    if(!string.IsNullOrWhiteSpace(stuffParameters.Name))
                    {
                        allItems = FilterItemsByName(stuffParameters.Name, allItems);
                    }

                    if(!string.IsNullOrWhiteSpace(stuffParameters.ViewId))
                    {
                        allItems = GetView(stuffParameters.ViewId).Filter(allItems);
                    }

                    return allItems.Select(item => new StuffItemViewModel(item));
                }
            }
        }
예제 #2
0
 public StuffViewModel BuildViewModel(StuffParameters stuffParameters)
 {
     using (_profilerWrapper.Step("Build Stuff View Model"))
     {
         return new StuffViewModel(
             GetStuffCategoryViewModels(),
             GetStuffViewViewModels(stuffParameters.ViewId),
             stuffParameters.Name);
     }
 }