Exemplo n.º 1
0
        public ActionResult ViewBookings()
        {
            var booking = _context.MakeBooking;
            var book    = new ViewBooking
            {
                ListBooking = booking.ToList()
            };

            return(View(book));
        }
Exemplo n.º 2
0
        public ActionResult ViewBookings(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            List <ViewBooking> vm = new List <ViewBooking>();
            var list = (from a in db.Booking2
                        join b in db.UserCaterings on a.BookingStatusId equals b.BookingStatusId
                        join c in db.UserDecors on b.BookingStatusId equals c.BookingStatusId
                        join d in db.Payments on c.BookingStatusId equals d.BookingStatusId
                        join e in db.BookingStatus on d.BookingStatusId equals e.BookingStatusId
                        where a.BookingStatusId == id
                        select new
            {
                a.Venue.VenueName, a.Date, a.TotalNumberOfGuests, a.OccasionType, b.Catering.CateringPackage, b.Catering.CateringPrice
                , c.Decor.DecorColourOne, c.Decor.DecorPrice, d.TotalCost, e.Status, a.Venue.VenuePrice
            }).ToList();

            foreach (var item in list)
            {
                ViewBooking vnm = new ViewBooking()
                {
                    date         = item.Date,
                    VenueName    = item.VenueName,
                    VenueCost    = item.VenuePrice,
                    Capacity     = item.TotalNumberOfGuests,
                    eventType    = item.OccasionType,
                    CateringType = item.CateringPackage,
                    cateringCost = item.CateringPrice * item.TotalNumberOfGuests,
                    DecorType    = item.DecorColourOne,
                    decorCost    = item.DecorPrice * item.TotalNumberOfGuests,
                    totalCost    = item.TotalCost,
                    Status       = item.Status
                };
                vm.Add(vnm);
            }

            return(View(vm));
        }