Exemplo n.º 1
0
 public static void UpdateUser(UserProfile user)
 {
     using (UnitOfWork uow = new UnitOfWork())
     {
         uow.UserProfileRepository.Update(user);
         uow.Save();
     }
 }
Exemplo n.º 2
0
 public static void CreateUser(UserProfile user)
 {
     UserProfile dbUser = GetUser(user.UserName);
     if (dbUser != null)
         throw new Exception("User with that username already exists.");
     UnitOfWork uow = new UnitOfWork();
     uow.UserProfileRepository.Insert(user);
     uow.Save();
 }
Exemplo n.º 3
0
 public ActionResult EditProfile(User user)
 {
     UnitOfWork unitofWork = new UnitOfWork();
     //User userNew = unitofWork.UserRepository.GetUserByEmail(User.Identity.Name);
     //userNew.FirstName = user.FirstName;
     //userNew.LastName = user.LastName;
     unitofWork.UserRepository.Update(user);
     unitofWork.Save();
     return View();
 }
Exemplo n.º 4
0
 public PartialViewResult _NotificationReadAll(List<Notification> notifications)
 {
     UnitOfWork unitOfWork = new UnitOfWork();
     User user = unitOfWork.UserRepository.GetUserByUserID((Guid)Membership.GetUser(WebSecurity.User.Identity.Name).ProviderUserKey);
     List<Notification> notificationList = unitOfWork.NotificationRepository.UserUnreadNotification(user);
     List<Notification> notificationListNew = new List<Notification>();
     foreach (Notification item in notificationList)
     {
         item.IsNoticed = true;
         unitOfWork.NotificationRepository.InsertOrUpdate(item);
     }
     unitOfWork.Save();
     return PartialView("_Notification", notificationListNew);
 }
        public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            if (string.IsNullOrEmpty(username))
            {
                status = MembershipCreateStatus.InvalidUserName;
                return null;
            }
            if (string.IsNullOrEmpty(password))
            {
                status = MembershipCreateStatus.InvalidPassword;
                return null;
            }
            if (string.IsNullOrEmpty(email))
            {
                status = MembershipCreateStatus.InvalidEmail;
                return null;
            }

            string HashedPassword = Crypto.HashPassword(password);
            if (HashedPassword.Length > 128)
            {
                status = MembershipCreateStatus.InvalidPassword;
                return null;
            }

            using (UnitOfWork reopo = new UnitOfWork())
            {
                UserProfile existingUser = reopo.UserRepository.GetUserByEmail(email);
             
               
                if (existingUser!=null)
                {
                    status = MembershipCreateStatus.DuplicateEmail;
                    return null;
                }

                UserProfile NewUser = new UserProfile
                {
                   // UserId = Guid.NewGuid(),
                   
                    Email = email,
                    
                };

                reopo.UserRepository.Insert(NewUser);
                reopo.Save();
                status = MembershipCreateStatus.Success;
                return null;// new MembershipUser(Membership.Provider.Name, NewUser.UserName, NewUser.UserId, NewUser.Email, null, null, NewUser.IsApproved, NewUser.IsLockedOut, NewUser.CreateDate.Value, NewUser.LastLoginDate.Value, NewUser.LastActivityDate.Value, NewUser.LastPasswordChangedDate.Value, NewUser.LastLockoutDate.Value);
            }
        }
Exemplo n.º 6
0
    public static string CreateAccount(string userName, string email,string password, string FirstName,string LastName ,bool requireConfirmationToken = false)
    {
        string status="";
            using (UnitOfWork reopo = new UnitOfWork())
            {
                User existingUser = reopo.UserRepository.GetUserByEmail(email);

                string HashedPassword = Crypto.HashPassword(password);
                if (HashedPassword.Length > 128)
                {
                    status = "InvalidPassword";
                    return null;
                }

                if (existingUser != null)
                {
                    status = "DuplicateEmail";
                    return null;
                }
                User NewUser = new User
                {
                    UserId = Guid.NewGuid(),
                    Username = email,
                    Password = HashedPassword,
                    IsApproved = true,
                    Email = email,
                    CreateDate = DateTime.UtcNow,
                    LastPasswordChangedDate = DateTime.UtcNow,
                    PasswordFailuresSinceLastSuccess = 0,
                    LastLoginDate = DateTime.UtcNow,
                    LastActivityDate = DateTime.UtcNow,
                    LastLockoutDate = DateTime.UtcNow,
                    IsLockedOut = false,
                    LastPasswordFailureDate = DateTime.UtcNow,
                    FirstName = FirstName,
                    LastName = LastName
                };

                reopo.UserRepository.Insert(NewUser);
                reopo.Save();
            }
            return status;
    }