public Task <CreateCategoryRootCommandResponse> Handle(CreateCategoryRootCommand command)
        {
            _categoryDomainService.CheckCategoryName(command.Name);
            var category = new CategoryRoot(command.Id, command.Name,
                                            command.Description,
                                            _repository.AsQuery().OfType <CategoryRoot>().Count(),
                                            new CategoryImage(command.CategoryImage.MainCatImage, command.CategoryImage.FullMainCatImage,
                                                              command.CategoryImage.TopPageCatImage))
            {
                SubCategories = new List <Category>()
            };

            _repository.Add(category);
            return(Task.FromResult(new CreateCategoryRootCommandResponse()));
        }
Пример #2
0
        public static void CreateCategoryRoot(CategoryRoot objCategoryRoot)
        {
            Logger.WriteToLogFile(DBInteractor.Common.Utilities.GetCurrentMethod());
            Logger.WriteObjectToLogFile <CategoryRoot>(objCategoryRoot);

            Neo4jController.m_graphClient.Cypher
            .Merge("(A:" + objCategoryRoot.getLabel() + "{ Name : {Name} })")
            .OnCreate()
            .Set("A = { objCategoryRoot }")
            .WithParams(new
            {
                Name            = objCategoryRoot.Name,
                objCategoryRoot = objCategoryRoot
            })
            .ExecuteWithoutResults();
        }
Пример #3
0
        public static void AddCategory(string sheetName)
        {
            Logger.WriteToLogFile(Utilities.GetCurrentMethod());

            Excel.Worksheet sheet = ExcelController.GetWorkSheet(sheetName);

            Excel.Range usedRange = sheet.UsedRange;

            CategoryRoot    objcategoryRoot = new CategoryRoot();
            CategoryWrapper objWrap         = new CategoryWrapper();

            //Do not consider row 1 as its the header
            for (int Row = 2; Row <= usedRange.Rows.Count; Row++)
            {
                Category objCategory = new Category();

                for (int Col = 1; Col <= usedRange.Columns.Count; Col++)
                {
                    string name = (string)(usedRange.Cells[1, Col] as Excel.Range).Value2;

                    dynamic dValue = (usedRange.Cells[Row, Col] as Excel.Range).Value2;
                    string  value  = null;

                    if (dValue != null)
                    {
                        value = dValue.ToString();
                    }
                    else
                    {
                        continue;
                    }

                    ExcelUtilities.PopulateStructure <Category>(name, value, ref objCategory);
                }

                //Add the country in the Neo4j Database

                objWrap.objCategoryRoot = objcategoryRoot;
                objWrap.objCategory     = objCategory;

                DBAddinterface.CreateCategoryNode(objCategory);
            }
        }
Пример #4
0
        public static void CreateCategoryNode(Category objCategory)
        {
            Logger.WriteToLogFile(DBInteractor.Common.Utilities.GetCurrentMethod());
            Logger.WriteObjectToLogFile <Category>(objCategory);

            CategoryRoot objRoot = new CategoryRoot();

            var result = Neo4jController.m_graphClient.Cypher
                         .Merge("(A:" + objRoot.getLabel() + " { Name : {Name} })")
                         .OnCreate()
                         .Set("A = { objRoot }")
                         .Merge("(A)-[R:" + Rel_CategoryRoot.categoryroot_category + "]->(B:" + objCategory.getLabel() + "{ Name : {CategoryName} })")
                         .OnCreate()
                         .Set("B = { objCategory }")
                         .OnMatch()
                         .Set("B = {objCategory }")
                         .WithParams(new
            {
                Name         = objRoot.Name,
                objCategory  = objCategory,
                objRoot      = objRoot,
                CategoryName = objCategory.Name
            })
                         .Return((B, R) => new
            {
                CategoryCount = B.Count(),
                RelationCount = R.Count()
            })
                         .Results
                         .Single();

            if (result.CategoryCount == 1)
            {
                Logger.WriteToLogFile("Successfully created category");
            }
            else
            {
                Logger.WriteToLogFile("Unable to create category");
            }
        }