示例#1
0
        public async Task <CategoryDto> UpdateAsync(int id, CategoryUpdateDto categoryUpdateDto)
        {
            var categoryE = await Repository.GetAsync(id) ?? throw new EntityNotFoundException();

            if (!string.IsNullOrWhiteSpace(categoryUpdateDto.ThumbnailBase64))
            {
                var categoryThumbnail = await ThumbnailManager.SaveAsync(categoryUpdateDto.ThumbnailBase64);

                await ThumbnailManager.DeleteAsync(categoryE.CategoryThumbnail);

                categoryE.CategoryThumbnail = categoryThumbnail;
            }

            ObjectMapper.Map(categoryUpdateDto, categoryE);
            await Repository.UpdateAsync(categoryE);

            return(ObjectMapper.Map <CategoryEntity, CategoryDto>(categoryE));
        }