/// <summary> /// Use this method to create a new <see cref="Category"/>. /// </summary> /// <param name="name">The name.</param> /// <param name="sortOrder">The sort order.</param> /// <param name="description">The description.</param> /// <returns>The created category.</returns> /// <exception cref="ArgumentNullException">If the name parameter or null/empty string.</exception> /// <exception cref="PermissionException">If the current user does not have the required permissions.</exception> public Category Create(String name, Int32 sortOrder, String description) { if (String.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException(nameof(name)); } this.loggingService.Application.DebugWriteFormat("Create called on CategoryService, Name: {0}, Description: {1}, Sort Order: {2}", name, description, sortOrder); IAuthenticatedUser currentUser = this.userProvider.CurrentUser; if (currentUser == null || !currentUser.CanCreateCategory(this.permissionService)) { this.loggingService.Application.DebugWriteFormat("User does not have permissions to create a new category, name: {0}", name); throw new PermissionException("create category", currentUser); } Category output = this.dataStore.CreateCategory(name, sortOrder, description); this.loggingService.Application.DebugWriteFormat("Category created in CategoryService, Id: {0}", output.Id); CategoryCreated afterEvent = new CategoryCreated { Name = output.Name, CategoryId = output.Id, Author = this.userProvider.CurrentUser }; this.eventPublisher.Publish <CategoryCreated>(afterEvent); return(output); }
private void Apply(CategoryCreated e) { Id = e.SourceId; ParentId = e.ParentId; Name = e.Name; Color = e.Color; Visible = e.Visible; }
void CreateCategory(object sender, EventArgs e) { string categoryName = CategotyNameTextBox.Text; int imgId = ChooseImgList.SelectedIndices.Count > 0 ? ChooseImgList.SelectedIndices[0] : -1; if (IsValidInput(categoryName, imgId)) { CategoryCreated?.Invoke(categoryName, imgId); Close(); } }
public async Task Handle(CategoryCreated message) { var category = new Category(); category.Id = Guid.Parse(message.SourceId); category.ParentId = message.ParentId; category.Name = message.Name; category.Color = message.Color; category.Visible = message.Visible; categoryRepository.Save(category); }
public async Task Create_Category_Command_Should_Insert_NewData_And_Publish_CategoryCreatedEvent() { //Arrange var category = new Category(Guid.NewGuid(), "Testing Name", "Testing Desc"); await _mongoDbFixture.Repository.AddAsync(category); var command = new CategoryCreated(category.Id, category.Name, category.Description); //Act var creationTask = await _rabbitMqFixture.SubscribeAndGetAsync <CategoryCreated, Category>(_mongoDbFixture.GetMongoEntity, command.Id); await _rabbitMqFixture.PublishAsync(command); var createdCategoryMessage = await creationTask.Task; //Assert createdCategoryMessage.Id.Should().Be(command.Id); createdCategoryMessage.Name.Should().Be(command.Name); createdCategoryMessage.Description.Should().Be(command.Description); }
private void When(CategoryCreated @event) { this.InitialCategory(@event.AggregateId, @event.Name, @event.Level, @event.IconPath, @event.ParentCategoryId, @event.CategoryProperties); }
void When(CategoryCreated evnt) { AddCategory(evnt.BudgetId, evnt.CategoryId, evnt.Name, evnt.Description); }
void Apply(CategoryCreated e) { Id = e.Id.ToString(); }
Task IEventHandler <CategoryCreated> .HandleAsync(CategoryCreated payload) => RaiseEvent(payload);
public void Apply(CategoryCreated message) { Name = message.Name; }
public virtual void OnCategoryCreated() { CreateNotification(EventActionType.Created); CategoryCreated?.Invoke(this, new NewNotificationEventArgs(this)); }
public void Apply(CategoryCreated e) { }
private void Apply(CategoryCreated e) { Activated = e.Activated; ParentId = e.ParentId; }