Exemplo n.º 1
0
 public ActionResult Edit([Bind(Include = "KidName,Email,PointsGoal")] KID kID)
 {
     if (ModelState.IsValid)
     {
         kID.KidiD           = User.Identity.GetUserId();
         db.Entry(kID).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(kID));
 }
Exemplo n.º 2
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    var kid = new KID
                    {
                        Email      = model.Email,
                        KidName    = model.KidName,
                        PointsGoal = model.PointsGoal,
                        KidiD      = user.Id
                    };
                    try
                    {
                        using (var db = new PWNDEntities())
                        {
                            db.KIDs.Add(kid);
                            db.SaveChanges();
                        }
                    }
                    catch (Exception Ex)
                    {
                        throw;
                    }
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    MessageSender.SendEmail(model.Email, "Thank You", "Thank You For Joining The PWND Community");

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Exemplo n.º 3
0
      // GET: KIDs/Edit/5
      public ActionResult Edit()
      {
          var id = User.Identity.GetUserId();

          if (id == null)
          {
              return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
          }
          KID kID = db.KIDs.Find(id);

          if (kID == null)
          {
              return(HttpNotFound());
          }
          return(View(kID));
      }