Esempio n. 1
0
 /// <summary>
 /// Adds the shop item.
 /// </summary>
 /// <param name="shopItem">The item.</param>
 /// <returns></returns>
 public Overview AddShopItem(ShopItem shopItem)
 {
     if (ItemExistsInShop(shopItem.ItemId, shopItem.ShopId))
     {
         UpdateShopItem();
     }
     else
     {
         shopItems.Add(shopItem);
     }
     return this;
 }
Esempio n. 2
0
 /// <summary>
 /// Inserts the shop item.
 /// </summary>
 /// <param name="shopItem">The shop item.</param>
 /// <returns><c>true</c> on success.</returns>
 public bool InsertShopItem(ShopItem shopItem)
 {
     Log.DebugFormat("InsertShopItem '{0}'", shopItem);
     using (dbConnection)
     {
         using (DbCommand dbCommand = dbConnection.CreateCommand())
         {
             dbConnection.Open();
             string commandText = String.Format(CultureInfo.InvariantCulture,
                                                "INSERT INTO ShopItems (Item, Shop, DateTime, Price, NumberOfItems, Id) VALUES('{0}', '{1}', '{2}', '{3}', {4}, '{5}')",
                                                shopItem.ItemId, shopItem.ShopId,
                                                shopItem.DateTime.ToString(DateTimeFormatProvider),
                                                shopItem.PriceId, shopItem.NumberOfItems, shopItem.Id);
             Log.Debug(commandText);
             dbCommand.CommandText = commandText;
             if (dbCommand.ExecuteNonQuery() == 1)
             {
                 return true;
             }
             Log.ErrorFormat("Failed to insert shopItem [{0}]", shopItem);
             return false;
         }
     }
 }
Esempio n. 3
0
 public Tracker(ShopItem shopItem)
 {
     Id = Guid.NewGuid();
     ShopItemId = shopItem.Id;
     DateTime = new DateTime(DateTime.Now.Ticks);
 }
Esempio n. 4
0
 public static List<ShopItem> ParseShopItems(this List<ShopItem> shopItems, DataRowCollection collection)
 {
     Log.DebugFormat("ParseShopItems with DataRowCollection.Count={0}. shopItems.Count={1}", collection.Count,
                     shopItems.Count);
     foreach (DataRow row in collection)
     {
         string itemId = row.ItemArray.GetValue(8).ToString();
         string shopId = row.ItemArray.GetValue(7).ToString();
         if (itemId.Length < 32 || shopId.Length < 32)
         {
             Log.Debug("itemId or shopId not set...");
             continue;
         }
         ShopItem currentShopItem = new ShopItem
             {
                 DateTime = DateTime.Parse(row.ItemArray.GetValue(0).ToString()),
                 NumberOfItems = String2Number(row.ItemArray.GetValue(1).ToString()),
                 Id = new Guid(row.ItemArray.GetValue(9).ToString()),
                 ItemId = new Guid(itemId),
                 ShopId = new Guid(shopId),
                 PriceId = new Guid(row.ItemArray.GetValue(6).ToString()),
             };
         Log.DebugFormat("Adding shop item [{0}]", currentShopItem);
         shopItems.Add(currentShopItem);
     }
     return shopItems;
 }