示例#1
0
        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))));
        }
示例#2
0
        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}"));
        }