Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "Id,UserName,Nazwa,NumerSkładu,SeriaPociągu,NumerPociągu,UwagiDyspozytora")] ServicePlan servicePlan)
        {
            if (ModelState.IsValid)
            {
                MasterProjectContext db = new MasterProjectContext();
                db.ServicePlans.Add(servicePlan);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(servicePlan));
        }
Ejemplo 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)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    Profile profile = new Profile {
                        UserName = model.Email, Imię = model.Imię, Nazwisko = model.Nazwisko, Miasto = model.Miasto, Zakład = model.Zakład
                    };
                    ServicePlan servicePlan = new ServicePlan {
                        UserName = model.Email
                    };
                    MasterProjectContext db = new MasterProjectContext();
                    db.Profiles.Add(profile);
                    db.SaveChanges();
                    // Aby uzyskać więcej informacji o sposobie włączania potwierdzania konta i resetowaniu hasła, odwiedź stronę https://go.microsoft.com/fwlink/?LinkID=320771
                    // Wyślij wiadomość e-mail z tym łączem
                    // 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, "Potwierdź konto", "Potwierdź konto, klikając <a href=\"" + callbackUrl + "\">tutaj</a>");

                    return(RedirectToAction("Login", "Account"));
                }
                AddErrors(result);
            }

            // Dotarcie do tego miejsca wskazuje, że wystąpił błąd, wyświetl ponownie formularz
            return(View(model));
        }