public ParkingLocation GetUserParkingLocation(string userId) { ParkingLocation parkingLocation = null; try { using (SqlCommand cmd = new SqlCommand(StoredProcedures.SPR_GET_USER_PARKING_LOCATION, _connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@UserId", SqlDbType.VarChar).Value = userId; SqlDataReader dr = cmd.ExecuteReader(); if (dr != null) { if (dr.HasRows) { if (dr.Read()) { parkingLocation = new ParkingLocation(); parkingLocation.Latitude = dr["Latitude"].ToString(); parkingLocation.Longitude = dr["Longitude"].ToString(); } } } } } catch (Exception ex) { } return parkingLocation; }
private void SaveParkingLocation() { ParkingLocation parkingLocation = new ParkingLocation(); parkingLocation.Latitude = hiddLatitude.Value; parkingLocation.Longitude = hiddLongitude.Value; parkingLocation.UserId = _userObj.UserId; ParkingLocationBLL parkingLocationBLL = new ParkingLocationBLL(); parkingLocationBLL.UpdateParkingLocation(parkingLocation); }
public bool UpdateParkingLocation(ParkingLocation parkingLocation) { try { using (SqlCommand cmd = new SqlCommand(StoredProcedures.SPR_UPDATE_PARKING_LOCATION, _connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@UserId", SqlDbType.VarChar).Value = parkingLocation.UserId; cmd.Parameters.Add("@Latitude", SqlDbType.VarChar).Value = parkingLocation.Latitude; cmd.Parameters.Add("@Longitude", SqlDbType.VarChar).Value = parkingLocation.Longitude; cmd.ExecuteNonQuery(); return true; } } catch (Exception ex) { return false; } }
public User ValidateUser(string userName, string password) { User validUser = null; try { using (SqlCommand cmd = new SqlCommand(StoredProcedures.SPR_VALIDATE_USER, _connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@UserName", SqlDbType.VarChar).Value = userName; cmd.Parameters.Add("@Password", SqlDbType.VarChar).Value = password; SqlDataReader dr = cmd.ExecuteReader(); if (dr != null) { if (dr.HasRows) { if (dr.Read()) { validUser = new User(); validUser.UserName = dr["UserName"].ToString(); validUser.EmailAddress = dr["EmailAddress"].ToString(); validUser.UserId = dr["UserId"].ToString(); ParkingLocation parkingLocation = new ParkingLocation(); parkingLocation.UserId = dr["UserId"].ToString(); parkingLocation.LocationId = dr["LocationId"].ToString(); parkingLocation.Latitude = dr["Latitude"].ToString(); parkingLocation.Longitude = dr["Longitude"].ToString(); validUser.ParkingLocation = parkingLocation; validUser.ModelId = Convert.ToInt32(dr["ModelId"]); validUser.MakeId = Convert.ToInt32(dr["MakeId"]); validUser.Year = Convert.ToInt32(dr["Year"]); validUser.isAdmin = false; } } } } } catch (Exception ex) { } return validUser; }
public bool UpdateParkingLocation(ParkingLocation parkingLocation) { return new ParkingLocationDAL().UpdateParkingLocation(parkingLocation); }