Пример #1
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Faculty = await _context.Faculty
                      .Include(f => f.Branch)
                      .Include(f => f.Genre).FirstOrDefaultAsync(m => m.FacultyId == id);

            if (Faculty == null)
            {
                return(NotFound());
            }
            ViewData["BranchId"] = new SelectList(_context.Branch, "BranchId", "Address");
            ViewData["GenreId"]  = new SelectList(_context.Set <Genre>(), "GenreId", "GenreName");
            return(Page());
        }
Пример #2
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ClassSchedule = await _context.ClassSchedule
                            .Include(c => c.BuddingDancer)
                            .Include(c => c.Faculty).FirstOrDefaultAsync(m => m.ClassScheduleId == id);

            if (ClassSchedule == null)
            {
                return(NotFound());
            }
            ViewData["BuddingDancerId"] = new SelectList(_context.BuddingDancer, "BuddingDancerId", "DancerFullName");
            ViewData["FacultyId"]       = new SelectList(_context.Set <Faculty>(), "FacultyId", "FacultyFullName");
            return(Page());
        }
Пример #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());
            }

            int birthYear       = BuddingDancer.DancerBirthDate.Year;
            int lastAllowedYear = DateTime.Now.Year - 5;

            if (birthYear > lastAllowedYear)
            {
                ModelState.AddModelError(key: "BuddingDancer.DancerBirthDate", errorMessage: "Must be older than 5 years");
            }

            if (!ModelState.IsValid)
            {
                ViewData["BranchId"] = new SelectList(_context.Branch, "BranchId", "Address");
                ViewData["GenreId"]  = new SelectList(_context.Set <Genre>(), "GenreId", "GenreName");

                return(Page());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BuddingDancerExists(BuddingDancer.BuddingDancerId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Пример #4
0
 public IActionResult OnGet()
 {
     ViewData["BranchId"] = new SelectList(_context.Branch, "BranchId", "Address");
     ViewData["GenreId"]  = new SelectList(_context.Set <Genre>(), "GenreId", "GenreName");
     return(Page());
 }
Пример #5
0
 public IActionResult OnGet()
 {
     ViewData["BuddingDancerId"] = new SelectList(_context.BuddingDancer, "BuddingDancerId", "DancerFullName");
     ViewData["FacultyId"]       = new SelectList(_context.Set <Faculty>(), "FacultyId", "FacultyFullName");
     return(Page());
 }