public MembershipUser CreateUser(string name, string email, string password)
        {
            MembershipUser membershipUser = GetUser(email, false);

            if (membershipUser == null)
            {
                try
                {
                    int userRoleId = _roleService.GetAllRoleEntities().First(role => role.Name == "user").Id;
                    MvcUser mvcUser = new MvcUser()
                    {
                        Name = name,
                        Email = email,
                        RoleId = userRoleId,
                        Password = Crypto.HashPassword(password),
                        CreationDate = DateTime.Now
                    };

                    _userService.CreateUser(mvcUser.ToBllUser());
                    membershipUser = GetUser(email, false);
                    return membershipUser;

                }
                catch
                {
                    return null;
                }
            }
            return null;
        }
示例#2
0
 public ActionResult DeleteConfirmed(MvcUser user)
 {
     _userService.DeleteUser(user.ToBllUser());
     return RedirectToAction("Index");
 }