Example #1
0
 public string?AddGame(Game game)
 {
     try
     {
         dbContent.Games.Add(game);
         dbContent.SaveChanges();
         return(null);
     }
     catch (Exception e)
     {
         return($"{e.Message}\n{e.StackTrace}");
     }
 }
Example #2
0
        private bool TryUpdate(User user)
        {
            try
            {
                dbContent.Users.Update(user);
                dbContent.SaveChanges();
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
Example #3
0
        public void AddItem(string userEmail, string gameUrl)
        {
            CartModel?cart = dbContent.Cart.FirstOrDefault(ci => ci.UserEmail == userEmail);

            if (cart != null)
            {
                dbContent.Cart.Remove(cart);
            }

            dbContent.Cart.Add(new CartModel {
                UserEmail = userEmail,
                GameUrl   = gameUrl
            });

            dbContent.SaveChanges();
        }
Example #4
0
        public void CheckAndUpdateDiscounts()
        {
            DateTime checkTime = new DateTime(
                DateTime.Now.Year,
                DateTime.Now.Month,
                DateTime.Now.Day,
                18,
                0,
                0
                );

            if (DateTime.Now < checkTime)
            {
                return;
            }

            IEnumerable <GameInfo> updatedInfos = dbContent.GameInfos
                                                  .Where(gi => gi.DiscountEndDate != DateTime.MinValue && gi.DiscountEndDate <= DateTime.Now);

            foreach (GameInfo updatedInfo in updatedInfos)
            {
                updatedInfo.Discount        = 0.00f;
                updatedInfo.DiscountEndDate = DateTime.MinValue;
            }

            dbContent.GameInfos.UpdateRange(updatedInfos);
            dbContent.SaveChanges();
        }
Example #5
0
 public void SetFavourite(UserLibraryGame game, bool isFavourite)
 {
     game.IsFavourite = isFavourite;
     dbContent.UserLibraryGames.Update(game);
     dbContent.SaveChanges();
 }