Exemplo n.º 1
0
        public async Task<DtoCategoryGet> PostCategory([FromBody] DtoCategoryPost dtoCategory)
        {
            var item = await queryProcessor.Create(dtoCategory);

            var categoryModel = autoMapper.Map<DtoCategoryGet>(item);

            return categoryModel;
        }
Exemplo n.º 2
0
        public async Task <Category> Create(DtoCategoryPost dtoCategoryPost)
        {
            var category = new Category()
            {
                CategoryName = dtoCategoryPost.CategoryName,
                Description  = dtoCategoryPost.Description,
                Picture      = dtoCategoryPost.Picture,
            };

            unitOfWork.Add(category);

            await unitOfWork.CommitAsync();

            var newCategory = await unitOfWork.Query <Category>().OrderBy(x => x.CategoryID).LastAsync();

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

            return(newCategory);
        }