public HttpResponseMessage Post(CreateCustomer customer) { _processor.Send(customer); if (!ModelState.IsValid) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState)); } if (_notifications.HasNotifications()) { return(Request.CreateResponse(HttpStatusCode.BadRequest, _notifications.GetNotifications())); } return(Request.CreateResponse(HttpStatusCode.Created)); }
public IActionResult CreateResponse() { if (!DomainNotification.HasNotifications()) { return(Ok(EnvelopResult.Ok())); } return(BadRequest(EnvelopResult.Fail(DomainNotification.Notify()))); }
public void Handle(CreateCustomer command) { ValidateCommand(command); var exists = false; if (EmailExists(command.Email)) { AddNotification(command.Action, "The customer e-mail has already been taken."); exists = true; } if (exists) { return; } var idAdress = Guid.NewGuid(); var idCustomer = Guid.NewGuid(); if (_notifications.HasNotifications()) { return; } AddAddress(command, idAdress); AddCustomer(command, idAdress, idCustomer); var action = "Customer Created"; Commit(idCustomer, command, "Customer Created"); }
protected bool Commit() { if (_notifications.HasNotifications()) { return(false); } var commandResponse = _unitOfWork.Commit(); if (commandResponse.Success) { return(true); } _notifications.AddNotification(new Notification("Commit", "Ocorreu um erro ao salvar os dados no banco")); return(false); }
protected void Commit(Event evet) { if (_notifications.HasNotifications()) { return; } if (_architectureContext.SaveChanges() > 0) { var anterior = _eventRepository.GetLastEvent(evet.AggregateId); var objJson = anterior != null ? ReadToObject(((StoredEvent)anterior).Data, ((StoredEvent)anterior).Assembly) : null; _eventRepository.Save(evet, objJson); } else { AddNotification(new DomainNotification("Commit", "We had a problem during saving your data.")); } }
protected void Commit(Event evet) { if (_notifications.HasNotifications()) { return; } if (_architectureContext.SaveChanges() > 0) { _eventRepository.Save(evet); } else { AddNotification(new DomainNotification("Commit", "We had a problem during saving your data.")); } }
public async Task <bool> CommitAsync() { if (Notifications.HasNotifications()) { return(false); } if (await Uow.SaveChangesAsync()) { return(true); } Notifications.Handle(new Notification("Ocorreu um erro ao salvar os dados")); return(false); }
public bool IsValidOperation() { return(!_notifications.HasNotifications()); }
public bool InvalidTransaction() { return(_notifications.HasNotifications()); }
protected bool OperacaoValida() { return(!_notifications.HasNotifications()); }