Пример #1
0
        private void AddUserCategories(IList <CategoryViewModel> levels, User user)
        {
            if (levels == null)
            {
                return;
            }

            foreach (CategoryViewModel item in levels)
            {
                CategoryFavouriteLevel level = _categoryFavouriteLevelService.FindById(item.LevelId);
                if (level == null)
                {
                    continue;
                }

                foreach (Guid categoryId in item.SelectedCatagories)
                {
                    Category category = _categoryService.FindById(categoryId);
                    if (category == null)
                    {
                        continue;
                    }

                    var userCategory = new UserCategory {
                        User     = user,
                        Category = category,
                        CategoryFavouriteLevel = level
                    };

                    _userCategoryService.Create(userCategory);
                }
            }
        }
Пример #2
0
        public void service_must_return_expected_favourite_level_by_id()
        {
            var favouriteLevelService = ServiceLocator.Current.GetInstance <ICategoryFavouriteLevelService>();
            var favouriteCategory     = favouriteLevelService.FindAll().FirstOrDefault();

            CategoryFavouriteLevel levelFromDb = favouriteLevelService.FindById(favouriteCategory.Id);

            Assert.AreEqual(favouriteCategory.Id, levelFromDb.Id, "Service must return expected favourite category by id");
        }