Пример #1
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Ride).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RideExists(Ride.RideID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Пример #2
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.restaurant_reservation.Add(restaurant_reservation);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Пример #3
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Ride.Add(Ride);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Пример #4
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Ride = await _context.Ride.FindAsync(id);

            if (Ride != null)
            {
                _context.Ride.Remove(Ride);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Пример #5
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            restaurant_reservation = await _context.restaurant_reservation.FindAsync(id);

            if (restaurant_reservation != null)
            {
                _context.restaurant_reservation.Remove(restaurant_reservation);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            //added
            int totalminutescheck = 0;

            ClaimsPrincipal currentUser   = this.User;
            var             currentUserID = currentUser.FindFirst(ClaimTypes.NameIdentifier).Value;

            restaurant_reservation2 = await _context.restaurant_reservation
                                      .Include(r => r.user)
                                      .Include(r => r.Restaurant)
                                      .Where(m => m.NewUserID == currentUserID)
                                      //.Include(m => m.NewUserID == currentUserID)
                                      .ToListAsync();

            //account for the fact that there are no previous reservations.
            if (restaurant_reservation2.Count < 1)
            {
                totalminutescheck = 100; //make it bigger than 30 so that it can add
            }
            foreach (var p in restaurant_reservation2)
            {
                DateTime date1 = p.DateAndTime;  //loop through the list and grab the date and time
                DateTime date2 = restaurant_reservation.DateAndTime;
                System.Diagnostics.Debug.WriteLine(date2);

                //int result = DateTime.Compare(date1, date2);

                TimeSpan diffresult = date2.Subtract(date1);

                int hours          = int.Parse(diffresult.Hours.ToString());
                int hourstominutes = hours * 60;
                int minutes        = int.Parse(diffresult.Minutes.ToString());
                int totalminutes   = hourstominutes + minutes;
                totalminutescheck = Math.Abs(totalminutes);
                System.Diagnostics.Debug.WriteLine(totalminutescheck);

                if (totalminutescheck < 30)
                {
                    System.Diagnostics.Debug.WriteLine("Less than 30 minutes");
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("greater than 30 minutes");
                }
            }

            if (!ModelState.IsValid || totalminutescheck < 30)
            {
                System.Diagnostics.Debug.WriteLine(globalRestaurantUrl);
                ViewData["DisplayError"]       = "Reservations must be greater than 30 minutes apart.  Please choose another time.";
                ViewData["RestaurantImageUrl"] = globalRestaurantUrl;
                ViewData["RestaurantID"]       = globalRestaurantID;
                ViewData["UserID"]             = globalUserID;
                ViewData["RestaurantName"]     = globalRestaurantName;

                return(Page());
            }

            _context.restaurant_reservation.Add(restaurant_reservation);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Reports/Index"));
        }