public void EditAd(ad a) { var cx1 = new Database1Entities8(); cx1.Entry(a).State = EntityState.Modified; cx1.SaveChanges(); }
public void DeleteAd(int id) { var db = new Database1Entities8(); ad a = db.ads.Find(id); db.ads.Remove(a); var q = db.userAds.Where(b => b.adId == id).Select(b => b); userAd o = null; foreach (var x in q) { o = x; } db.userAds.Remove(o); db.SaveChanges(); }
public int IpostAd(ad d) { var cx1 = new Database1Entities8(); var q = cx1.ads.Select(a => new { a.Id }); cx1.ads.Add(d); cx1.SaveChanges(); int max = 0; foreach (var x in q) { if (x.Id > max) { max = x.Id; } } return(max); }