Exemple #1
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            TeamSchedule = await _context.TeamSchedule
                           .Include(t => t.Volunteer).FirstAsync(m => m.TeamScheduleId == id);

            if (TeamSchedule == null)
            {
                return(NotFound());
            }
            ViewData["VolunteerId"] = new SelectList(_context.Volunteer, "VolunteerId", "VName");
            return(Page());
        }
Exemple #2
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            TeamSchedule = await _context.TeamSchedule
                           .Include(t => t.Volunteer)
                           .AsNoTracking()
                           .FirstOrDefaultAsync(m => m.TeamScheduleId == id);

            if (TeamSchedule == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Exemple #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()
        {
            var emptyTeamSchedule = new TeamSchedule();

            if (await TryUpdateModelAsync <TeamSchedule>(
                    emptyTeamSchedule,
                    "TeamSchedule", // Prefix for form value.
                    s => s.TSDate,
                    s => s.TSPeriod,
                    s => s.VolunteerId))

            {
                _context.TeamSchedule.Add(emptyTeamSchedule);
                await _context.SaveChangesAsync();

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

            return(Page());
        }