public void SetRiderEquipment(UserRider rider, TurboTrainer turbo) { string userId = Context.User.Identity.Name; rider.SaveEquipment(userId); if (turbo != null) { turbo.Save(userId); } // This may have changed the configuration - kill the existing processor CycliManager.Instance.Kill(userId); }
public static UserRider Load(string userId) { UserRider thisRider = null; SQLiteDatabase db = new SQLiteDatabase(); string sql = @"select r.UserId, r.FirstName, r.Surname, r.Username, r.Email, r.Nationality, n.Flag, r.DoB, r.Sex, r.BikeWheelSizeMm, r.Turbo, " + "r.TurboIsCalibrated, r.EstimatedPower,r.HrAsPercentage, r.MaxHr, r.MaxHrFromAge, r.HeightCm, r.WeightKg, r.ThresholdPower, r.FriendCode, r.AccountType " + "From cycli_riders r LEFT OUTER JOIN cycli_nationalities n " + "ON r.Nationality = n.Nationality " + "where UserId=@u and AccountStatus='Active'"; // Only load active accounts DataTable dtUser = db.GetDataTable(sql, "@u", userId); if (dtUser.Rows.Count > 0) { DataRow dr = dtUser.Rows[0]; thisRider = new UserRider(); thisRider.FirstName = dr["FirstName"] == DBNull.Value ? "" : dr.Field<string>("FirstName"); thisRider.Surname= (dr["Surname"] == DBNull.Value ? "" : dr.Field<string>("Surname")); thisRider.UserName = dr.Field<string>("Username"); thisRider.UserId= dr.Field<string>("UserId"); thisRider.Email = dr.Field<string>("Email"); thisRider.Nationality = dr.Field<string>("Nationality"); thisRider.FlagFile = dr["Flag"] == DBNull.Value ? "" :dr.Field<string>("Flag"); thisRider.DoB = dr.Field<long>("DoB"); thisRider.IsMale = dr.Field<string>("Sex") == bool.TrueString; thisRider.BikeWheelSizeMm = (int)dr.Field<long>("BikeWheelSizeMm"); thisRider.CurrentTurbo = dr.Field<string>("Turbo"); thisRider.TurboIsCalibrated = (dr.Field<string>("TurboIsCalibrated") == bool.TrueString); thisRider.EstimatedPower = (dr.Field<string>("EstimatedPower") == bool.TrueString); thisRider.HrAsPercentage = dr.Field<long>("HrAsPercentage") == 1; thisRider.MaxHr = (int)dr.Field<long>("MaxHr"); thisRider.MaxHrFromAge = dr.Field<long>("MaxHrFromAge") == 1; thisRider.HeightCm = (int)dr.Field<long>("HeightCm"); thisRider.WeightKg = (int)dr.Field<long>("WeightKg"); thisRider.ThresholdPower = (int)dr.Field<long>("ThresholdPower"); thisRider.FriendCode = dr.Field<string>("FriendCode"); thisRider.AccountType = dr.Field<string>("AccountType"); thisRider.MaximumRiders = thisRider.AccountType == @"FREE" ? Properties.Settings.Default.MAX_RIDERS_FREE : Properties.Settings.Default.MAX_RIDERS_PREMIUM; thisRider.MaximumFriends = thisRider.AccountType == @"FREE" ? Properties.Settings.Default.MAX_FRIENDS_FREE : Properties.Settings.Default.MAX_FRIENDS_PREMIUM; thisRider.MaximumRaces = thisRider.AccountType == @"FREE" ? Properties.Settings.Default.MAX_RACES_FREE : Properties.Settings.Default.MAX_RACES_PREMIUM; thisRider.MaximumVirtualRiders = thisRider.AccountType == @"FREE" ? Properties.Settings.Default.MAX_VIRTUAL_RIDERS_FREE : Properties.Settings.Default.MAX_VIRTUAL_RIDERS_PREMIUM; } db.Close(); return thisRider; }
public void SetRiderDetails(UserRider rider) { string userId = Context.User.Identity.Name; rider.SaveDetails(userId); // This may have changed the configuration - kill the existing processor CycliManager.Instance.Kill(userId); }