Example #1
0
        public User Register(Model.RegisterModel registerModel)
        {
            var manager = Ioc.Instance.GetService(typeof(IUserManager)) as IUserManager;

            var dtoUser = ObjectMapperManager.DefaultInstance.GetMapper <Model.RegisterModel, Dto.User>().Map(registerModel);

            var savedUser = manager.Save(dtoUser);
            var result    = ObjectMapperManager.DefaultInstance.GetMapper <Dto.User, Models.User>().Map(savedUser);

            return(result);
        }
Example #2
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus;
                //Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);
                var result = _repository.Register(model);

                if (result != null)
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
                    _session.CurrentUser = result;
                    return RedirectToAction("DailyScrum", "Home");
                }
                else
                {
                    //TODO: add dif error messages
                    ModelState.AddModelError("", "Error");
                }
            }

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