public ActionResult GetNewGame(int intensity_level) { using (var context = new IslandEscapeOfficialEntities()) { var new_game = new Game() { IntensityLevel = intensity_level, Start = DateTime.Now }; context.Games.Add(new_game); context.SaveChanges(); return(Json(new_game)); } }
public ActionResult SaveGame(int game_id, string user_id, int progress) { int records = 0; using (var context = new IslandEscapeOfficialEntities()) { var new_game_state = new SavdGameState { GameId = game_id, UserId = user_id, Progress = progress, Saved = DateTime.Now }; context.SavdGameStates.Add(new_game_state); records = context.SaveChanges(); } return(Json(records)); }
/// <summary> /// This function helps build the query part of the URL for the configuration properties. /// </summary> /// <param name="user_id">The UserID</param> /// <returns>A valid URL query part for the names and values of the configuration properties. Append to URL with already at least one name and value.</returns> public static string GetConfigurationURLPart(string user_id) { bool?sound = null; int? brightness = null; using (var context = new IslandEscapeOfficialEntities()) { Configuration config = context.Configurations.Where(c => c.UserId == user_id && c.Chosen).FirstOrDefault(); if (config != null) { sound = config.SoundLevel; brightness = config.BrightnessLevel; } } return("&sound=" + sound + "&brightness=" + (brightness != null ? brightness : 100)); }