예제 #1
0
        /// <summary>
        /// Use this method to update an existing <see cref="Category"/>.
        /// </summary>
        /// <param name="categoryId">Id of the category</param>
        /// <param name="name">The updated name.</param>
        /// <param name="sortOrder">The updated sort order.</param>
        /// <param name="description">The updated description.</param>
        /// <returns>The updated category.</returns>
        /// <exception cref="ArgumentNullException">If the name or categoryId parameters or null/empty strings.</exception>
        /// <exception cref="PermissionException">If the current user does not have the required permissions.</exception>
        public Category Update(String categoryId, String name, Int32 sortOrder, String description)
        {
            if (String.IsNullOrWhiteSpace(categoryId))
            {
                throw new ArgumentNullException(nameof(categoryId));
            }
            if (String.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            this.loggingService.Application.DebugWriteFormat("Update called on CategoryService, Id: {0}, Name: {1}, Description: {2}, Sort Order: {3}", categoryId, name, description, sortOrder);

            IAuthenticatedUser currentUser = this.userProvider.CurrentUser;

            if (currentUser == null || !currentUser.CanUpdateCategory(this.permissionService))
            {
                this.loggingService.Application.DebugWriteFormat("User does not have permissions to update a category, Id: {0}", categoryId);
                throw new PermissionException("create category", currentUser);
            }

            Category output = this.dataStore.UpdateCategory(categoryId, name, sortOrder, description);

            this.loggingService.Application.DebugWriteFormat("Category updated in CategoryService, Id: {0}", output.Id);

            CategoryUpdated afterEvent = new CategoryUpdated {
                Name       = output.Name,
                CategoryId = output.Id,
                Author     = this.userProvider.CurrentUser
            };

            this.eventPublisher.Publish <CategoryUpdated>(afterEvent);

            return(output);
        }
예제 #2
0
        protected void ClosePopup()
        {
            // Refresh collection on parent
            CategoryUpdated.InvokeAsync(true);

            // Close Popup
            ShowManager = false;
        }
예제 #3
0
 void When(CategoryUpdated evnt)
 {
     UpdateCategory(evnt.BudgetId, evnt.CategoryId, evnt.Name, evnt.Description);
 }
예제 #4
0
 public void Apply(CategoryUpdated message)
 {
     Name = message.Name;
 }
예제 #5
0
 public virtual void OnCategoryUpdated()
 {
     CreateNotification(EventActionType.Updated);
     CategoryUpdated?.Invoke(this, new NewNotificationEventArgs(this));
 }
예제 #6
0
 private static void OnCategoryUpdated(CategoryUpdateEventArgs e)
 {
     CategoryUpdated?.Invoke(null, e);
 }
예제 #7
0
 public void Handle(CategoryUpdated @event, CommerceInstance instance)
 {
     CategoryTree.Remove(CommerceInstance.Current.Name);
 }