Ejemplo n.º 1
0
        public static void DeleteBrandDescriptionNode(BrandDescription objNode)
        {
            Logger.WriteToLogFile(DBInteractor.Common.Utilities.GetCurrentMethod());

            Neo4jController.m_graphClient.Cypher
            .Match("(C:" + objNode.getLabel() + "{ id : { Nodeid }})")
            .Match("(C)-[R]-()")
            .OptionalMatch("(D)-[:" + Rel_Brand.brand_brandDescription + "]->(C)")
            .Delete("C,R")
            .With("D")
            .Match("(D)-[R]-()")
            .OptionalMatch("(D)-[:" + Rel_Brand.brand_item + "]->(E)")
            .Delete("D,R")
            .With("E")
            .Match("(E)-[R]-()")
            .OptionalMatch("(F)-[:" + Rel_Item.item_itemDescription + "]->(E)")
            .Delete("E,R")
            .With("F")
            .Match("(F)-[R]-()")
            .Delete("F,R")
            .WithParams(new
            {
                Nodeid = objNode.id
            })
            .ExecuteWithoutResults();
        }
Ejemplo n.º 2
0
 public async Task CreateDescription(BrandDescription description)
 {
     description.CreationDate = DateTime.Now;
     description.EditDate     = DateTime.Now;
     _brandDescriptionRepository.Add(description);
     await _brandDescriptionRepository.SaveChangesAsync();
 }
Ejemplo n.º 3
0
        // If Equals() returns true for a pair of objects
        // then GetHashCode() must return the same value for these objects.

        public override int GetHashCode()
        {
            //Get hash code for the Name field if it is not null.
            int hashMarca = BrandDescription == null ? 0 : BrandDescription.GetHashCode();

            //int hashIdMarca = IdMarca.GetHashCode();

            //Calculate the hash code for the product.
            return(hashMarca); //^ hashIdMarca;
        }
Ejemplo n.º 4
0
        // If Equals() returns true for a pair of objects
        // then GetHashCode() must return the same value for these objects.

        public override int GetHashCode()
        {
            //Get hash code for the modelo field if it is not null.
            int hashMarca = BrandDescription == null ? 0 : BrandDescription.GetHashCode();

            //Get hash code for the modelo field if it is not null.
            int hashModelo = ModelDescription == null ? 0 : ModelDescription.GetHashCode();

            //Calculate the hash code for the product.
            return(hashMarca ^ hashModelo);
        }
Ejemplo n.º 5
0
        public static void CreateBrandNode(BrandWrapper objWrap)
        {
            Logger.WriteToLogFile(DBInteractor.Common.Utilities.GetCurrentMethod());
            Logger.WriteObjectToLogFile <Brand>(objWrap.objBrand);

            Brand            objBrand       = objWrap.objBrand;
            SubCategory      objSubCategory = objWrap.objSubCategory;
            BrandDescription objbrandDesc   = new BrandDescription();

            objbrandDesc.Name = objBrand.Name;
            objBrand.Name     = null;

            if (objSubCategory == null)
            {
                Logger.WriteToLogFile("Sub Category not found");
                throw new Exception("Sub Category is null");
            }

            var result = Neo4jController.m_graphClient.Cypher
                         .Match("(A:" + objSubCategory.getLabel() + " { id : { id }})")
                         .Match("(B:" + objbrandDesc.getLabel() + " { Name : { Name }})")
                         .Merge("(A)-[R:" + Rel_SubCategory.subCategory_brand + "]->(C:" + objBrand.getLabel() + "{ Name : { Name }})")
                         .OnCreate()
                         .Set("C = { objBrand }")
                         .OnMatch()
                         .Set("B = { objBrand }")
                         .Merge("(C)-[R2:" + Rel_Brand.brand_brandDescription + "]->(B)")
                         .WithParams(new
            {
                id       = objSubCategory.id,
                objBrand = objBrand,
                Name     = objbrandDesc.Name
            })
                         .Return((B, R) => new
            {
                Count         = B.Count(),
                RelationCount = R.Count()
            })
                         .Results
                         .Single();

            if (result.Count == 1)
            {
                Logger.WriteToLogFile("Successfully created brand");
            }
            else
            {
                Logger.WriteToLogFile("unable to create brand");
            }
        }
Ejemplo n.º 6
0
        public bool Equals(Model other)
        {
            //Check whether the compared object is null.
            if (other is null)
            {
                return(false);
            }

            //Check whether the compared object references the same data.
            if (Object.ReferenceEquals(this, other))
            {
                return(true);
            }

            //Check whether the products' properties are equal.
            return(BrandDescription.Equals(other.BrandDescription) && ModelDescription.Equals(other.ModelDescription));
        }
Ejemplo n.º 7
0
        public static void AddBrand(string sheetName)
        {
            Logger.WriteToLogFile(Utilities.GetCurrentMethod());

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

            Excel.Range usedRange = sheet.UsedRange;

            BrandDescriptionWrapper objWrap = new BrandDescriptionWrapper();



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

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

                    if ((usedRange.Cells[Row, Col] as Excel.Range).Value2 != null)
                    {
                        value = (usedRange.Cells[Row, Col] as Excel.Range).Value2.ToString();
                    }
                    else
                    {
                        continue;
                    }

                    ExcelUtilities.PopulateStructure <BrandDescription>(name, value, ref objBrand);
                }

                //Add the country in the Neo4j Database


                objWrap.objRoot  = new BrandRoot();
                objWrap.objBrand = objBrand;

                DBAddinterface.CreateBrandDescriptionNode(objBrand);
            }
        }
Ejemplo n.º 8
0
        /*
         * This created a brandroot-[has_brand]->brand relation and nodes
         *
         */
        public static BrandDescription CreateBrandDescriptionNode(BrandDescription objBrand)
        {
            Logger.WriteToLogFile(DBInteractor.Common.Utilities.GetCurrentMethod());
            Logger.WriteObjectToLogFile <BrandDescription>(objBrand);

            BrandRoot objRoot = new BrandRoot();


            var result = Neo4jController.m_graphClient.Cypher
                         .Merge("(A:" + objRoot.getLabel() + " { Name : { Rootname}} )")
                         .OnCreate()
                         .Set("A = { objRoot}")
                         .Merge("(A)-[R:" + Rel_BrandRoot.brandroot_brand + "]->(B:" + objBrand.getLabel() + "{ Name : { Name }})")
                         .OnCreate()
                         .Set("B = { objBrand }")
                         .WithParams(new
            {
                Rootname = objRoot.Name,
                objRoot  = objRoot,
                objBrand = objBrand,
                Name     = objBrand.Name
            })
                         .Return((B, R) => new
            {
                BrandCount    = B.Count(),
                RelationCount = R.Count(),
                retObj        = B.As <BrandDescription>()
            })
                         .Results
                         .Single();

            if (result.BrandCount == 1)
            {
                Logger.WriteToLogFile("Successfully created Brand");
                objBrand = result.retObj;
            }
            else
            {
                Logger.WriteToLogFile("unable to create Brand");
                objBrand = null;
            }

            return(objBrand);
        }
Ejemplo n.º 9
0
 public void UpdateDescription(BrandDescription description)
 {
     description.EditDate = DateTime.Now;
     _brandDescriptionRepository.Update(description);
     _brandDescriptionRepository.SaveChanges();
 }
Ejemplo n.º 10
0
 public async Task <IActionResult> EditBrandDescription(BrandDescription description)
 {
     _brandService.UpdateDescription(description);
     return(RedirectToAction("EditBrand", new { id = description.BrandId }));
 }