public Login CreateLogin(Login login) { _repository.Add<Login>(login); _repository.UnitOfWork.SaveChanges(); return _repository.FindOne<Login>(o => o.Username == login.Username); }
public void UpdateLoginInfo(Login login) { Login dbLogin = _repository.FindOne<Login>(l => l.Id == login.Id); dbLogin.Username = login.Username; dbLogin.Email = login.Email; dbLogin.MemberPIN = login.MemberPIN; _repository.UnitOfWork.SaveChanges(); }
public bool ValidateUser(string username, string password) { FlyingClub.Data.Model.Entities.Login login = _repository.FindOne <FlyingClub.Data.Model.Entities.Login>(l => l.Username == username); if (login != null && login.Password == SimpleHash.MD5(password, login.PasswordSalt)) { return(true); } else { return(false); } }
public AccountViewModel(Login entity) { LoginId = entity.Id; UserName = entity.Username; Email = entity.Email; Email2 = entity.Email2; Password = entity.Password; MemberPIN = entity.MemberPIN; //TODO: implement timezone // TimeZoneOffset = entity. Init(); }
public bool ValidateUser(string username, string password) { IRepository repository = new GenericRepository(); FlyingClub.Data.Model.Entities.Login login = repository.FindOne <FlyingClub.Data.Model.Entities.Login>(l => l.Username == username); if (login != null && login.Password == password) { return(true); } else { return(false); } }
public static Login ConvertToEntity(this AccountEditViewModel entity, Login login) { if (entity == null) throw new Exception("Account not found"); login.Email = entity.Email; login.Email2 = entity.Email2; login.Username = entity.UserName; login.MemberPIN = entity.MemberPIN; return login; }
public AccountEditViewModel(Login entity) { LoginId = entity.Id; UserName = entity.Username; Email = entity.Email; }
public LoginViewModel(Login login) { Id = login.Id; Username = login.Username; Password = login.Password; }
public void UpdateLogin(Login login) { _repository.Attach<Login>(login); _repository.UnitOfWork.SaveChanges(); }
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status) { if (_dataService.IsExistingUsername(username)) { status = MembershipCreateStatus.DuplicateUserName; return null; } if (_dataService.IsExistingEmail(email)) { status = MembershipCreateStatus.DuplicateEmail; return null; } TimeSpan ts = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)); string salt = SimpleHash.GetSalt(32); string activationCode = ShortGuid.NewGuid(); User user = new User() { email = email, usergroupid = 3, username = username, password = SimpleHash.MD5(password, salt), passworddate = DateTime.Now.Date, usertitle = "Guest", joindate = Convert.ToInt32(ts.TotalSeconds), timezoneoffset = -6, options = 45108439, salt = salt, showbirthday = 0, showvbcode = 0, membergroupids = string.Empty }; user = _dataService.CreateForumUser(user, activationCode); if (user != null) { Login login = new Login(); login.Username = username; login.Password = SimpleHash.MD5(password, salt); login.Email = email; login.ForumUserId = user.userid; login.PasswordSalt = salt; login = _dataService.CreateLogin(login); if (login != null) { NtxfcMembershipProvider provider = Membership.Provider as NtxfcMembershipProvider; provider.SendConfirmationEmail(username, email, String.Format("{0}/Account/Activation/?u={1}&i={2}", ConfigurationManager.AppSettings["MemberUrl"], HttpContext.Current.Server.UrlEncode(username), activationCode)); status = MembershipCreateStatus.Success; return new MembershipUser(this.Name, username, login.Id, login.Email, string.Empty, string.Empty, true, false, new DateTime(), new DateTime(), new DateTime(), new DateTime(), new DateTime()); } } status = MembershipCreateStatus.ProviderError; return null; }
public ActionResult CreateLogin(LoginViewModel viewModel) { if (ModelState.IsValid) { Login login = new Login() { Username = viewModel.Username, Password = viewModel.Password }; _dataService.CreateLogin(login); } return View(ViewNames.CreateLogin, viewModel); }
public void ImportUsers() { IEnumerator<NtfcDataSet.LoginRow> srcLogins = _dataSet.Login.GetEnumerator(); while (srcLogins.MoveNext()) { var srcLogin = srcLogins.Current; NtfcDataSet.MembershipRow srcMember = _dataSet.Membership.FirstOrDefault(r => r.Member_ID == srcLogin.Member_ID); // drop members that don't have logins if (srcMember == null) { Debug.WriteLine("Member " + srcLogin.Member_ID + " not found."); continue; } if (srcMember.IsFirst_NameNull()) continue; if (srcMember.First_Name.Trim() == String.Empty || srcMember.First_Name.Contains("--")) continue; //if (!srcMember.Status) // continue; Login login = new Login(); login.MemberPIN = srcLogin.Member_ID.ToString(); string username = (srcMember.First_Name.Trim() + srcMember.Last_Name.Trim()).ToLower(); username = Regex.Replace(username, @"[\W]", String.Empty); login.Username = username; login.PasswordSalt = SimpleHash.GetSalt(32); login.Password = SimpleHash.MD5(srcLogin.Login_Password, login.PasswordSalt); login.FirstName = srcMember.First_Name; login.LastName = srcMember.Last_Name; login.Email = !srcMember.IsEmailNull() ? srcMember.Email : null; login.Email2 = !srcMember.Isemail2Null() ? srcMember.email2 : null; Member member = new Member(); if (srcMember.Status) member.Status = MemberStatus.Active.ToString(); else member.Status = MemberStatus.Removed.ToString(); member.AddressLine_1 = !srcMember.IsAddressNull() ? srcMember.Address : null; member.Phone = !srcMember.IsHome_PhoneNull() ? srcMember.Home_Phone : null; member.AltPhone = !srcMember.IsWork_PhoneNull() ? srcMember.Work_Phone : null; member.City = !srcMember.IsCityNull() ? srcMember.City : null; member.State = !srcMember.IsStateNull() ? srcMember.State : null; member.Zip = !srcMember.IsZipNull() ? srcMember.Zip : null; //member.PrimaryEmail = !srcMember.IsEmailNull() ? srcMember.Email : null; //member.SecondaryEmail = !srcMember.Isemail2Null() ? srcMember.email2 : null; member.EmergencyName = !srcMember.IsE_First_NameNull() ? srcMember.E_First_Name + " " + srcMember.E_Last_Name : null; member.EmergencyPhone = !srcMember.IsE_Home_PhoneNull() ? srcMember.E_Home_Phone : null; member.FirstName = srcMember.First_Name; member.LastName = srcMember.Last_Name; member.LastMedical = !srcMember.IsMedical_DateNull() ? (DateTime?)srcMember.Medical_Date : null; member.MemberSince = srcMember.Membership_Date; if (!srcMember.IsBirthdateNull()) { DateTime dob = DateTime.MinValue; if (DateTime.TryParse(srcMember.Birthdate, out dob)) member.BirthDate = dob; } member.LastUpdated = srcMember.Last_Update; member.PilotStatus = !srcMember.IsPilot_statusNull() ? srcMember.Pilot_status : null; member.Roles = new List<Role>(); member.Roles.Add(_dbContext.Roles.First(r => r.Id == 5)); if (login.MemberPIN == "547" || login.MemberPIN == "615") member.Roles.Add(_dbContext.Roles.First(r => r.Id == 1)); //Role instructorRole = _dbContext.Roles.First(r => r.Name.Contains("Instructor")); //if(login.OldMemberId == "703" || // login.OldMemberId == "587" || // login.OldMemberId == "199" || // login.OldMemberId == "296" || // login.OldMemberId == "359" || // login.OldMemberId == "655" || // login.OldMemberId == "727" || // login.OldMemberId == "618") //{ // member.Roles.Add(instructorRole); //} login.ClubMember = new List<Member>(); login.ClubMember.Add(member); _dbContext.Logins.Add(login); //_dbContext.Members.Add(member); // insert into forum database //User user = new User(); //user.password = srcLogin.Login_Password; //using (ExternalDbContext db = new ExternalDbContext()) //{ // db.Users.Add(user); // db.SaveChanges(); // string sqlCommand = String.Format("INSERT INTO `vb3_userfield` (userid) VALUES({0})", user.userid); // db.Database.ExecuteSqlCommand(sqlCommand); // db.SaveChanges(); // string sqlCommand2 = String.Format("INSERT INTO `vb3_useractivation` (userid, activationid) VALUES({0},'test')", user.userid); // db.Database.ExecuteSqlCommand(sqlCommand2); // db.SaveChanges(); //} } _dbContext.SaveChanges(); }