public HttpResponseMessage PostCartModel([FromBody]List<SetGameDTO> games)
        {
            if (ModelState.IsValid)
            {
                if (games.Count > 0)
                {
                    var headers = Request.Headers;
                    var userID = Convert.ToInt32(headers.Where(m => m.Key == "xcmps383authenticationid").First().Value.First());
                    if (!(db.Carts.Where(m => m.User_Id == userID && m.CheckoutReady == true).Count() > 0))
                    {
                        List<GameModel> gamelist = new List<GameModel>();
                        foreach (var item in games)
                        {
                            GameModel TheGame;
                            try
                            {
                                TheGame = Factory.Parse(item);
                            }
                            catch
                            {
                                return Request.CreateResponse(HttpStatusCode.BadRequest, "Coud not read one or more games from body of request");
                            }
                            var game = db.Games.FirstOrDefault(m => m.GameName == TheGame.GameName);
                            if (game == null)
                            {
                                return Request.CreateResponse(HttpStatusCode.BadRequest, "One or more games could not be found");
                            }
                            gamelist.Add(game);
                        }
                        CartModel cart = new CartModel()
                                            {
                                                CheckoutReady = true,
                                                User_Id = userID,
                                                Games = new List<CartGameQuantities>()
                                            };
                        foreach (var item in gamelist)
                        {
                            bool found = false;
                            foreach (var game in cart.Games)
                            {
                                if (game.Game == item)
                                {
                                    game.Quantity++;
                                    found = true;
                                    break;
                                }
                            }
                            if (!found)
                            {
                                cart.Games.Add(new CartGameQuantities() { Cart = cart, Game = item, Quantity = 1 });
                            }
                        }
                        try
                        {
                            db.Carts.Add(cart);
                            db.SaveChanges();
                            return Request.CreateResponse(HttpStatusCode.OK, Factory.Create(cart));
                        }
                        catch (DbUpdateConcurrencyException ex)
                        {
                            return Request.CreateResponse(HttpStatusCode.InternalServerError, ex);
                        }
                    }
                    else
                    {
                        return Request.CreateResponse(HttpStatusCode.BadRequest, "User already has an active cart");
                    }

                }
                else
                {
                    return Request.CreateResponse(HttpStatusCode.NotFound, "Games not found");
                }
            }
            else
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }
        }
        public GameModel Parse(SetGameDTO game)
        {
            GameModel ret = new GameModel()
            {
                GameName = game.GameName,
                ReleaseDate = game.ReleaseDate,
                InventoryStock = game.InventoryStock,
                Price = game.Price,
                Genres = new List<GenreModel>(),
                Tags = new List<TagModel>()
            };
            CartModel varus = new CartModel();

            foreach (var item in game.Genres)
            {
                ret.Genres.Add(Parse(item));
            }

            foreach (var item in game.Tags)
            {
                ret.Tags.Add(Parse(item));
            }

            return ret;
        }
        public CartModel Parse(SetCartDTO cart)
        {
            CartModel ret = new CartModel()
            {
                User_Id = cart.User_Id,
                Games = new List<CartGameQuantities>()
            };

            foreach (var item in cart.Games)
            {
                ret.Games.Add(new CartGameQuantities()
                {
                    Game = Parse(item.Item1),
                    Quantity = item.Item2
                }
                );
            }

            return ret;
        }
        public GetCartDTO Create(CartModel cart)
        {
            GetCartDTO retu = new GetCartDTO()
            {
                URL = urlHelper.Link("CartRoute", new { id = cart.Id }),
                CheckoutReady = cart.CheckoutReady,
                User_Id = cart.User_Id,
                Games = new List<Tuple<GetGameDTO, int>>()
            };

            foreach (var item in cart.Games)
            {
                retu.Games.Add(Tuple.Create(Create(item.Game), item.Quantity));
            }
            return retu;
        }