Beispiel #1
0
        public ActionResult ChangePassWord(ViewModel.RegisterViewModel model)
        {
            string userName    = model.UserName;
            string passWord    = model.PassWord;
            string newPassWord = model.newPassWord;

            var user = _context.Registrations
                       .Single(u => u.UserName == userName &&
                               u.PassWord == passWord);

            user.PassWord = newPassWord;
            user.Flag     = 1;
            _context.SaveChanges();


            return(RedirectToAction("welcome", "Login"));
        }
Beispiel #2
0
        //internal static Task CreateRegisteredWorker(ViewModel.RegisterViewModel model)
        //{
        //    using (var context = new ApplicationDbContext())
        //    {
        //        context.Workers.Add(new Worker() { Username = model.Username, Password = model.Password, ConfirmPassword = model.Password, Email = model.Email });
        //        context.SaveChanges();
        //    }
        //    return Task.Factory.StartNew(() => {  });
        //}

        internal static Task CreateRegisteredWorker(ViewModel.RegisterViewModel model)
        {
            using (var context = new ApplicationDbContext())
            {
                context.Workers.Add(new Worker()
                {
                    Username        = model.Username,
                    Password        = model.Password,
                    ConfirmPassword = model.Password,
                    Uloga           = Enums.UlogaEnum.Administrator,
                    ImePrezime      = model.Username,
                    Email           = model.Email
                });
                context.SaveChanges();
            }
            return(Task.Factory.StartNew(() => { }));
        }
Beispiel #3
0
        public async Task <ActionResult> Register1(ViewModel.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)
                {
                    WebApplication19.Models.uzytkownicy   uzytkownik = new Models.uzytkownicy();
                    WebApplication19.Models.adres_klienta adres      = new Models.adres_klienta();
                    uzytkownik.klient.Add(model.Klient);
                    uzytkownik.haslo             = model.Password;
                    uzytkownik.nazwa_uzytkownika = model.Email;
                    uzytkownik.typ = "klient";

                    adres = model.Adres_klienta;

                    db.Entry(adres).State      = EntityState.Added;
                    db.Entry(uzytkownik).State = EntityState.Added;

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

                    // For more information on how to enable account confirmation and password reset please visit http://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));
        }
Beispiel #4
0
        public ActionResult Login(ViewModel.RegisterViewModel model)
        {
            string userName = model.UserName;
            string passWord = model.PassWord;

            var user = _context.Registrations
                       .Where(u => u.UserName == userName &&
                              u.PassWord == passWord).ToList();

            if (user.Count > 0)
            {
                int firstEnterUser = user.First().Flag;

                if (firstEnterUser == 0)
                {
                    return(RedirectToAction("ChangePassWord", "Login"));
                }
                else
                {
                    return(RedirectToAction("welcome", "Login"));
                }
            }
            return(RedirectToAction("Index", "Home"));
        }
 public RegisterPage()
 {
     _RegisterViewModel = new ViewModel.RegisterViewModel();
     this.DataContext = _RegisterViewModel;
     this.InitializeComponent();
 }
        public override System.Threading.Tasks.Task <System.Web.Mvc.ActionResult> Register(ViewModel.RegisterViewModel viewModel)
        {
            var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Register);

            ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "viewModel", viewModel);
            RegisterOverride(callInfo, viewModel);
            return(System.Threading.Tasks.Task.FromResult(callInfo as ActionResult));
        }
 partial void RegisterOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, ViewModel.RegisterViewModel viewModel);
Beispiel #8
0
 public RegisterPage()
 {
     InitializeComponent();
     BindingContext = new ViewModel.RegisterViewModel(Navigation);
 }