public CountryStateDistrictRelation AddRelStateDistrict(CountryTemp c, CountrySate p1, CountryDistrict p2) { bool isFailed; if (p1 != null) { if (!IsStateDistrictExist(p1, p2)) { var o = new CountryStateDistrictRelation(); o.CountrySateID = p1.CountrySateID; o.CountryDistrictID = p2.CountryDistrictID; db.CountryStateDistrictRelations.Add(o); var failed = db.SaveChanges(o, "AddRelStateDistrict"); //var failed = db.SaveChanges(); isFailed = (failed == -1) ? true : false; if (!isFailed) { return(o); } else { AddError(c, "StateDistrictRel"); return(null); } } } return(null); }
public CountrySate AddState(CountryTemp c) { bool isFailed; if (c.IsState) { if (IsStringNullOrWhite(c.State)) { return(null); } if (!IsStateExist(c.State)) { var state = new CountrySate(); state.StateName = c.State; state.IsDivision = c.IsDivision; db.CountrySates.Add(state); var failed = db.SaveChanges(state, "AddState"); //var failed = db.SaveChanges(); isFailed = (failed == -1) ? true : false; if (isFailed) { AddError(c, "State"); } return(state); } } var x = db.CountrySates.FirstOrDefault(n => n.StateName == c.State); if (x == null) { isFailed = true; AddError(c, "State"); } return(x); }
public bool IsStateDistrictExist(CountrySate s, CountryDistrict d) { return(db.CountryStateDistrictRelations.Any(n => n.CountrySateID == s.CountrySateID && n.CountryDistrictID == d.CountryDistrictID)); }
public bool IsStateCountryExist(CountrySate s, Country c) { return(db.CountryStateCountryRelations.Any(n => n.CountrySateID == s.CountrySateID && n.CountryID == c.CountryID)); }