Exemplo n.º 1
0
        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);
                }
            }
        }
Exemplo n.º 2
0
 public List <Game> GetAll()
 {
     using (PlayContext context = new PlayContext())
     {
         List <Game> list = context.Games
                            .Include("Location")
                            .Include("Attendance")
                            .ToList();
         return(list);
     }
 }
Exemplo n.º 3
0
        public Game GetByID(int id)
        {
            using (PlayContext context = new PlayContext())
            {
                var game = context.Games
                           .Include("Location")
                           .Include("Attendance")
                           .FirstOrDefault(x => x.ID == id);

                return(game);
            }
        }
Exemplo n.º 4
0
 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);
         }
     }
 }