public string EditTreeNode(int NodeId, string Title, string Description, string imageName, string VideoName, string VideoFrom)
        {
            try
            {
                //check parent nodeid
                if (NodeId == 162)
                {
                    return("3");
                }

                CategoryContent objCategoryContent = dbContext.CategoryContents.Where(x => x.Id == NodeId).SingleOrDefault();
                objCategoryContent.Name = Title;

                if (Description != null && Description != "")
                {
                    objCategoryContent.Description = Description;
                }

                if (imageName.Trim() != "" && imageName.Trim() != null)
                {
                    objCategoryContent.ImageName = imageName;
                }

                if (VideoName.Trim() != "" && VideoName != null)
                {
                    objCategoryContent.VideoName = VideoName;
                    objCategoryContent.VideoFrom = VideoFrom;
                }

                dbContext.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return("2");
        }
Exemple #2
0
        public async Task <Category> CreateCategory(string fullName, Guid catalogId, int collapseOrder, bool isTopMenu, bool isLanding, int sortOrder)
        {
            CategoryContent content = new CategoryContent(fullName);

            content.CatalogIdentifier  = catalogId;
            content.CollapseOrder      = collapseOrder;
            content.IsTopMenu          = isTopMenu;
            content.IsLanding          = isLanding;
            content.SortOrder          = sortOrder;
            content.HierarchyLevel     = 0;
            content.LeftBower          = 1;
            content.RightBower         = 1;
            content.PlatformIdentifier = _platformIdentifier;
            content.ParentIdentifier   = null;

            Category newEntity = new Category
            {
                Contents = content
            };

            var entity = await _context.Categories.AddAsync(newEntity);

            return(entity);
        }
        public string CreateChildNode(int CategoryId, int ParentId, string Name, int UserId, string Description, string imageName, string VideoName, string VideoFrom)
        {
            try
            {
                CategoryContent objCategoryContent = new CategoryContent();
                objCategoryContent.Name        = Name;
                objCategoryContent.ParentId    = ParentId;
                objCategoryContent.CategoryId  = CategoryId;
                objCategoryContent.UserId      = UserId;
                objCategoryContent.Description = Description;
                objCategoryContent.ImageName   = imageName;
                objCategoryContent.VideoName   = VideoName == null ? "" : VideoName.Trim() == "" ? "" : VideoName.Trim();
                objCategoryContent.VideoFrom   = VideoFrom == null ? "" : VideoFrom.Trim() == "" ? "" : VideoFrom.Trim();
                dbContext.CategoryContents.Add(objCategoryContent);

                dbContext.SaveChanges();

                return(objCategoryContent.Id.ToString());
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }