private void increaseScorePoint(int p) { long point = dbc.Score.First().Total.Value + p; dbc.Score.First().Total = point; lblMsg.Text = "You have unlocked " + p.ToString() + " points."; dbc.SubmitChanges(); Util.UpdateUnlockCategories(); }
public static bool UpdateUnlockCategories() { bool hasUnlocked = false; Moviadb1DataContext dbc = App.CurrentApp.DB; List <Categories> lockedCats = dbc.Categories.Where(c => c.IsUnlocked == 0).ToList(); foreach (Categories cat in lockedCats) { Score s = dbc.Score.First(); string[] con = cat.UnlockCode.Split('_'); if (con[1] == "P") { int rpoint; int.TryParse(con[0], out rpoint); if (rpoint <= s.Total) { cat.IsUnlocked = 1; hasUnlocked = true; } } else if (con[1] == "G") { int rgames; int.TryParse(con[0], out rgames); if (rgames <= s.TotalGames) { cat.IsUnlocked = 1; hasUnlocked = true; } } } dbc.SubmitChanges(); return(hasUnlocked); }
/// <summary> /// Saves data of the updated question /// </summary> /// public void Save() { dbcontext.SubmitChanges(); }