コード例 #1
0
        public async Task <Category> CreateCategory(CreateCategoryViewModel createcategoryViewModel, ClaimsPrincipal claimsPrincipal)
        {
            Category category = createcategoryViewModel.Category;

            category = await postService.AddCategory(category);

            string webRootPath = webHostEnvironment.WebRootPath;
            string pathToImage = $@"{webRootPath}\UserFiles\Categories\{category.ID}\HeaderImage.jpg";

            EnsureFolder(pathToImage);
            using (var fileStream = new FileStream(pathToImage, FileMode.Create))
            {
                await createcategoryViewModel.BlogHeaderImage.CopyToAsync(fileStream);
            }
            logger.LogInformation("PostBusinessManager: CreateCategory  OK.");
            return(category);
        }