Esempio n. 1
0
        public async Task <ActionResult> UploadImage(CategoryViewModel category)
        {
            await _dictionaryService.CategoryUpdateAsync(_mapper.Map <Category>(category));

            await _cacheImage.ClearAsync();

            return(RedirectToAction("Image", new { id = category.Id }));
        }
Esempio n. 2
0
        public async Task <ActionResult> UpdateImage(int id, IFormFile image)
        {
            if (image == null)
            {
                return(NotFound());
            }

            var categories = await _dictionaryService.GetCategoriesAsync();

            var category = _mapper.Map <CategoryViewModel>(
                categories.FirstOrDefault(c => c.Id == id));

            if (category == null)
            {
                return(NotFound());
            }

            category.ImageUpload = image;

            await _dictionaryService.CategoryUpdateAsync(_mapper.Map <Category>(category));

            return(NoContent());
        }