예제 #1
0
 public ActionResult BuyCard(FormCollection f)
 {
     bizUsers bu = new bizUsers();
     bizCard bc = new bizCard();
     bizUserXCard buc = new bizUserXCard();
     Card cmodel = bc.Get(f["cardName"]);
     Users umodel = bu.Get(UserID);
     if (cmodel.AllowBuy != 1)
         return Content("�õ����޷�����");
     if (umodel.Jinbi < int.Parse(f["cardNum"]) * cmodel.Price)
         return Content("��İɱҲ������޷�����");
     buc.BuyCard(UserID, f["cardName"], int.Parse(f["cardNum"]));
     return Content("�ɹ�������" + f["cardNum"] + "��"+cmodel.CardAlias);
 }
예제 #2
0
        public ActionResult SelfBuyCard(FormCollection f)
        {
            int userID = UserID;
            bizUsers model = new bizUsers();
            bizUserXCard bc = new bizUserXCard();

            for (int i = 0; i < f.Count; i++)
            {
                if (int.Parse(f[i]) < 0)
                {
                    TempData["Msg"] = "����ȷ���뿨Ƭ��";
                    return RedirectToAction("SelfBuyCard");
                }
            }

            Users user = model.Get(userID);
            if (user.Jinbi < GetCardPrice(f))
                TempData["Msg"] = "��Ҳ������޷�����";
            else
            {
                for (int i = 0; i < f.Count; i++)
                {
                    if (int.Parse(f[i]) > 0)
                        bc.BuyCard(userID, f.AllKeys[i].Trim(), int.Parse(f[i]));
                }
                TempData["Msg"] = "����ɹ�";
            }

            return RedirectToAction("SelfBuyCard");
        }