using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace Services.Controllers
{
    public class GamesController : ApiController
    {
        Console[] Consoles = new Console[]
        {
            new Console { Id = 1, Name = "Xbox One", Price = 1500 },
            new Console { Id = 2, Name = "PS4",  Price = 1250 },
            new Console { Id = 3, Name = "Ps3", Price = 800 }
        };

        Game[] Games = new Game[]
        {
            new Game { Id = 1, Name = "GearsOfWar",ConsoleID= 1 },
            new Game { Id = 2, Name = "HeartStone",  ConsoleID=1 },
            new Game { Id = 3, Name = "Fifa2016", ConsoleID=1 },
            new Game { Id = 4, Name = "Mortal Kombat", ConsoleID=2 },
            new Game { Id = 5, Name = "Street Fighter", ConsoleID=2 },
            new Game { Id = 6, Name = "Hunter", ConsoleID=2 },
            new Game { Id = 7, Name = "Limbo", ConsoleID=3 },
            new Game { Id = 8, Name = "Bridge", ConsoleID=3 },
            new Game { Id = 9, Name = "Shadow Warrior", ConsoleID=3 }
        };

        Shop[] Shops = new Shop[]
       {
            new Shop { Id = 1, Name = "Shopto",GameID= 1 },
            new Shop { Id = 2, Name = "Ebay",  GameID=1 },
            new Shop { Id = 3, Name = "Amazon", GameID=2 },
            new Shop { Id = 4, Name = "Argos", GameID=2 },
            new Shop { Id = 5, Name = "Gamespot", GameID=3 },
            new Shop { Id = 6, Name = "Mall", GameID=3 },
            new Shop { Id = 6, Name = "Virgin", GameID=4 },
            new Shop { Id = 6, Name = "GameShop", GameID=5},
            new Shop { Id = 6, Name = "Virtual Shop", GameID=6 },
            new Shop { Id = 6, Name = "GameLand", GameID=7 },
            new Shop { Id = 6, Name = "Sendit", GameID=8 },
            new Shop { Id = 6, Name = "BuyBuy", GameID=9 }
       };

        // GET api/values
        public IEnumerable<Console> Get()
        {
            return Consoles;
        }

        // GET api/values/5
        public IEnumerable<Game> Get(int id)
        {
            return Games.Where(cat => cat.ConsoleID == id).ToList();
        }        
        public IEnumerable<Shop> GetShops(int GameId)
        {
            return Shops.Where(shp => shp.GameID == GameId).ToList();
        }
    }

    public class Console
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public decimal Price { get; set; }
    }
    public class Game
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public int ConsoleID { get; set; }
    }
    public class Shop
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public int GameID { get; set; }
    }
}
