public async Task <IActionResult> Post(int apiVersion, [CustomizeValidator] CustomerDto dto) { var item = dto.Map(); _dbContext.Set <Customer>().Add(item); await _dbContext.SaveChangesAsync(); return(Created($"api/v{apiVersion}/Customers/{item.Id}", dto)); }
public async Task <IActionResult> Put(long id, [FromBody] CustomerDto dto) { var item = await _dbContext.Set <Customer>().FindAsync(id); if (item == null) { return(NotFound()); } if (!await _validator.IsValid(dto, ModelState)) { return(BadRequest(ModelState)); } dto.Map(item); await _dbContext.SaveChangesAsync(); return(Ok()); }