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(); }
public async Task CreateDescription(BrandDescription description) { description.CreationDate = DateTime.Now; description.EditDate = DateTime.Now; _brandDescriptionRepository.Add(description); await _brandDescriptionRepository.SaveChangesAsync(); }
// 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; }
// 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); }
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"); } }
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)); }
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); } }
/* * 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); }
public void UpdateDescription(BrandDescription description) { description.EditDate = DateTime.Now; _brandDescriptionRepository.Update(description); _brandDescriptionRepository.SaveChanges(); }
public async Task <IActionResult> EditBrandDescription(BrandDescription description) { _brandService.UpdateDescription(description); return(RedirectToAction("EditBrand", new { id = description.BrandId })); }