public static PasswordStatus GetPasswordStatus(string name, string password2Check, string connectionString)
 {
     using (CarolineCottageDbContext dbContext = new CarolineCottageDbContext(connectionString))
     {
         var user = dbContext.Users.FirstOrDefault(x => x.Name == name) ?? new Repository.CarolineCottageClasses.User();
         if (PasswordUtilityFunctions.CreatePasswordHashSHA1(password2Check, user.Salt) == user.PasswordEnc)
         {
             return(PasswordStatus.Valid);
         }
     }
     return(PasswordStatus.Invalid);
 }
 public bool Save(string connectionString)
 {
     AutoMapper.Mapper.CreateMap <UserView, User>();
     using (CarolineCottageDbContext dbContext = new CarolineCottageDbContext(connectionString))
     {
         DateSet     = DateTime.Now;
         Salt        = PasswordUtilityFunctions.CreateSalt(6);
         PasswordEnc = PasswordUtilityFunctions.CreatePasswordHashSHA1(Password, Salt);
         dbContext.Entry(AutoMapper.Mapper.Map <UserView, User>(this)).State = this.UserID == 0 ? EntityState.Added : EntityState.Modified;
         dbContext.SaveChanges();
     }
     return(true);
 }
 public bool ValidateLogin(string connectionString)
 {
     return(PasswordUtilityFunctions.GetPasswordStatus(Name, Password, connectionString) == PasswordStatus.Valid);
 }