private ICollection <VulnerabilityDB> CheckIfInDB(List <VulnerabilityDB> vulnerabilityDBs) { ICollection <VulnerabilityDB> vulners = new List <VulnerabilityDB>(); foreach (VulnerabilityDB vul in vulnerabilityDBs) { VulnerabilityDB vulnerabilityDB = db.vulnerabilityDBs.ToList().Find(x => x.name == vul.name); if (vulnerabilityDB != null) { vulners.Add(vulnerabilityDB); } } HashSet <string> diffids = new HashSet <string>(db.vulnerabilityDBs.ToList().Select(s => s.name)); var results = vulnerabilityDBs.Where(m => !diffids.Contains(m.name)).ToList(); vulnerabilityDBs.Clear(); foreach (VulnerabilityDB vul in results) { vulners.Add(vul); } foreach (VulnerabilityDB vul in vulners) { vulnerabilityDBs.Add(vul); } return(vulnerabilityDBs); }
public VulnerabilityDB SetParamsConsole(VulnerabilityDB vulnerability) { if (vulnerability.vulnerability == null) { Console.WriteLine("Set vulnerability:"); vulnerability.vulnerability = Convert.ToDouble(Console.ReadLine()); } if (vulnerability.threats == null) { Console.WriteLine("Set threats:"); vulnerability.threats = Convert.ToDouble(Console.ReadLine()); } if (vulnerability.techDamage == null) { Console.WriteLine("Set techDamage:"); vulnerability.techDamage = Convert.ToDouble(Console.ReadLine()); } if (vulnerability.bizDamage == null) { Console.WriteLine("Set bizDamage:"); vulnerability.bizDamage = Convert.ToDouble(Console.ReadLine()); } vulnerability.rezult = vulnerability.rezult == null?riskRules.Calculete(new double[] { vulnerability.vulnerability.GetValueOrDefault(), vulnerability.threats.GetValueOrDefault() , vulnerability.techDamage.GetValueOrDefault(), vulnerability.bizDamage.GetValueOrDefault() }) : vulnerability.rezult; return(vulnerability); }
public void Delet(VulnerabilityDB obj) { context = new Context(); obj = context.vulnerabilityDBs.Find(obj.id); if (obj == null) { return; } context.vulnerabilityDBs.Remove(obj); context.SaveChanges(); }
public void Update(VulnerabilityDB obj) { context = new Context(); var entity = context.vulnerabilityDBs.Find(obj.id); if (entity == null) { return; } context.Entry(entity).CurrentValues.SetValues(obj); context.SaveChanges(); return; }
public void Create(VulnerabilityDB vulnerabilityDB) { context = new Context(); context.vulnerabilityDBs.Add(vulnerabilityDB); context.SaveChanges(); }
public void UpdateVulnerabilityDB(VulnerabilityDB vulnerability) { crudVulnerabilityDB.Update(vulnerability); }