public IActionResult Reservation(ReservationCreateModel model) { if (ModelState.IsValid) { //setting default values for reservation ReservationCreateModel m = model; m.Status = "Pending"; m.Source = "WebSite"; m.EndTime = model.StartTime.AddHours(1); Customer c = _reservationServices.GetCustomerByEmail(model.Email); List <Customer> Cs = _reservationServices.GetAllRCustomers(); if (Cs.Contains(c)) { model.CustomerID = c.CustomerID; _reservationServices.AddReservationOnly(m); return(RedirectToAction("Done")); } else { _reservationServices.AddCustomerReservation(m); return(RedirectToAction("Done")); } } else { return(View(model)); } }
public async Task <IActionResult> OnGetAsync() { var user = await _userManager.GetUserAsync(User); if (user == null) { return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.")); } Customer c = _services.GetCustomerByEmail(user.Email); try { MyReservations = _context.Reservations.Select(r => new ReservationModel() { //Sitting SittingID = r.SittingID, SittingName = r.Sitting.SittingName, //Reservation ReservationID = r.ReservationID, NumberOfGuests = r.NumberOfGuests, AdditionalRequirements = r.AdditionalRequirements, Date = r.Date, StartTime = r.StartTime, EndTime = r.EndTime, Status = r.Status, //Customer CustomerId = r.Customer.CustomerID, FirstName = r.Customer.FirstName, LastName = r.Customer.LastName, //tables NumberOfTables = r.Table_Reservation.Count, }).Where(r => r.CustomerId == c.CustomerID).OrderByDescending(r => r.Date).ToList(); foreach (var i in MyReservations) { i.Area = _services.GetAreaByID(i.ReservationID); } } catch { MyReservations = new List <ReservationModel>(); } return(Page()); }