public async Task <IActionResult> Put(int id, [FromBody] BlogDTO blogDTO) { if (id != blogDTO.Id) { return(BadRequest()); } Blog blog = BlogMapper.mapSingleToBlog(blogDTO); try { await _blogService.UpdateAsync(blog); } catch (DBConcurrencyException e) { if (await _blogService.GetByIdAsync(id) == null) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Post([FromBody] BlogDTO blogDTO) { Blog blog = BlogMapper.mapSingleToBlog(blogDTO); await _blogService.AddAsync(blog); return(CreatedAtAction(nameof(Get), new { id = blog.Id }, blogDTO)); }