public static ViewHotelOrderVM returnHotel(Order order) { ViewHotelOrderVM ovm = new ViewHotelOrderVM(); DataLayer dl = new DataLayer(); ovm.invoice = order.InvoiceNumber; ovm.creditCardNumber = order.CreditCard; HotelOrder hotelorder = (from x in dl.hotelOrders where x.InvoiceID == ovm.invoice select x).ToList <HotelOrder>().FirstOrDefault(); ovm.hotelName = hotelorder.HotelName; ovm.startDate = hotelorder.StartDate; ovm.endDate = hotelorder.EndDate; ovm.orderDate = order.OrderDate; ovm.status = order.Status; ovm.email = order.CustomerEmail; Customer cust = (from x in dl.customers where x.Email == ovm.email select x).ToList <Customer>().FirstOrDefault(); ovm.customerName = cust.FullName; ovm.customerId = cust.ID; List <HotelOrderDetails> hod = (from x in dl.hotelOrderDetails where x.Invoice == ovm.invoice select x).ToList <HotelOrderDetails>(); ovm.totalPrice = order.TotalPayment; //ovm.rooms = null; ovm.numberOfRooms = hod.Count; List <RoomVM> rooms = new List <RoomVM>(); for (int i = 0; i < hod.Count; ++i) { RoomVM r = new RoomVM() { roomComposition = hod[i].RoomComposition, roomPrice = hod[i].PaymentForRoom, roomDescription = hod[i].RoomType }; rooms.Add(r); } ovm.rooms = rooms; return(ovm); }
// ----------------------------- this view is only for static run (TEMP VIEW) public ActionResult ViewOrder() { List <RoomVM> roomsList = new List <RoomVM>(); RoomVM tempRoom1 = new RoomVM() { roomDescription = "bla bla bla", roomComposition = "Single", roomPrice = 256.12, }; RoomVM tempRoom2 = new RoomVM() { roomDescription = "what are you saying to me?", roomComposition = "Adult + Child", roomPrice = 812.10, }; roomsList.Add(tempRoom1); roomsList.Add(tempRoom2); ViewHotelOrderVM viewHotelOrder = new ViewHotelOrderVM() { creditCardNumber = "1111222233334444", customerId = "123456789", customerName = "Daniel Mashukov", email = "*****@*****.**", startDate = "15.06.2018", endDate = "18.06.2018", //hotelAddress = "Galatea 6 Madrid", hotelName = "Globales Acis Y Galatea", invoice = 12, orderDate = "08.04.2018", status = 0, totalPrice = 1560.2, rooms = roomsList }; return(RedirectToAction("ViewOrderReceipt", "Support", viewHotelOrder)); }