Example #1
0
 public ActionResult Create(FormCollection formCollection)
 {
     subscription sub = new subscription();
     sub.duration = int.Parse(formCollection["duration"]);
     sub.idTraining = int.Parse(formCollection["kind"]);
     sub.dateOfPurchase = DateTime.Now;
     sub.status = "Оформлен";
     db.subscriptions.Add(sub);
     db.SaveChanges();
     UserProfile u = db.UserProfiles.Find(int.Parse(formCollection["id"]));
     u.idSubscription = sub.idSubscription;
     db.Entry(u).State = EntityState.Modified;
     db.SaveChanges();
     return RedirectToAction("Index", new { id = u.UserId });
 }
Example #2
0
 public ActionResult ExtendSubscription(subscription subscription, int duration)
 {
     if (ModelState.IsValid)
     {
         db.Entry(subscription).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(subscription);
 }