public void addUpdateEntity(entity newEnt) { try { var old = DB.entity.Where(e => e.entityValue == newEnt.entityValue); if (old.Any()) { var oldEnt = old.Single(); foreach (var s in newEnt.entitySynonimus.Split(';')) { if (s != "") { oldEnt.entitySynonimus += s + ";"; } } } else { DB.entity.Add(newEnt); } DB.SaveChanges(); } catch (Exception e) { // Logger.log(this.GetType().Name, MethodBase.GetCurrentMethod().Name, e.ToString()); throw new DBException(); } }
public IentityBase clone() { var newMulEnt = new entity(); newMulEnt.entityID = entityID; newMulEnt.entityValue = entityValue; newMulEnt.entityType = entityType; newMulEnt.entitySynonimus = entitySynonimus; return(newMulEnt); }
public async virtual void addNewEntity(string value, string type) { try { if (DB.entity.Count(x => x.entitySynonimus.Contains(value)) == 0) { var entity = new entity(); entity.entityValue = value; entity.entitySynonimus = ";" + value + ";"; entity.entityType = type; DB.entity.Add(entity); await DB.SaveChangesAsync(); } } catch (Exception e) { // Logger.log(this.GetType().Name, MethodBase.GetCurrentMethod().Name, e.ToString()); throw new DBException(); } }