public ActionResult Edit(Ad advert) { using (CommonContext db = new CommonContext()) { Ad ad = db.Ads.Find(advert.Id); ad.Title = advert.Title; ad.Text = advert.Text; ad.Keywords = advert.Keywords; ad.Theme = advert.Theme; ad.Date = DateTime.Now; ad.Country = advert.Country; db.SaveChanges(); } return RedirectToAction("Index"); }
public ActionResult New(Ad advert) { using (CommonContext db = new CommonContext()) { advert.Date = DateTime.Now; advert.Engaged = 0; advert.Views = 0; advert.Theme = advert.Theme; advert.OwnerID = User.Identity.Name; advert.Country = advert.Country; db.Ads.Add(advert); db.SaveChanges(); } return RedirectToAction("Index"); }