コード例 #1
0
        public async Task <IActionResult> Actualizar(MCliente clienteCRUD)
        {
            try
            {
                Clientes clienteDB = await _clientesRepository.ObtenerClienteIdAsync(clienteCRUD.Id);

                if (clienteDB == null)
                {
                    return(BadRequest("El cliente no existe."));
                }

                _mapper.Map(clienteCRUD, clienteDB);
                await _unitOfWork.CompleteAsync();

                var result = _mapper.Map <Clientes, MCliente>(clienteDB);
                return(Ok(result));
            }

            catch (Exception e)
            {
                return(StatusCode(500, e));
            }
        }