public async Task <IActionResult> PutCategory(int id, InCategoryDTO inCategoryDTO) { var category = _mapper.Map <Category>(inCategoryDTO); if (id != category.Id) { return(BadRequest()); } _context.Entry(category).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <OutCategoryDTO> > PostCategory(InCategoryDTO inCategoryDTO) { var category = _mapper.Map <Category>(inCategoryDTO); _context.Categories.Add(category); await _context.SaveChangesAsync(); return(CreatedAtAction("GetCategory", new { id = category.Id }, _mapper.Map <OutCategoryDTO>(category))); }