Exemple #1
0
        public async Task <Category> Update(int id, DtoCategoryPut dtoCategoryPut)
        {
            var category = await unitOfWork.Query <Category>().FirstAsync(c => c.CategoryID == id);

            if (category == null)
            {
                throw new KeyNotFoundException();
            }

            category.Description = dtoCategoryPut.Description;
            category.Picture     = dtoCategoryPut.Picture;

            unitOfWork.Commit();

            BackgroundJob.Enqueue(() => RefreshCache());

            return(category);
        }
 public async Task<DtoCategoryGet> PutCategory(int id, [FromBody] DtoCategoryPut dtoCategory)
 {
     var item = await queryProcessor.Update(id, dtoCategory);
     var model = autoMapper.Map<DtoCategoryGet>(item);
     return model;
 }