Пример #1
0
        public async Task AddCategory(CategoryViewModel model, HttpPostedFileBase file)
        {
            string _path;

            if (file.ContentLength > 0)
            {
                model.IconFileName = Path.GetFileName(file.FileName);
                _path = Path.Combine(HostingEnvironment.MapPath("~/Content/Icons"), model.IconFileName);
                file.SaveAs(_path);
            }

            model.CategoryId = Guid.NewGuid();

            var category = _mapper.Map <CategoryViewModel, Category>(model);

            await _categoryRepo.AddCategoryAsync(category);
        }
        public async Task AddCategoryAsync(CategoryCreateDto categoryCreateDto)
        {
            var category = _mapper.Map <Category>(categoryCreateDto);

            await _repo.AddCategoryAsync(category);
        }