public async Task <CustomerDTO> Create([FromRoute] int?id, [FromBody] CustomerUpdateDTO customerUpdate) { if (id.HasValue && id != customerUpdate.Id) { throw new InvalidDataException(nameof(id)); } return(Mapper.Map <CustomerDTO>( await CustomerUpdateService.UpdateAsync(Mapper.Map <CustomerUpdateModel>(customerUpdate)))); }
public async Task <IActionResult> Edit(int id, CustomerUpdateDTO customerUpdate) { if (id != customerUpdate.Id) { return(NotFound()); } var customer = Mapper.Map <CustomerDTO>(await CustomerUpdateService.UpdateAsync(Mapper.Map <CustomerUpdateModel>(customerUpdate))); return(Redirect($"/customers/{customer.Id}")); }