public void Cleanup() { var itemsToDelete = db.Subscriptions .Where(e => e.EmailAddress == TEST_EMAIL); db.Subscriptions.RemoveRange(itemsToDelete); db.SaveChanges(); }
public ActionResult SignUp([Bind(Include = "ID,EmailAddress,Source,SourceOther,Reason")] Subscription subscription) { subscription.EmailAddress = subscription.EmailAddress.Trim(); //Check existing email address if (db.Subscriptions.Any(s => s.EmailAddress == subscription.EmailAddress)) { ViewBag.CssClass = "danger"; ViewBag.Message = "Your email address is already signed up"; } else if (ModelState.IsValid) { subscription.DateTime = DateTime.Now; db.Subscriptions.Add(subscription); db.SaveChanges(); ViewBag.CssClass = "success"; ViewBag.Message = "You have been succesfully signed up!"; ModelState.Clear(); return(View()); } return(View(subscription)); }