Courses.Buisness.CategoryService.Add C# (CSharp) Method

Add() public method

Добавление категории в репозиторий
public Add ( CategoryViewModel categoryView ) : void
categoryView CategoryViewModel
return void
        public void Add(CategoryViewModel categoryView)
        {
            categoryView.CreatedDate = categoryView.UpdatedDate = DateTime.Now;
            Category category = Convert(categoryView);
            if (categoryView.ParentCategoryId == 0)
                category.ParentCategory = null;
            else
            {
                category.ParentCategory = categoryRepository.Get(categoryView.ParentCategoryId.Value);
            }
            categoryRepository.Add(category);
        }

Usage Example

Ejemplo n.º 1
0
 public void GetByIDTest()
 {
     ICategoryService _categoryService = new CategoryService(new CategoryRepository(), new CategoryFilterFactory());
     CategoryViewModel _categoryViewModel = GetCategoryViewModel();
     _categoryService.Add(_categoryViewModel);
     Assert.IsNotNull(_categoryService.GetByID(1));
 }
All Usage Examples Of Courses.Buisness.CategoryService::Add