示例#1
0
        public ActionResult DeleteConfirmed(string id)
        {
            Comedy comedy = db.Comedies.Find(id);

            db.Comedies.Remove(comedy);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#2
0
 public ActionResult Edit([Bind(Include = "MovieName,ReleaseDate,Description")] Comedy comedy)
 {
     if (ModelState.IsValid)
     {
         db.Entry(comedy).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(comedy));
 }
示例#3
0
        public ActionResult Create([Bind(Include = "MovieName,ReleaseDate,Description")] Comedy comedy)
        {
            if (ModelState.IsValid)
            {
                db.Comedies.Add(comedy);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(comedy));
        }
示例#4
0
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Comedy comedy = db.Comedies.Find(id);

            if (comedy == null)
            {
                return(HttpNotFound());
            }
            return(View(comedy));
        }
        public string Run(JObject invoice, JObject plays)
        {
            var totalAmount   = 0;
            var volumeCredits = 0;
            var result        = $"Statement for {invoice.GetValue("customer")}\n";
            var cultureInfo   = new CultureInfo("en-US");

            foreach (JObject performace in invoice.GetValue("performances"))
            {
                var play       = (JObject)plays.GetValue(performace.GetValue("playID").ToString());
                var thisAmount = 0;
                switch (play.GetValue("type").ToString())
                {
                case "tragedy":
                    var tragedy      = new Tragedy();
                    var performance1 = new Performance(tragedy, Convert.ToInt32(performace.GetValue("audience")));
                    thisAmount = performance1.CalculatePlayCost();
                    break;

                case "comedy":
                    var comedy       = new Comedy();
                    var performance2 = new Performance(comedy, Convert.ToInt32(performace.GetValue("audience")));
                    thisAmount = performance2.CalculatePlayCost();
                    break;

                default:
                    throw new Exception($"unknown type: { play.GetValue("type").ToString()}");
                }
                // add volume credits
                volumeCredits += Math.Max(Convert.ToInt32(performace.GetValue("audience")) - 30, 0);
                // add extra credit for every ten comedy attendees
                if ("comedy" == play.GetValue("type").ToString())
                {
                    volumeCredits += Convert.ToInt32(performace.GetValue("audience")) / 5;
                }
                // print line for this order
                result      += $" {play.GetValue("name")}: {(thisAmount/100).ToString("C", cultureInfo)} ({performace.GetValue("audience")} seats)\n";
                totalAmount += thisAmount;
            }
            result += $"Amount owed is {(totalAmount/100).ToString("C", cultureInfo)}\n";
            result += $"You earned {volumeCredits} credits\n";

            return(result);
        }