private async Task BuildSaveCommandHandlerSuccess() { SaveCompanyCommand saveCommand = (SaveCompanyCommand)validEntity; bool result = await handlerSuccess.Handler(saveCommand); SuccessTests(handlerSuccess.Invalid, result, handlerSuccess.Notifications); }
private async Task BuildSaveCommandHandlerError() { SaveCompanyCommand saveCommand = (SaveCompanyCommand)validEntity; bool result = await handlerError.Handler(saveCommand); ErrorTests(handlerError.Invalid, result, handlerError.Notifications); }
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); }
public Task <IActionResult> Post([FromBody] Company company) { SaveCompanyCommand companyCommand = company; companyCommand.ResetCustomerId(); var result = _handler.Handler(companyCommand); return(Response(result, _handler.Notifications)); }
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; }