public bool DeleteCounty(County county) { if (county.Locality.Count == 0) { using (var ctx = new SocializRContext()) { county = ctx.County.Include(c => c.Locality).FirstOrDefault(c => c.Id == county.Id); } } if (county.Locality.Count != 0) { return(false); } if (user.isAdmin()) { using (var ctx = new SocializRContext()) { ctx.County.Remove(county); ctx.SaveChanges(); ctx.SaveChanges(); } } return(false); }
public bool AddCounty(County newCounty) { if (user.isAdmin()) { using (var ctx = new SocializRContext()) { ctx.County.Add(newCounty); ctx.SaveChanges(); return(true); } } return(false); }
public bool DeleteLocality(Locality locality) { if (user.isAdmin()) { using (var ctx = new SocializRContext()) { ctx.Locality.Remove(locality); ctx.SaveChanges(); return(true); } } return(false); }
public bool EditCounty(County pre, County post) { if (user.isAdmin()) { using (var ctx = new SocializRContext()) { ctx.County.Update(pre); if (pre.Name != post.Name) { pre.Name = post.Name; } ctx.SaveChanges(); return(true); } } return(false); }
public bool EditLocality(Locality pre, Locality post) { if (user.isAdmin()) { using (var ctx = new SocializRContext()) { ctx.Locality.Update(pre); if (pre.Name != post.Name) { pre.Name = post.Name; } if (pre.CountyId != post.CountyId) { pre.CountyId = post.CountyId; pre.County = post.County; } ctx.Locality.Update(pre); ctx.SaveChanges(); return(true); } } return(false); }
public BaseRepository(SocializRContext context) { Context = context; }
public BaseUnitOfWork(SocializRContext context) { DbContext = context; }