Esempio n. 1
0
        /// <summary>
        /// Puts the category specified in request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>
        ///   <c>PutCategoriesResponse</c> with updated category data.
        /// </returns>
        public PutCategoryTreeResponse Put(PutCategoryTreeRequest request)
        {
            var serviceRequest = new SaveCategoryTreeRequest
            {
                Id      = request.Id ?? Guid.Empty,
                Title   = request.Data.Name,
                Version = request.Data.Version,
                UseForCategorizableItems = request.Data.UseForCategorizableItems
            };
            IList <Module.Root.Services.Categories.CategoryNodeModel> rootNodes = new List <Module.Root.Services.Categories.CategoryNodeModel>();

            if (request.Data.Nodes != null)
            {
                foreach (var node in request.Data.Nodes)
                {
                    rootNodes.Add(RemapChildren(node, null));
                }
                serviceRequest.RootNodes = rootNodes;
            }

            var categoryTree = categoryTreeService.Save(serviceRequest);

            return(new PutCategoryTreeResponse {
                Data = categoryTree.Id
            });
        }