Beispiel #1
0
 protected void BuyBtn_Click(object sender, EventArgs e)
 {
     if (Session["Item"] is Items)
     {
         Items item = Session["Item"] as Items;
         System.Diagnostics.Debug.WriteLine("Item ID: " + item.ItemId);
         int usercoins = CurrentUser.Entity().Coins;
         if (usercoins < item.ItemPrice)
         {
         }
         else
         {
             using (DataContext db = new DataContext())
             {
                 Users u = CurrentUser.Entity(false, db);
                 u.Coins = u.Coins - item.ItemPrice;
                 db.SaveChanges();
             }
             ItemLogic.AddItemToInventory(CurrentUser.Entity(), item.ItemId);
             ItemNameLbl.Text  = item.ItemName;
             ItemPriceLbl.Text = item.ItemPrice.ToString();
             ScriptManager.RegisterStartupScript(this, this.GetType(), "PartTransactionModel", "ShowTransactionBox();", true);
         }
     }
     else
     {
         Response.Redirect("Parts.aspx", true);
     }
 }