示例#1
0
        public ObjectRequest NewAddressCustomer(RegisterAddressCommand cmd)
        {
            var customer = _repCustomer.GetCustomer(cmd.CustomerId);

            if (customer == null)
            {
                return(new ObjectRequest()
                       .CreateObjectRequest($"Endereço nao foi adicionado, Cliente não Registrado no Sistema", false));
            }

            var address = new Address(cmd.Street, cmd.Number, cmd.Complement, cmd.District, cmd.City, cmd.State, cmd.CEP, cmd.CustomerId);

            _repAddress.AddEntity(address);

            if (Commit(address))
            {
                return(new ObjectRequest().CreateObjectRequest($" Novo Endereco Add com Sucesso", true));
            }

            return(new ObjectRequest().CreateErrorNotification(address.ListErrors()));
        }
示例#2
0
 public async Task <IActionResult> AddAddressCustomer([FromBody] dynamic body)
 {
     try
     {
         var cmd = new RegisterAddressCommand
         {
             CEP        = (string)body.cep,
             City       = (string)body.city,
             Complement = (string)body.complement,
             CustomerId = (Guid)body.customerId,
             District   = (string)body.district,
             Number     = (int)body.number,
             State      = (string)body.state,
             Street     = (string)body.street
         };
         var result = _service.NewAddressCustomer(cmd);
         return(await CreateResponse(result));
     }
     catch (Exception ex)
     {
         return(await ServerErroApp(ex));
     }
 }