public ActionResult Create(Booking booking, int id)
        {
            //Checking if all values are filled
            if (booking.Address == null || booking.Postcode == null || booking.City == null
                || booking.EmailAddress == null || booking.InvoiceAddress == null || booking.AccountNumber == null
                || booking.StartDate == null || booking.EndDate == null)
            {
                ViewData["error"] = "Please completely fill in the form";
                return View(booking);
            }

            //Checking if the startdate isn't greater than the enddate
            if (booking.StartDate > booking.EndDate)
            {
                ViewData["errorDate"] = "Please enter a correct date";
                return View(booking);
            }

            if (ModelState.IsValid)
            {
                Room room = db.Rooms.Find(id);

                double totalPrice = PriceCalculator.CalculateTotalPrice(room, booking.StartDate.Value.Month);

                booking.Username = db.Users.Find(User.Identity.Name).Username;
                int newID = db.Bookings.Max(b => b.ID) + 1;
                booking.ID = newID;
                booking.TotalPrice = Convert.ToInt32(totalPrice);
                booking.BookingStatus_name = "reserved";

                List<Guest> GuestList = new List<Guest>();
                for (int i = 0; i < room.NumberOfPersons; i++)
                    try
                    {
                        Guest g = new Guest();
                        g.FirstName = "default";
                        g.Lastname = "default";
                        g.Gender = "/";
                        g.ID = (db.Guests.Max(gg => gg.ID) + i) + 1;
                        g.Bookings.Add(booking);
                        db.Guests.Add(g);
                        booking.Guests.Add(g);
                    }
                    catch (DbEntityValidationException e)
                    {
                        throw e;
                    }

                db.Bookings.Add(booking);
                db.SaveChanges();
                return RedirectToAction("PriceOverview", booking);
            }

            ViewBag.BookingStatus_name = new SelectList(db.BookingStatus, "Name", "Name", booking.BookingStatus_name);
            ViewBag.Username = new SelectList(db.Users, "Username", "Password", booking.Username);
            return View(booking);
        }
        public ViewResult PriceOverview(Booking booking)
        {
            ViewBag.YEN = PriceCalculator.ConvertPriceToYen(booking.TotalPrice);
            ViewBag.USD = PriceCalculator.ConvertPriceToUSD(booking.TotalPrice);

            return View(booking);
        }
 public ActionResult Edit(Booking booking)
 {
     if (ModelState.IsValid)
     {
         booking.Username = db.Users.Find(User.Identity.Name).Username;
         db.Entry(booking).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("BookingOverview");
     }
     ViewBag.BookingStatus_name = new SelectList(db.BookingStatus, "Name", "Name", booking.BookingStatus_name);
     ViewBag.Username = new SelectList(db.Users, "Username", "Password", booking.Username);
     return View(booking);
 }