Exemplo n.º 1
0
        public async Task <IActionResult> Put([FromRoute] long id, CustomerPut customerPut)
        {
            var customer = await _customers.GetById(id);

            if (customer == null)
            {
                throw new Exception("Cliente não encontrado");
            }

            customerPut.UpdateDomain(customer);

            await _customers.Update(customer);

            return(Ok(new Response <long>(customer.Id)));
        }
        public void Update(CustomerDTO customerDTO)
        {
            var proto = _mapperCustomer.DTOToProto(customerDTO);

            var customer = new CustomerPut
            {
                Id        = customerDTO.Id.Value,
                IdAddress = proto.IdAddress,
                Name      = proto.Name,
                Surname   = proto.Surname,
                Cpf       = proto.Cpf,
                Genre     = proto.Genre.ToString()
            };

            _serviceGrpcCustomer.Update(customer);
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="request"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public override Task <Empty> Update(CustomerPut request, ServerCallContext context)
        {
            var customer = new domain.Entities.Customer
            {
                Id        = request.Id,
                IdAddress = request.IdAddress,
                Name      = request.Name,
                Surname   = request.Surname,
                Cpf       = request.Cpf,
                Genre     = request.Genre.ToCharArray()[0]
            };

            if (_repositoryCustomer.Get(customer.Id) == null)
            {
                throw new ApplicationException("Customer not found.");
            }

            _repositoryCustomer.Update(customer);

            return(Task.FromResult(new Empty()));
        }