Exemplo n.º 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(Team).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TeamExists(Team.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 2
0
        // To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Teams.Add(Team);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Reservation = await _context.Reservations.FindAsync(id);

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

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Equipment = await _context.Equipments.FindAsync(id);

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

            return(RedirectToPage("../Confirmation"));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> OnPostAsync()
        {
            var emptyRev = new Reservation();

            if (await TryUpdateModelAsync <Reservation>(
                    emptyRev,
                    "reservation",
                    x => x.SpaceID, x => x.PhoneNumber, x => x.FirstName, x => x.LastName, x => x.EndTime, x => x.StartTime))
            {
                _context.Reservations.Add(emptyRev);
                await _context.SaveChangesAsync();

                return(RedirectToPage("../Confirmation"));
            }

            return(Page());      // need to add error messages
        }
Exemplo n.º 6
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Tournament = await _context.Tournaments.FindAsync(id);

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

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 7
0
        // To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD
        public async Task <IActionResult> OnPostAsync()
        {
            var emptyEquipment = new Equipment();

            if (await TryUpdateModelAsync <Equipment>(
                    emptyEquipment,
                    "equipment",
                    s => s.Quantity, s => s.Description, s => s.EquipmentName))
            {
                _context.Equipments.Add(emptyEquipment);
                await _context.SaveChangesAsync();

                return(RedirectToPage("../Confirmation"));
            }

            return(Page());
        }
Exemplo n.º 8
0
        public async Task <IActionResult> OnPostAsync(int id)
        {
            var RentalToUpdate = await _context.Rentals.FindAsync(id);

            if (RentalToUpdate == null)
            {
                return(NotFound());
            }

            if (await TryUpdateModelAsync <Rental>(
                    RentalToUpdate,
                    "Rental",
                    s => s.FirstName, s => s.LastName, s => s.PhoneNumber, s => s.DateFor, s => s.EquipmentID))
            {
                //_context.Rentals.Add(RentalToUpdate);
                await _context.SaveChangesAsync();

                return(RedirectToPage("../Confirmation"));


                /*var quantityLimit = from x in _context.Equipments
                 *                  where x.ID == RentalToUpdate.EquipmentID
                 *                  select x.Quantity;
                 *
                 * var count = from y in _context.Rentals
                 *          where y.DateFor == RentalToUpdate.DateFor && y.EquipmentID == RentalToUpdate.EquipmentID
                 *          select y;
                 *
                 * if (count.Count() > quantityLimit.First())
                 * {
                 *  var temp = from z in _context.Equipments
                 *             where z.ID == RentalToUpdate.EquipmentID
                 *             select z.EquipmentName;
                 *
                 *  Msg = "There are no more of " + temp.First().ToString() + " available. Please select a new item to rent.";
                 *
                 *  PopulateEquipmentsDropDownList(_context, RentalToUpdate.ID);
                 *  return Page();      // need to add error messages
                 * }*/
            }

            PopulateEquipmentsDropDownList(_context, RentalToUpdate.ID);
            return(Page());      // need to add error messages
        }
Exemplo n.º 9
0
        public async Task <IActionResult> OnPostAsync()
        {
            var emptyTourn = new Tournament();

            if (await TryUpdateModelAsync <Tournament>(
                    emptyTourn,
                    "tournament",
                    q => q.DateFor, q => q.ActivityType, q => q.MaxTeams,
                    q => q.MaxTeamSize, q => q.MinTeamSize, q => q.SpaceID
                    ))
            {
                _context.Tournaments.Add(emptyTourn);
                await _context.SaveChangesAsync();

                return(RedirectToPage("../Confirmation"));
            }

            return(Page());
        }
Exemplo n.º 10
0
        public async Task <IActionResult> OnPostAsync(int id)
        {
            var ResToUpdate = await _context.Reservations.FindAsync(id);

            if (ResToUpdate == null)
            {
                return(NotFound());
            }

            if (await TryUpdateModelAsync <Reservation>(
                    ResToUpdate,
                    "Reservation",
                    r => r.FirstName, r => r.LastName, r => r.SpaceID))
            {
                await _context.SaveChangesAsync();

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

            return(Page());
        }
Exemplo n.º 11
0
        public async Task <IActionResult> OnPostAsync(int id)
        {
            var TournToUpdate = await _context.Tournaments.FindAsync(id);

            if (TournToUpdate == null)
            {
                return(NotFound());
            }

            if (await TryUpdateModelAsync <Tournament>(
                    TournToUpdate,
                    "Tournament",
                    t => t.DateFor, t => t.ActivityType, t => t.MaxTeams,
                    t => t.MaxTeamSize, t => t.MinTeamSize, t => t.SpaceID))
            {
                await _context.SaveChangesAsync();

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


            return(Page());
        }