コード例 #1
0
 public ActionResult AddToCard(Card card, string add)
 {
     if (ModelState.IsValid)
     {
         if (string.IsNullOrEmpty(add))
             return RedirectToAction("AddToCard");
         Card old = db.GetCard(card.CardId);
         double money = Convert.ToDouble(add);
         double mmoneyToCard = (double)old.Amount;
         if (mmoneyToCard >= 500 && mmoneyToCard <= 2000)
             money *= 0.98;
         if (mmoneyToCard >= 2000.01 && mmoneyToCard <= 5000)
             money *= 0.95;
         if (mmoneyToCard >= 5000.01)
             money *= 0.93;
         card.Amount += (decimal)money;
         old.Amount += card.Amount;
         db.SaveCard(old);
         return RedirectToAction("Index");
     }
     else
     {
         return View();
     }
 }
コード例 #2
0
        public ActionResult Create(Card card, string add)
        {
            if (String.IsNullOrEmpty(add))
                return RedirectToAction("Create");
                if (ModelState.IsValid)
                {
                    double money = Convert.ToDouble(add);
                    if (money >= 200)
                    {
                        card.Amount = (decimal)money;
                        db.Save(card);
                    }
                    return RedirectToAction("Index");
                }
                else
                {
                    return View();
                }

            return View(card);
        }
コード例 #3
0
ファイル: DataManager.cs プロジェクト: PrinceGosplana/Cards
 public void SaveCard(Card obj)
 {
     Card old = GetCard(obj.CardId);
     old.Amount = obj.Amount;
     _db.SaveChanges();
 }
コード例 #4
0
ファイル: DataManager.cs プロジェクト: PrinceGosplana/Cards
 public void Save(Card obj)
 {
     _db.AddToCards(obj);
     _db.SaveChanges();
 }
コード例 #5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Cards EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCards(Card card)
 {
     base.AddObject("Cards", card);
 }
コード例 #6
0
 /// <summary>
 /// Create a new Card object.
 /// </summary>
 /// <param name="cardId">Initial value of the CardId property.</param>
 /// <param name="amount">Initial value of the Amount property.</param>
 public static Card CreateCard(global::System.Int32 cardId, global::System.Decimal amount)
 {
     Card card = new Card();
     card.CardId = cardId;
     card.Amount = amount;
     return card;
 }
コード例 #7
0
        public ActionResult SaveToPDF(Card cart)
        {
            var cardSearch = from card in db.GetCards() select card;
            ViewBag.CountCard = cardSearch.Count();
            var topCard = cardSearch.OrderByDescending(c => c.Amount).Take(5).ToList();
            String htmlText = "<br><br><h1><font  " +
                             " color=\"#0000FF\"><b><i>Top 5 cards   " +
                             " </i></b></font> </h1><br>" +
                             "<table border='1' bgcolor='#999777'>" +
                             "<tr><th style='color:white; text-align:center' width='20%'>Card number</th>" +
                             "<th style='color:white;text-align:center;width:80%'>Amount</th></table>";
            String ja = " ";
            bool prov = true;
            foreach (Card card in topCard)
            {
                if (prov)
                {
                    String lines = "<table><tr><td style='text-align:center' border='1' bgcolor='#d1d1d1' width='20%'>" +
                                            card.CardId +
                                        "</td><td style='text-align:center'border='1' bgcolor='#d1d1d1' width='80%'>" +
                                            card.Amount +
                                        "</td></tr></table>";
                    ja += lines;
                    prov = false;
                }
                else
                {
                    String lines = "<table><tr><td style='text-align:center' border='1' bgcolor='#afafaf' width='20%'>" +
                                            card.CardId +
                                        "</td><td style='text-align:center'border='1' bgcolor='#afafaf' width='80%'>" +
                                            card.Amount +
                                        "</td></tr></table>";
                    ja += lines;
                    prov = true;
                }
            }

            htmlText += ja;
            HTMLToPdf(htmlText, "PDFfile.pdf");
            return RedirectToAction("Index");
        }