public bool UpdateGame(GameVM vm) { using (PlayContext context = new PlayContext()) { try { Game game = context.Games.Single(x => x.ID == vm.Game.ID); Location loc = new Entities.Location(); game.Name = vm.Game.Name; game.Type = vm.Game.Type; game.Description = vm.Game.Description; game.Start = vm.Game.Start; game.End = vm.Game.End; game.Modified = DateTime.Now; loc.Name = vm.Game.Location.Name; loc.Coordinates = CreatePoint(vm.Latitude, vm.Longitude); game.Location = loc; context.SaveChanges(); return(true); } catch (Exception e) { return(false); } } }
public bool DeleteGame(int id) { using (PlayContext context = new PlayContext()) { try { Game game = context.Games.Single(x => x.ID == id); context.Games.Remove(game); context.SaveChanges(); return(true); } catch (Exception e) { return(false); } } }