Exemplo n.º 1
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    var mgr    = new ElDataManager();
                    var userId = mgr.Create(new User()
                    {
                        DisplayName = model.UserName,
                        Username    = model.UserName,
                        Password    = model.Password
                    });
                    WebSecurity.CreateUserAndAccount(model.UserName, model.Password, new { EverliveGuid = userId });
                    Roles.AddUsersToRoles(new[] { model.UserName }, new[] { "Dispatcher" });

                    WebSecurity.Login(model.UserName, model.Password);
                    return(RedirectToAction("All", "Locations"));
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    var mgr = new ElDataManager();
                    var userId = mgr.Create(new User()
                        {
                            DisplayName = model.UserName,
                            Username = model.UserName,
                            Password = model.Password
                        });
                    WebSecurity.CreateUserAndAccount(model.UserName, model.Password, new { EverliveGuid = userId });
                    Roles.AddUsersToRoles(new[] { model.UserName }, new[] { "Dispatcher" });

                    WebSecurity.Login(model.UserName, model.Password);
                    return RedirectToAction("All", "Locations");
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
 public BaseDispatchController()
 {
     this.context = new UsersContext();
     this.eManager = new ElDataManager();
 }
 public BaseDispatchController()
 {
     this.context  = new UsersContext();
     this.eManager = new ElDataManager();
 }