public UserViewModel Update(int flag, UserViewModel objEntity) { try { // Database objDB = base.GetDatabase(); // Create a suitable command type and add the required parameter. using (DbCommand sprocCmd = objDB.GetStoredProcCommand(sp_UserViewModelUpdate)) { objDB.AddInParameter(sprocCmd, PARAM_Flag, DbType.Int32, flag); objDB.AddInParameter(sprocCmd, PARAM_UserId, DbType.Int32, objEntity.UserId); objDB.AddInParameter(sprocCmd, PARAM_UserEmail, DbType.String, objEntity.UserEmail); objDB.AddInParameter(sprocCmd, PARAM_OldPassword, DbType.String, objEntity.OldPassword); objDB.AddInParameter(sprocCmd, PARAM_Password, DbType.String, objEntity.Password); objDB.AddInParameter(sprocCmd, PARAM_UserTypeId, DbType.Int32, objEntity.UserTypeId); objDB.AddInParameter(sprocCmd, PARAM_UserStatus, DbType.Int32, objEntity.UserStatus); objDB.AddOutParameter(sprocCmd, PARAM_Result, DbType.Int32, objEntity.Result); objDB.ExecuteNonQuery(sprocCmd); objEntity.Result = Convert.ToInt32(objDB.GetParameterValue(sprocCmd, PARAM_Result)); } // } catch (Exception ex) { throw ex; } finally { } return objEntity; }
public List<UserViewModel> Select(int flag, UserViewModel entity) { var objEntityList = new List<UserViewModel>(); try { Database objDB = base.GetDatabase(); // Create a suitable command type and add the required parameter. using (DbCommand sprocCmd = objDB.GetStoredProcCommand(sp_UserViewModelSelect)) { objDB.AddInParameter(sprocCmd, COLUMN_NAME_FLAG, DbType.Int32, flag); objDB.AddInParameter(sprocCmd, COLUMN_NAME_USERID, DbType.Int32, entity.UserId); objDB.AddInParameter(sprocCmd, COLUMN_NAME_USEREMAIL, DbType.String, entity.UserEmail); objDB.AddInParameter(sprocCmd, COLUMN_NAME_PASSWORD, DbType.String, entity.Password); objDB.AddInParameter(sprocCmd, COLUMN_NAME_ROLEID, DbType.Int32, entity.RoleId); using (IDataReader reader = objDB.ExecuteReader(sprocCmd)) { while (reader.Read()) { UserViewModel objEntity = new UserViewModel(); objEntity.UserId = reader.GetColumnValue<Int32>(COLUMN_NAME_USERID); objEntity.RegistrationId = reader.GetColumnValue<Int32>(COLUMN_NAME_REGISTRATIONID); objEntity.RoleId = reader.GetColumnValue<Int16>(COLUMN_NAME_ROLEID); objEntity.RoleName = reader.GetColumnValue<String>(COLUMN_NAME_ROLENAME); objEntity.PhotoName = reader.GetColumnValue<String>(COLUMN_NAME_PHOTONAME); objEntity.Password = reader.GetColumnValue<String>(COLUMN_NAME_PASSWORD); objEntity.PasswordSalt = reader.GetColumnValue<String>(COLUMN_NAME_PASSWORDSALT); objEntity.UserEmail = reader.GetColumnValue<String>(COLUMN_NAME_USEREMAIL); objEntity.UserCreatedDate = reader.GetColumnValue<DateTime>(COLUMN_NAME_CREATEDDATE); objEntity.UserStatus = (StatusEnum)reader.GetColumnValue<Int16>(COLUMN_NAME_USERSTATUS); if (objEntity != null) { objEntityList.Add(objEntity); } } } } } catch (Exception ex) { throw ex; } finally { } return objEntityList; }
public UserAccount GetAccountByUser(UserViewModel objEntity) { UserAccount objUserAccount = new UserAccount(); objUserAccount.UserID = objEntity.UserId; objUserAccount.UserTypeID = Convert.ToInt32(objEntity.UserTypeId); objUserAccount.UserEmail = objEntity.UserEmail; return objUserAccount; }
public UserViewModel CheckSignIn(int flag, UserLoginViewModel objEntity) { var objUserViewModel = new UserViewModel { UserEmail = objEntity.UserEmail, Password = objEntity.Password }; return _userRepository.Select(flag, objUserViewModel).FirstOrDefault(); }
public UserAccountModel GetAccountByUser(UserViewModel objEntity) { UserAccountModel objUserAccount = new UserAccountModel(); objUserAccount.UserId = objEntity.UserId; objUserAccount.RoleId = objEntity.RoleId; objUserAccount.RegistrationId = objEntity.RegistrationId; objUserAccount.PhotoName = objEntity.PhotoName; objUserAccount.UserEmail = objEntity.UserEmail; return objUserAccount; }
public bool SetAccountByUser(int userID) { bool isSuccess = false; var userViewModel = new UserViewModel() { UserId = userID }; var objUserViewModel = _userRepository.Select(UserFlags.SelectByID.GetHashCode(), userViewModel).SingleOrDefault(); if (objUserViewModel != null) { SessionWrapper.UserAccount = new AccountRepository().GetAccountByUser(objUserViewModel); isSuccess = true; } return isSuccess; }
public List<UserViewModel> Select(int flag, UserViewModel entity) { var objEntityList = new List<UserViewModel>(); try { Database objDB = base.GetDatabase(); // Create a suitable command type and add the required parameter. using (DbCommand sprocCmd = objDB.GetStoredProcCommand(sp_UserViewModelSelect)) { objDB.AddInParameter(sprocCmd, "Flag", DbType.Int32, flag); objDB.AddInParameter(sprocCmd, "UserId", DbType.Int32, entity.UserId); objDB.AddInParameter(sprocCmd, "UserEmail", DbType.String, entity.UserEmail); objDB.AddInParameter(sprocCmd, "Password", DbType.String, entity.Password); objDB.AddInParameter(sprocCmd, "UserTypeId", DbType.Int32, entity.UserTypeId); using (IDataReader reader = objDB.ExecuteReader(sprocCmd)) { while (reader.Read()) { var objEntity = new UserViewModel() { UserId = reader.GetInt32(reader.GetOrdinal("UserId")), UserTypeId = reader.GetInt32(reader.GetOrdinal("UserTypeId")), UserEmail = reader.GetString(reader.GetOrdinal("UserEmail")), UserCreatedDate = reader.GetDateTime(reader.GetOrdinal("UserCreatedDate")), UserStatus = reader.GetInt32(reader.GetOrdinal("UserStatus")), }; if (objEntity != null) { objEntityList.Add(objEntity); } } } } } catch (Exception ex) { throw ex; } finally { } return objEntityList; }
public static int Login(UserViewModel objUserViewModel) { int isResult = LoginResultEnum.Failure.GetHashCode(); try { SessionWrapper.UserAccount = new AccountRepository().GetAccountByUser(objUserViewModel); FormsAuthentication.SetAuthCookie(Convert.ToString(objUserViewModel.UserId), false); isResult = LoginResultEnum.Success.GetHashCode(); } catch (Exception ex) { throw ex; } return isResult; }
public UserViewModel Update(int flag, UserViewModel objEntity) { try { // Database objDB = base.GetDatabase(); // Create a suitable command type and add the required parameter. using (DbCommand sprocCmd = objDB.GetStoredProcCommand(sp_UserViewModelUpdate)) { objDB.AddInParameter(sprocCmd, COLUMN_NAME_FLAG, DbType.Int32, flag); objDB.AddInParameter(sprocCmd, COLUMN_NAME_USERID, DbType.Int32, objEntity.UserId); objDB.AddInParameter(sprocCmd, COLUMN_NAME_OLDPASSWORD, DbType.String, objEntity.OldPassword); objDB.AddInParameter(sprocCmd, COLUMN_NAME_PASSWORDSALT, DbType.String, objEntity.PasswordSalt); objDB.AddInParameter(sprocCmd, COLUMN_NAME_PASSWORD, DbType.String, objEntity.Password); objDB.AddInParameter(sprocCmd, COLUMN_NAME_ROLEID, DbType.Int16, objEntity.RoleId); objDB.AddInParameter(sprocCmd, COLUMN_NAME_USEREMAIL, DbType.String, objEntity.UserEmail); objDB.AddInParameter(sprocCmd, COLUMN_NAME_USERSTATUS, DbType.Int16, objEntity.UserStatus); objDB.AddOutParameter(sprocCmd, COLUMN_NAME_RESULT, DbType.Int32, objEntity.Result); objDB.ExecuteNonQuery(sprocCmd); objEntity.Result = Convert.ToInt32(objDB.GetParameterValue(sprocCmd, COLUMN_NAME_RESULT)); } // } catch (Exception ex) { throw ex; } finally { } return objEntity; }
public int ValidateUserChangePassword(UserChangePasswordViewModel objEntity) { int result = 0; AccountRepository objAccountRepository = new AccountRepository(); var objUserRepository = new UserRepository(); var objLoginUserViewModel = objAccountRepository.GetUserDetailsforLogin(UserFlags.UserSignIn.GetHashCode(), new UserLoginViewModel() { UserEmail = objEntity.UserEmail }); if (objLoginUserViewModel != null) { if (PasswordHelpers.Validate(objLoginUserViewModel.Password, objLoginUserViewModel.PasswordSalt, objEntity.NewPassword)) { result = ResultFlags.OldPasswordMismatch.GetHashCode(); } else { PasswordHelpers.HashedPassword objHashedPassword = PasswordHelpers.Generate(objEntity.NewPassword); var objNewUserViewModel = new UserViewModel() { UserId = SessionWrapper.UserAccount.UserId, UserEmail = SessionWrapper.UserAccount.UserEmail, PasswordSalt = objHashedPassword.Salt, Password = objHashedPassword.Password }; objNewUserViewModel = objUserRepository.Update(UserFlags.UpdatePasswordByID.GetHashCode(), objNewUserViewModel); result = objNewUserViewModel.Result; } } return result; }
public ActionResult ManageUserEdit(Int16 id, UserViewModel objEntity) { var objUserRepository = new UserRepository(); if (ModelState.IsValid) { objEntity.UserId = id; objEntity = objUserRepository.Update(UserFlags.UpdateStatusByID.GetHashCode(), objEntity); if (objEntity.Result == ResultFlags.Success.GetHashCode()) { this.Flash("Success", "User details updated successfully"); return RedirectToAction("Index"); } else if (objEntity.Result == ResultFlags.Failure.GetHashCode()) { this.Flash("Error", "User details failed to Update"); } } return View(objEntity); }
public ActionResult ManageUserEdit(int id) { UserRepository objUserRepository = new UserRepository(); var objEntity = new UserViewModel(); objEntity = objUserRepository.Select(UserFlags.SelectByID.GetHashCode(), new UserViewModel() { UserId = id }).FirstOrDefault(); if (objEntity == null) { this.Flash("Error", "Failed to edit user details"); return RedirectToAction("Index"); } return View(objEntity); }
public UserViewModel GetUserDetailsforLogin(int flag, UserLoginViewModel objEntity) { var objUserViewModel = new UserViewModel { UserEmail = objEntity.UserEmail }; return _userRepository.Select(flag, objUserViewModel).FirstOrDefault(); }