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)
                {
                    medewerker mede = new medewerker();
                    model.Voornaam      = mede.voornaam;
                    model.Achternaam    = mede.achternaam;
                    model.Password      = mede.wachtwoord;
                    model.Email         = mede.email;
                    model.Tussenvoegsel = mede.tussenvoegsel;


                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // 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.º 2
0
        // POST: Activity/Activate/medewerker
        public ActionResult ActivateConfirm(int?id)
        {
            medewerker medewerker = db.medewerkers.Find(id);

            //Set actief to true
            medewerker.actief = true;
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "medewerkerid,voorletters,tussenvoegsels,achternaam,vestigingsid,actief, AspNetUserID")] medewerker medewerker)
 {
     if (ModelState.IsValid)
     {
         db.Entry(medewerker).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.vestigingsid = new SelectList(db.vestigings, "vestigingsid", "vestigingsnaam", medewerker.vestigingsid);
     ViewBag.AspNetUserID = new SelectList(db.AspNetUsers, "Id", "Email", medewerker.AspNetUserID);
     return(View(medewerker));
 }
Exemplo n.º 4
0
        // GET: Activity/Activate/5
        public ActionResult Activate(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            medewerker medewerker = db.medewerkers.Find(id);

            if (medewerker == null)
            {
                return(HttpNotFound());
            }
            return(View(medewerker));
        }
Exemplo n.º 5
0
        // GET: AssignFil/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            medewerker medewerker = db.medewerkers.Find(id);

            if (medewerker == null)
            {
                return(HttpNotFound());
            }
            ViewBag.vestigingsid = new SelectList(db.vestigings, "vestigingsid", "vestigingsnaam", medewerker.vestigingsid);
            ViewBag.AspNetUserID = new SelectList(db.AspNetUsers, "Id", "Email", medewerker.AspNetUserID);
            return(View(medewerker));
        }
Exemplo n.º 6
0
        public async Task <ActionResult> RegisterMedewerker(RegisterMedewerkerViewModel model)
        {
            var user = new ApplicationUser {
            };

            if (ModelState.IsValid)
            {
                //Alle informatie voor het maken van een medewerker
                if (model.TussenVoegsel != "")
                {
                    //string uName = model.FirstName + model.LastName;

                    user = new ApplicationUser {
                        UserName = model.UserEmail, Email = model.UserEmail
                    };
                }
                else
                {
                    //string uName = model.FirstName + model.TussenVoegsel + model.LastName;

                    user = new ApplicationUser {
                        UserName = model.UserEmail, Email = model.UserEmail
                    };
                }

                //De gebruiker toevegen aan de Role Medewerker omdat deze gemaakt is in de sectie
                //Registreer medewerker


                var result = await UserManager.CreateAsync(user, model.Password);


                if (result.Succeeded)
                {
                    var Medewerker = new medewerker {
                    };
                    if (model.TussenVoegsel != "")
                    {
                        Medewerker = new medewerker {
                            voorletters = model.FirstName, tussenvoegsels = "", achternaam = model.LastName, vestigingsid = model.vestigingsid, actief = false, AspNetUserID = user.Id
                        };
                    }
                    else
                    {
                        Medewerker = new medewerker {
                            voorletters = model.FirstName, tussenvoegsels = model.TussenVoegsel, achternaam = model.LastName, vestigingsid = model.vestigingsid, actief = false, AspNetUserID = user.Id
                        };
                    }
                    UserManager.AddToRole(user.Id, "Medewerker");
                    // 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>");
                    using (DB_A3D6D6_FlowerPowerLuukEntities db = new DB_A3D6D6_FlowerPowerLuukEntities())
                    {
                        try
                        {
                            db.medewerkers.Add(Medewerker);

                            db.SaveChanges();
                        }
                        catch (DbEntityValidationException e)
                        {
                            Exception raise = e;
                            foreach (var validationErrors in e.EntityValidationErrors)
                            {
                                foreach (var validationError in validationErrors.ValidationErrors)
                                {
                                    string message = string.Format("{0}:{1}",
                                                                   validationErrors.Entry.Entity.ToString(),
                                                                   validationError.ErrorMessage);
                                    // raise a new exception nesting
                                    // the current instance as InnerException
                                    raise = new InvalidOperationException(message, raise);
                                }
                            }
                            throw raise;
                        }
                    }
                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }