public ActionResult DeleteConfirmed(int id)
        {
            Philanthropist philanthropist = db.Philanthropists.Find(id);

            db.Philanthropists.Remove(philanthropist);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,FundId,Name,Amount,Message")] Philanthropist philanthropist)
 {
     if (ModelState.IsValid)
     {
         db.Entry(philanthropist).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.FundId = new SelectList(db.Funds, "FundId", "Title", philanthropist.FundId);
     return(View(philanthropist));
 }
Exemplo n.º 3
0
        public void TestMethod1()
        {
            var h  = new HomeController();
            var db = new BetterHelpDbEntities();
            var ph = new Philanthropist {
                Amount = 100, FundId = 1, Id = 10, Name = "Андрей", Message = ""
            };

            var result = h.Donate(ph);



            Assert.IsTrue(result is ViewResult);
        }
        // GET: Philanthropists/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Philanthropist philanthropist = db.Philanthropists.Find(id);

            if (philanthropist == null)
            {
                return(HttpNotFound());
            }
            return(View(philanthropist));
        }
        // GET: Philanthropists/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Philanthropist philanthropist = db.Philanthropists.Find(id);

            if (philanthropist == null)
            {
                return(HttpNotFound());
            }
            ViewBag.FundId = new SelectList(db.Funds, "FundId", "Title", philanthropist.FundId);
            return(View(philanthropist));
        }
Exemplo n.º 6
0
        public ActionResult Donate([Bind(Include = "Id,FundId,Name,Amount,Message")] Philanthropist philanthropist)
        {
            if (ModelState.IsValid)
            {
                var fundCollectedAmount = db.Funds.Find(philanthropist.FundId);
                fundCollectedAmount.CollectedAmount = fundCollectedAmount.CollectedAmount + philanthropist.Amount;
                try
                {
                    db.Philanthropists.Add(philanthropist);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                db.SaveChanges();
                return(View("ThankYouPage"));
            }

            return(RedirectToAction("Donate", "Home", new{ fundId = philanthropist.FundId }));
        }