public async Task CreateCategoryAsync(CategoryCreateDtoModel categoryCreateDto) { if (categoryCreateDto.ImageAddress == null) { categoryCreateDto.ImageAddress = GlobalConstants.ImageAddress; } var category = CategoryServiceCreateMapper.Map(categoryCreateDto); var allModels = this.models.All().ToList(); for (int i = 0; i < allModels.Count(); i++) { var modelCategory = new ModelCategories { Category = category, Model = allModels[i], }; await this.modelCategories.AddAsync(modelCategory); } await this.categories.AddAsync(category); await this.categories.SaveChangesAsync(); }
public static Category Map(CategoryCreateDtoModel categoryCreateDto) { Category category = new Category { Name = categoryCreateDto.CategoryName, ImageAddress = categoryCreateDto.ImageAddress, }; return(category); }
public static CategoryCreateDtoModel Map(CategoryWithImageViewModel categoryModel) { var category = new CategoryCreateDtoModel { CategoryName = categoryModel.Name, ImageAddress = categoryModel.ImageAddress, }; return(category); }