public async Task <ActionResult <V1DTO.Category> > PostCategory(V1DTO.Category category) { var bllEntity = _mapper.Map(category); _bll.Categories.Add(bllEntity); await _bll.SaveChangesAsync(); category.Id = bllEntity.Id; return(CreatedAtAction(nameof(GetCategory), new { id = category.Id, version = HttpContext.GetRequestedApiVersion()?.ToString() ?? "0" }, category)); }
public async Task <IActionResult> PutCategory(Guid id, V1DTO.Category category) { if (id != category.Id) { return(BadRequest(new V1DTO.MessageDTO("Id and Category.Id do not match"))); } if (!await _bll.Addresses.ExistsAsync(category.Id)) { return(NotFound(new V1DTO.MessageDTO($"Current user does not have session with this id {id}"))); } await _bll.Categories.UpdateAsync(_mapper.Map(category)); await _bll.SaveChangesAsync(); return(NoContent()); }