public void AccountControllerRegister()
        {
            const bool ISAJAX = true;
            var info = new RegisterViewModel()
            {
                UserName = "******",
                Password = "******",
                ConfirmPassword = "******",
                Address = "asd"
            };

            var factory = new WorkChannelFactoryMock();
            var auth = new FakeAuthenticationService();
            var ctrl = new AccountController(factory, auth);
            FakeControllerSession.SetFakeControllerContext(ctrl, ISAJAX);

            var res2 = ctrl.Register(info) as RedirectToRouteResult;
            Assert.IsNotNull(res2);
            Assert.AreEqual(res2.RouteValues["action"], "Index");
            Assert.AreEqual(factory.LastWorkChannel.UsersRegistered.Count, 1);
            Assert.AreEqual(factory.LastWorkChannel.UsersRegistered[0].Email, "Admin");
        }
        public ActionResult Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    using (var proxy = factory.GetWorkChannel())
                    {
                        var result = proxy.RegisterUser(new PizzaNetCommon.Requests.UpdateRequest<PizzaNetCommon.DTOs.UserDTO>
                        {
                            Data = new PizzaNetCommon.DTOs.UserDTO
                            {
                                Address = model.Address,
                                Email = model.UserName,
                                Password = model.Password
                            }
                        });
                    }
                    //auth.CreateUserAndAccount(model.UserName, model.Password);
                    auth.Login(model.UserName, model.Password);
                    return RedirectToAction("Index", "Home");
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", e);
                }
            }

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