Exemplo n.º 1
0
        public ActionResult GetTotalTable(string tbString)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            var table = serializer.Deserialize<List<TotalRow>>(tbString);

            foreach (var row in table.FindAll(o=>o.People == "Single Supplement"))
            {
                if (table.Any(o => o.Level == row.Level && o.TourId == row.TourId && o.People != "Single Supplement"))
                {
                    table.First(o => o.Level == row.Level && o.TourId == row.TourId).SingleSupplement = row.Price;
                }
                else
                {
                    var newRow = row;
                    newRow.People = "";
                    newRow.SingleSupplement = newRow.Price;
                    newRow.Price = 0;
                }
            }

            table.RemoveAll(o => o.People == "Single Supplement");

            var returnObj = new TotalTable()
            {
                DataRows = table,
                TotalPrice = table.Sum(i => i.Price),
                TotalPriceSingle = table.Sum(u=>u.SingleSupplement),
                StrResultTable = serializer.Serialize(table)
            };

            return PartialView("TotalTable", returnObj);
        }
        public ActionResult DetailsBooked(int id)
        {
            var objData = db.SelectTourBookeds.First(o => o.ID == id);
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            var lstRow = serializer.Deserialize<List<TotalRow>>(objData.Json);

            var table = new TotalTable()
            {
                DataRows = lstRow,
                TotalPrice = lstRow.Sum(i => i.Price)
            };

            var obj = new BookedSelectViewModel()
            {
                objData = objData,
                TotalTable = table
            };
            return View(obj);
        }