public ActionResult DeleteConfirmed(int id) { YearlySubscriber yearlySubscriber = db.YearlySubscribers.Find(id); db.YearlySubscribers.Remove(yearlySubscriber); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,Name,Email,ApplicationUserID")] YearlySubscriber yearlySubscriber) { if (ModelState.IsValid) { db.Entry(yearlySubscriber).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Details")); } return(View(yearlySubscriber)); }
// GET: YearlySubscribers/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } YearlySubscriber yearlySubscriber = db.YearlySubscribers.Find(id); if (yearlySubscriber == null) { return(HttpNotFound()); } return(View(yearlySubscriber)); }
// GET:YearlySubscribers/Details/5 public ActionResult Details(int?id) { var currentUserId = User.Identity.GetUserId(); if (currentUserId == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } YearlySubscriber yearlySubscriber = db.YearlySubscribers.Where(r => r.ApplicationUserID == currentUserId).FirstOrDefault(); if (yearlySubscriber == null) { return(HttpNotFound()); } return(View(yearlySubscriber)); }
public ActionResult Create([Bind(Include = "ID,Name,Email,ApplicationUserId")] YearlySubscriber yearlySubscriber) { var currentUserId = User.Identity.GetUserId(); yearlySubscriber.ApplicationUserID = currentUserId; if (ModelState.IsValid) { yearlySubscriber.SubscriptionActive = true; yearlySubscriber.SubscriptionStartDate = DateTime.Now; yearlySubscriber.SubscriptionEndDate = yearlySubscriber.SubscriptionStartDate.AddDays(365); db.YearlySubscribers.Add(yearlySubscriber); db.SaveChanges(); return(RedirectToAction("Index", "Home")); } return(View(yearlySubscriber)); }