Exemplo n.º 1
0
        private async Task BuildSaveCommandHandlerSuccess()
        {
            SaveCompanyCommand saveCommand = (SaveCompanyCommand)validEntity;
            bool result = await handlerSuccess.Handler(saveCommand);

            SuccessTests(handlerSuccess.Invalid, result, handlerSuccess.Notifications);
        }
Exemplo n.º 2
0
        private async Task BuildSaveCommandHandlerError()
        {
            SaveCompanyCommand saveCommand = (SaveCompanyCommand)validEntity;
            bool result = await handlerError.Handler(saveCommand);

            ErrorTests(handlerError.Invalid, result, handlerError.Notifications);
        }
Exemplo n.º 3
0
        public async Task <bool> Handler(SaveCompanyCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(false);
            }

            Company customer = command;

            if (customer.Id > 0)
            {
                if (!await _repository.Update(customer))
                {
                    AddNotification("", "Erro ao atualizar o estabelecimento");
                    return(false);
                }
            }
            else
            {
                await _repository.Insert(customer);
            }
            return(true);
        }
Exemplo n.º 4
0
        public Task <IActionResult> Post([FromBody] Company company)
        {
            SaveCompanyCommand companyCommand = company;

            companyCommand.ResetCustomerId();
            var result = _handler.Handler(companyCommand);

            return(Response(result, _handler.Notifications));
        }
Exemplo n.º 5
0
 public Company(SaveCompanyCommand saveCompany)
 {
     Id        = saveCompany.Id;
     Name      = saveCompany.Name;
     Cnpj      = saveCompany.Cnpj;
     Address   = saveCompany.Address;
     Telephone = saveCompany.Telephone;
     NumberOfSpacesForMotorcycles = saveCompany.NumberOfSpacesForMotorcycles;
     NumberOfSpacesForCars        = saveCompany.NumberOfSpacesForCars;
 }