public void AddQuestionnaire() { var questionnaireName = "Test Name 1"; var questionnaireCreator = new User() { Name = "User 1" }; context.Users.Add(questionnaireCreator); context.SaveChanges(); var addQuestionnaireCommand = new AddEntityCommand(context); var questionnaire = new Questionnaire { Name = questionnaireName, CreatedByUser = questionnaireCreator, CreatedDate = DateTime.Now.AddDays(-2) }; addQuestionnaireCommand.Execute(questionnaire); Assert.Equal(1, context.Questionnaires.Count()); Assert.Equal(1, context.Users.Count()); }
public override async void AddEntity(IClosable window) { try { base.IsLoading = true; AddEntityCommand.RaiseCanExecuteChanged(); _mapper.Map(EntityViewModel, _questionnaire); await _client.GetSyncTable <Questionnaire>().InsertAsync(_questionnaire); await _client.SyncAsync(); foreach (var questionViewModel in EntityViewModel.QuestionViewModels) { await questionViewModel.Save(); } _list.AddEntity(_questionnaire); window?.Close(); await _client.SyncAsync(); } finally { base.IsLoading = false; } }
public void ValidationExceptionOnInvalidModel() { var entity = new TestValidationModel { }; var command = new AddEntityCommand <TestValidationModel>(new EntityEntry(entity, EntityEntryState.Added)); command.GetModel(WriteModelOptions.Default).FirstOrDefault(); }
public DynamicVM() { ExitCommand = new ExitCommand(this); AddEntityCommand = new AddEntityCommand(this); OpenDialogCommand = new OpenDialogCommand(this); AddAttributeCommand = new AddAttributeCommand(this); EntityRecords = new ObservableCollection <EntityRecord>(); InItEntityRecords(); }
///------------------------------------------------------------------------------------------------- /// <summary> /// An IHyperstore extension method that creates an entity. /// </summary> /// <exception cref="SessionRequiredException"> /// Thrown when a Session Required error condition occurs. /// </exception> /// <param name="domain"> /// the domain model. /// </param> /// <param name="schema"> /// The schema. /// </param> /// <param name="id"> /// (Optional) the identifier. /// </param> /// <returns> /// The new entity. /// </returns> ///------------------------------------------------------------------------------------------------- public static IModelEntity CreateEntity(this IDomainModel domain, ISchemaEntity schema, Identity id = null) { Contract.Requires(domain != null, "domain"); Contract.Requires(schema != null, "schema"); if (Session.Current == null) { throw new SessionRequiredException(); } var cmd = new AddEntityCommand(domain, schema, id); Session.Current.Execute(cmd); return(cmd.Entity); }
///------------------------------------------------------------------------------------------------- /// <summary> /// An IHyperstore extension method that creates an entity. /// </summary> /// <exception cref="SessionRequiredException"> /// Thrown when a Session Required error condition occurs. /// </exception> /// <typeparam name="T"> /// Generic type parameter. /// </typeparam> /// <param name="domain"> /// (Optional) the domain model. /// </param> /// <param name="id"> /// (Optional) the identifier. /// </param> /// <returns> /// The new entity. /// </returns> ///------------------------------------------------------------------------------------------------- public static T CreateEntity <T>(this IDomainModel domain, Identity id = null) where T : IModelEntity { Contract.Requires(domain != null, "domain"); if (Session.Current == null) { throw new SessionRequiredException(); } var schema = domain.Store.GetSchemaEntity <T>(); var cmd = new AddEntityCommand(domain, schema, id); Session.Current.Execute(cmd); return((T)cmd.Entity); }
public PaymentController( IBankService bankService, PaymentMapper paymentMapper, AddEntityCommand addEntityCommand, GetPaymentByIdQuery getPaymentByIdQuery, PaymentViewModelBuilder paymentViewModelBuilder, GetAllPaymentsQuery getAllPaymentsQuery) { this.bankService = bankService; this.paymentMapper = paymentMapper; this.addEntityCommand = addEntityCommand; this.getPaymentByIdQuery = getPaymentByIdQuery; this.paymentViewModelBuilder = paymentViewModelBuilder; this.getAllPaymentsQuery = getAllPaymentsQuery; }
protected override Task <CommandResult <Guid> > ExecuteCommand(AddEntityCommand command, CancellationToken cancellationToken) { var agg = BusinessEntityAggregateRoot.Create(); var isSucceed = false; var okId = Guid.Empty; if (agg.IsValid) { isSucceed = true; agg.GetEvents().ToImmutableList() .ForEach(ev => Publisher.Publish(ev)); okId = agg.GetChange().Identity.Value; } return(Task.FromResult(new CommandResult <Guid>(isSucceed, okId, agg.Failures))); }
protected override Task <CommandResult <Guid> > ExecuteCommand(AddEntityCommand command, CancellationToken cancellationToken) { var agg = _aggregateFactory.Create(command); var isSucceed = false; var okId = Guid.Empty; //validation is not working nice yet if (agg.IsValid) { isSucceed = true; agg.GetEvents().ToImmutableList() .ForEach(ev => Publisher.Publish(ev)); okId = agg.GetChange().AggregationId.Value; } return(Task.FromResult(new CommandResult <Guid>(isSucceed, okId, agg.Failures.ToImmutableList()))); }
protected override Task <CommandResult <Guid> > ExecuteCommand(AddEntityCommand command, CancellationToken cancellationToken) { var agg = EventStreamBusinessEntityAggregateRoot.Create(EntityTestId.GetNext(), Name.From(command.Name), Email.From(command.Mail)); var isSucceed = false; var okId = Guid.Empty; //validation is not working nice yet if (agg.ValidationResults.IsValid) { isSucceed = true; agg.GetEvents().ToImmutableList() .ForEach(ev => Publisher.Publish(ev)); okId = agg.GetChange().AggregationId.Value; } return(Task.FromResult(new CommandResult <Guid>(isSucceed, okId, agg.ValidationResults.Errors.ToImmutableList()))); }
private void System_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e) { AddEntityCommand.UpdateCanExecute(this, e); }
public Task <ActionResult <SomeEntity> > AddEntity(AddEntityCommand command) => Task.Run <ActionResult <SomeEntity> >(() => Ok(command.Execute().Result));