/// <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);
        }