Exemplo n.º 1
0
        public ActionResult Account(UserModels model, string returnUrl)
        {
            if (SessionFacade.USERNAME == null)
                return RedirectToAction("LogIn", "Home", new { ReturnUrl = "~/Home/Account" });
            else
            {
                IBusinessAuthentication ibau = GenericFactory<ShoppingBusiness, IBusinessAuthentication>.CreateInstance();
                if (ModelState.IsValid)
                {
                    if (ibau.ChangePasswordBusiness(SessionFacade.USERNAME, model.Password, model.NewPassword))
                    {
                        if (!String.IsNullOrEmpty(returnUrl))
                        {
                            return Redirect(returnUrl);
                        }
                        else
                        {
                            //return RedirectToAction("Index");
                            //ViewBag.Message = "Login successful..";
                            return RedirectToAction("Index", "Home");
                            //if (SessionFacade.PAGEREQUESTED != null)
                            //    Response.Redirect(SessionFacade.PAGEREQUESTED);
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", "Password changing not successful.");
                    }
                }

                // If we got this far, something failed, redisplay form
                return View(model);
            }
        }
Exemplo n.º 2
0
        public ActionResult Register(UserModels model, string returnUrl)
        {
            IBusinessAuthentication ibau = GenericFactory<ShoppingBusiness, IBusinessAuthentication>.CreateInstance();
            if (ModelState.IsValid)
            {
                if (ibau.RegisterBusiness(model.Username, model.Email, model.NewPassword))
                {
                    if (!String.IsNullOrEmpty(returnUrl))
                    {
                        return Redirect(returnUrl);
                    }
                    else
                    {
                        //return RedirectToAction("Index");
                        //ViewBag.Message = "Login successful..";
                        return RedirectToAction("Index", "Home");
                        //if (SessionFacade.PAGEREQUESTED != null)
                        //    Response.Redirect(SessionFacade.PAGEREQUESTED);
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Register not successful.");
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
Exemplo n.º 3
0
        //display: company information
        public ActionResult ViewAllUsers()
        {
            //XYZShoppingEntities db = new XYZShoppingEntities();
            DataClasses1DataContext db = new DataClasses1DataContext();
            UserModels um = new UserModels();
            var results = from u in db.users
                          select new
                          {
                              username = u.username,
                              email = u.email,
                              password = u.password
                          };
            foreach (var u in results)
            {
                UserModels tmpUser = new UserModels();
                tmpUser.Username = u.username;
                tmpUser.Email = u.email;
                tmpUser.Password = u.password;
                um.UserList.Add(tmpUser);
            }

            return View(um);
        }
Exemplo n.º 4
0
        public ActionResult LogIn(UserModels model, string returnUrl)
        {
            UserModels theUser = new UserModels();
            IBusinessAuthentication ibau = GenericFactory<ShoppingBusiness, IBusinessAuthentication>.CreateInstance();
            if (ModelState.IsValid)
            {
                if (ibau.IsValidUserBusiness(model.Username, model.Password) != "")
                {
                    theUser.UserTable = ibau.GetUserBussiness(model.Username);
                    SessionFacade.USERNAME = theUser.UserTable.Rows[0][0].ToString();
                    SessionFacade.EMAIL = theUser.UserTable.Rows[0][1].ToString();
                    SessionFacade.PASSWORD = theUser.UserTable.Rows[0][2].ToString();
                    FormsService.SignIn(model.Username, model.RememberMe);
                    if (!String.IsNullOrEmpty(returnUrl))
                    {
                        return Redirect(returnUrl);
                    }
                    else
                    {
                        //return RedirectToAction("Index");
                        //ViewBag.Message = "Login successful..";
                        return RedirectToAction("Index", "Home");
                        //if (SessionFacade.PAGEREQUESTED != null)
                        //    Response.Redirect(SessionFacade.PAGEREQUESTED);
                    }
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }

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