public async Task <IActionResult> Edit(int id, [FromForm] EditCategoryInput input)
        {
            var absolutePath = Path.Combine(_webHostEnvironment.WebRootPath, Category.IMAGE_PATH);
            await _categoryService.Edit(id, input, absolutePath);

            await _dbContext.SaveChangesAsync();

            return(Ok());
        }
Exemplo n.º 2
0
        /// <summary>
        /// 新增分类
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <ServiceResult> InsertCategoryAsync(EditCategoryInput input)
        {
            var result = new ServiceResult();

            var category = ObjectMapper.Map <EditCategoryInput, Category>(input);
            await _categoryRepository.InsertAsync(category);

            result.IsSuccess(ResponseText.INSERT_SUCCESS);
            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 新增分类
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <ServiceResult> InsertCategoryAsync(EditCategoryInput input)
        {
            var result = new ServiceResult();

            var category = ObjectMapper.Map <EditCategoryInput, Category>(input);
            await _categoryRepository.InsertAsync(category);

            // 执行清除缓存操作
            await _blogCacheService.RemoveAsync(CachePrefix.Blog_Category);

            result.IsSuccess(ResponseText.INSERT_SUCCESS);
            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 更新分类
        /// </summary>
        /// <param name="id"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <ServiceResult> UpdateCategoryAsync(int id, EditCategoryInput input)
        {
            var result   = new ServiceResult();
            var category = await _categoryRepository.GetAsync(id);

            ObjectMapper.Map(input, category);
            await _categoryRepository.UpdateAsync(category);

            await _blogCacheService.RemoveAsync(CachePrefix.Blog_FriendLink);

            result.IsSuccess(ResponseText.UPDATE_SUCCESS);
            return(result);
        }
Exemplo n.º 5
0
        public async Task Edit(int id, EditCategoryInput input, string imageFolderPath)
        {
            var category = await Get(id);

            if (input.Image != null)
            {
                category.Image = await Upload.UploadImageAsync(input.Image, imageFolderPath);
            }
            category.Name        = input.Name;
            category.PriceUnit   = input.PriceUnit;
            category.Status      = input.Status;
            category.Description = input.Description;
            category.Url         = input.Url;
        }
Exemplo n.º 6
0
        /// <summary>
        /// 更新分类
        /// </summary>
        /// <param name="id"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <ServiceResult> UpdateCategoryAsync(int id, EditCategoryInput input)
        {
            var result = new ServiceResult();

            var category = await _categoryRepository.GetAsync(id);

            category.CategoryName = input.CategoryName;
            category.DisplayName  = input.DisplayName;

            await _categoryRepository.UpdateAsync(category);

            result.IsSuccess(ResponseText.UPDATE_SUCCESS);
            return(result);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 新增分类
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <ServiceResult> InsertCategoryAsync(EditCategoryInput input)
        {
            var result = new ServiceResult();

            var category = ObjectMapper.Map <EditCategoryInput, Category>(input);
            await _categoryRepository.InsertAsync(category);

            await _distributedEventBus.PublishAsync(new CachingRemoveEventData
            {
                Key = CachePrefix.Blog_Category
            });

            result.IsSuccess(ResponseText.INSERT_SUCCESS);
            return(result);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 更新分类
        /// </summary>
        /// <param name="id"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <ServiceResult> UpdateCategoryAsync(int id, EditCategoryInput input)
        {
            var result = new ServiceResult();

            var category = await _categoryRepository.GetAsync(id);

            category.CategoryName = input.CategoryName;
            category.DisplayName  = input.DisplayName;

            await _categoryRepository.UpdateAsync(category);

            await _distributedEventBus.PublishAsync(new CachingRemoveEventData
            {
                Key = CachePrefix.Blog_Category
            });

            result.IsSuccess(ResponseText.UPDATE_SUCCESS);
            return(result);
        }
Exemplo n.º 9
0
 public async Task <ServiceResult> UpdateCategoryAsync([Required] int id, [FromBody] EditCategoryInput input)
 {
     return(await _blogService.UpdateCategoryAsync(id, input));
 }
Exemplo n.º 10
0
 public async Task <ServiceResult> InsertCategoryAsync([FromBody] EditCategoryInput input)
 {
     return(await _blogService.InsertCategoryAsync(input));
 }
Exemplo n.º 11
0
 public async Task <ServiceResult> UpdateCategoryAsync(int id, EditCategoryInput input)
 {
     return(await _blogService.UpdateCategoryAsync(id, input));
 }