private void Initialization(Membership model, int action) { if (!string.IsNullOrEmpty(model.FullName)) { model.FullName = model.FullName.Trim(); } if (!string.IsNullOrEmpty(model.Email)) { model.Email = model.Email.Trim(); } if (!string.IsNullOrEmpty(model.Phone)) { model.Phone = model.Phone.Trim(); } if (string.IsNullOrEmpty(model.Password)) { model.Password = "******"; } if (string.IsNullOrEmpty(model.GUICode)) { model.InitDefaultValue(); } switch (action) { case 0: model.InitDefaultValue(); model.EncryptPassword(); break; case 1: Membership model001 = _membershipRepository.GetByID(model.ID); if (model001 != null) { if (model.Password != model001.Password) { model.EncryptPassword(); } } break; } }
public IActionResult SaveChange(Membership model) { string note = AppGlobal.InitString; int result = 0; if (model.Id > 0) { model.Initialization(InitType.Update, RequestUserID); model.ConcatFullname(); result = _resposistory.Update(model.Id, model); if (result > 0) { note = AppGlobal.Success + " - " + AppGlobal.EditSuccess; } else { note = AppGlobal.Success + " - " + AppGlobal.EditFail; } } else { model.Initialization(InitType.Insert, RequestUserID); model.ConcatFullname(); model.InitDefaultValue(); model.EncryptPassword(); result = _resposistory.Create(model); if (result > 0) { note = AppGlobal.Success + " - " + AppGlobal.CreateSuccess; } else { note = AppGlobal.Success + " - " + AppGlobal.CreateFail; } } return(Json(note)); }
public bool CreateCustomer(Membership.CustomerAccount u, ref CreateUserStatus status, string clearPassword) { bool result = false; if (u != null) { Membership.CustomerAccount testUser = new Membership.CustomerAccount(); testUser = Customers.FindByEmail(u.Email); if (testUser != null) { if (testUser.Bvin != string.Empty) { status = CreateUserStatus.DuplicateUsername; return false; } } if (u.Salt == string.Empty) { u.Salt = System.Guid.NewGuid().ToString(); u.Password = u.EncryptPassword(clearPassword); } if (Customers.Create(u) == true) { result = true; status = CreateUserStatus.Success; } else { status = CreateUserStatus.UpdateFailed; } } return result; }
public bool DoPasswordsMatchForCustomer(string trialpassword, Membership.CustomerAccount u) { return u.Password.Equals(u.EncryptPassword(trialpassword), StringComparison.InvariantCulture); }