示例#1
0
 public static User CreateUserAndAccount(RegisterModel registerDates)
 {
     var newRegisteredUser = new User();
       newRegisteredUser.Email = registerDates.Email;
       newRegisteredUser.UserName = registerDates.Email;
       newRegisteredUser.UniqueKey = Guid.NewGuid().ToString();
       newRegisteredUser.FirstName = registerDates.FirstName;
       newRegisteredUser.LastName = registerDates.LastName;
       newRegisteredUser.Password = registerDates.Password;
       newRegisteredUser.RoleID = (int)Core.Roles.User;
       newRegisteredUser.AddedDate = DateTime.Now;
       Core.DataContext.Users.Add(newRegisteredUser);
       Core.DataContext.SaveChanges();
       return newRegisteredUser;
 }
示例#2
0
        public ActionResult Register(RegisterModel model)
        {
            var newUSer = new User();
              if (ModelState.IsValid)
              {
            if (!UsersManager.CheckExistingUserByEmail(model.Email))
            {
              newUSer = UsersManager.CreateUserAndAccount(model);
              FormsAuthentication.SetAuthCookie(model.Email, false);
              ZazaIdentity.Current.CurrentUser = newUSer;
            }
            return RedirectToAction("Index", "Home");

              }

              return View(model);
        }