public string UpateLoginUserPassword(User objUpdateUser) { string resultmsg = string.Empty; objencrypt = new DataEncryptDecrypt(); objpwdencrypt = new PasswordEncryptDecrypt(); string resultMsg = string.Empty; string encryptKey = string.Empty; try { string resultkey = getEncryptdata(objUpdateUser.UserCode); string pwd = objpwdencrypt.Encrypt(objUpdateUser.Password, resultkey); //objUpdateUser.Password;// using (SqlConnection sqlconn_obj = new SqlConnection(SqlHelper.GetDBConnectionString())) { using (SqlCommand sqlcmd_obj = new SqlCommand("OPAPP_PROC_UpateLoginUserPassword", sqlconn_obj)) { sqlcmd_obj.CommandType = CommandType.StoredProcedure; sqlcmd_obj.Parameters.AddWithValue("@UserID", objUpdateUser.UserID); sqlcmd_obj.Parameters.AddWithValue("@PASSWORD", pwd); sqlcmd_obj.Parameters.AddWithValue("@UpdatedBy", objUpdateUser.UserID); sqlconn_obj.Open(); int resultcount = sqlcmd_obj.ExecuteNonQuery(); if (resultcount > 0) { resultmsg = "Success"; } else { resultmsg = "Fail"; } } } } catch (Exception ex) { objExceptionlog.InsertException("WebAPI", ex.Message, "DALUserLoginVerification", "Proc: " + "OPAPP_PROC_UpateLoginUserPassword", "UpateLoginUserPassword"); throw; } return(resultmsg); }
public ShowUserInformation UserRegistration(UserModel data) { SqlConnection connection = DatabaseConnection(); try { //password encrption string encryptedPassword = PasswordEncryptDecrypt.EncodePasswordToBase64(data.Password); //for store procedure and connection to database SqlCommand command = StoredProcedureConnection("spRegisterUser", connection); command.Parameters.AddWithValue("@EmailID", data.EmailID); command.Parameters.AddWithValue("@Password", encryptedPassword); command.Parameters.AddWithValue("@UserName", data.UserName); command.Parameters.AddWithValue("@RegistrationDate", DateTime.Now); connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.Read() == false) { return(null); } else { return(new ShowUserInformation { Id = reader.GetInt32(0), EmailID = reader.GetString(1), UserName = reader.GetString(3), RegistationDate = reader.GetDateTime(4).ToString() }); } } catch (Exception e) { throw new Exception(e.Message); } finally { connection.Close(); } }
public string GetUserDeviceLoginStatus(UserLogin objUser) { string resultmsg = string.Empty; objencrypt = new DataEncryptDecrypt(); objpwdencrypt = new PasswordEncryptDecrypt(); string resultMsg = string.Empty; string encryptKey = string.Empty; try { string resultkey = getEncryptdata(objUser.UserName); string pwd = objpwdencrypt.Encrypt(objUser.Password, resultkey); using (SqlConnection sqlconn_obj = new SqlConnection(SqlHelper.GetDBConnectionString())) { using (SqlCommand sqlcmd_obj = new SqlCommand("OPAPP_PROC_GetUserDeviceLoginStatus", sqlconn_obj)) { sqlcmd_obj.CommandType = CommandType.StoredProcedure; sqlcmd_obj.Parameters.AddWithValue("@UserName", objUser.UserName); sqlcmd_obj.Parameters.AddWithValue("@Password", pwd); sqlcmd_obj.Parameters.AddWithValue("@LoginDeviceID", objUser.LoginDeviceID); sqlconn_obj.Open(); SqlDataAdapter sqldap = new SqlDataAdapter(sqlcmd_obj); DataTable resultdt = new DataTable(); sqldap.Fill(resultdt); if (resultdt.Rows.Count > 0) { resultmsg = "Please check user already logged in another device"; } } } } catch (Exception ex) { objExceptionlog.InsertException("WebAPI", ex.Message, "DALUserLoginVerification", "Proc: " + "OPAPP_PROC_GetUserDeviceLoginStatus", "GetUserDeviceLoginStatus"); throw; } return(resultmsg); }
public ShowUserInformation UserLogin(LoginModel data) { SqlConnection connection = DatabaseConnection(); try { SqlCommand command = StoredProcedureConnection("spLoginUser", connection); command.Parameters.Add("@EmailID", SqlDbType.VarChar, 50).Value = data.EmailID; command.Parameters.Add("@Password", SqlDbType.VarChar, 50).Value = PasswordEncryptDecrypt.EncodePasswordToBase64(data.Password); connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.Read() == false) { return(null); } else { return(new ShowUserInformation { Id = reader.GetInt32(0), EmailID = reader.GetString(1), UserName = reader.GetString(3), RegistationDate = reader.GetDateTime(4).ToString() }); } } catch (Exception exception) { throw new Exception(exception.Message); } finally { connection.Close(); } }
public User GetLoginUserDetails(UserLogin objUser) { User objOutPutuser = new User(); objencrypt = new DataEncryptDecrypt(); objpwdencrypt = new PasswordEncryptDecrypt(); string resultMsg = string.Empty; string encryptKey = string.Empty; try { string resultkey = getEncryptdata(objUser.UserName); string pwd = objpwdencrypt.Encrypt(objUser.Password, resultkey); using (SqlConnection sqlconn_obj = new SqlConnection(SqlHelper.GetDBConnectionString())) { using (SqlCommand sqlcmd_obj = new SqlCommand("OPAPP_PROC_LoginVerification", sqlconn_obj)) { sqlcmd_obj.CommandType = CommandType.StoredProcedure; sqlcmd_obj.Parameters.AddWithValue("@USERNAME", objUser.UserName); sqlcmd_obj.Parameters.AddWithValue("@PASSWORD", pwd); sqlcmd_obj.Parameters.AddWithValue("@Lattitude", objUser.Latitude); sqlcmd_obj.Parameters.AddWithValue("@Longitude", objUser.Longitude); sqlconn_obj.Open(); SqlDataAdapter sqldap = new SqlDataAdapter(sqlcmd_obj); DataTable resultdt = new DataTable(); sqldap.Fill(resultdt); if (resultdt.Rows.Count > 0) { objOutPutuser.UserName = Convert.ToString(resultdt.Rows[0]["USERNAME"]); objOutPutuser.UserCode = Convert.ToString(resultdt.Rows[0]["UserCode"]); objOutPutuser.UserID = resultdt.Rows[0]["UserID"] == DBNull.Value ? 0 : Convert.ToInt32(resultdt.Rows[0]["UserID"]); objOutPutuser.UserTypeID.UserTypeID = resultdt.Rows[0]["UserTypeID"] == DBNull.Value ? 0 : Convert.ToInt32(resultdt.Rows[0]["UserTypeID"]); objOutPutuser.LocationParkingLotID.LocationParkingLotID = resultdt.Rows[0]["LocationParkingLotID"] == DBNull.Value ? 0 : Convert.ToInt32(resultdt.Rows[0]["LocationParkingLotID"]); objOutPutuser.LocationParkingLotID.LocationParkingLotName = Convert.ToString(resultdt.Rows[0]["LocationParkingLotName"]); objOutPutuser.LocationParkingLotID.LocationParkingLotCode = Convert.ToString(resultdt.Rows[0]["LocationParkingLotCode"]); objOutPutuser.LocationParkingLotID.LocationID.LocationID = resultdt.Rows[0]["LocationID"] == DBNull.Value ? 0 : Convert.ToInt32(resultdt.Rows[0]["LocationID"]); objOutPutuser.LocationParkingLotID.LocationID.LocationName = Convert.ToString(resultdt.Rows[0]["LocationName"]); objOutPutuser.UserTypeID.UserTypeName = Convert.ToString(resultdt.Rows[0]["UserTypeName"]); objOutPutuser.LocationParkingLotID.Lattitude = Convert.ToDecimal(objUser.Latitude); objOutPutuser.LocationParkingLotID.Longitude = Convert.ToDecimal(objUser.Longitude); objOutPutuser.PhoneNumber = Convert.ToString(resultdt.Rows[0]["PhoneNumber"]); objOutPutuser.LoginTime = DateTime.Now; objOutPutuser.LoginDeviceID = objUser.LoginDeviceID; objOutPutuser.Photo = resultdt.Rows[0]["Photo"] == DBNull.Value ? null : (byte[])resultdt.Rows[0]["Photo"]; List <LocationParkingLot> lstLocationParkingLots = GetLoginUserAllocatedLocationLots(objOutPutuser); if (lstLocationParkingLots.Count > 0) { LocationParkingLot userlot = lstLocationParkingLots[0]; objOutPutuser.LocationParkingLotID.LotCloseTime = userlot.LotCloseTime; objOutPutuser.LocationParkingLotID.LotOpenTime = userlot.LotOpenTime; if (resultdt.Rows[0]["LocationParkingLotID"] == DBNull.Value) { objOutPutuser.LocationParkingLotID.LocationParkingLotID = userlot.LocationParkingLotID; objOutPutuser.LocationParkingLotID.LocationParkingLotName = userlot.LocationParkingLotName; objOutPutuser.LocationParkingLotID.LocationID.LocationID = userlot.LocationID.LocationID; objOutPutuser.LocationParkingLotID.LocationID.LocationName = userlot.LocationID.LocationName; } DALLocationLot dalLocation = new DALLocationLot(); var lotavilability = dalLocation.GetLocationLotVehicleAvailabilityDetails(userlot.LocationID.LocationID, userlot.LocationParkingLotID); objOutPutuser.LocationParkingLotID.LotVehicleAvailabilityName = lotavilability.LotVehicleAvailabilityName; } } } } } catch (Exception ex) { objExceptionlog.InsertException("WebAPI", ex.Message, "DALUserLoginVerification", "Proc: " + "OPAPP_PROC_LoginVerification", "GetLoginUserDetails"); throw; } return(objOutPutuser); }