public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            AdvisingAssignment = await _context.AdvisingAssignments.FindAsync(id);

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

            return(RedirectToPage("./Index"));
        }
Exemple #2
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            // make an empty list
            List <SectionDropdownItem> dropdownItems
                = new List <SectionDropdownItem>();
            // get all sections from the db
            List <DiplomaProgramYearSection> dpysList =
                _context
                .DiplomaProgramYearSections
                .Include(dpys => dpys.AcademicYear)
                .Include(dpys => dpys.DiplomaProgramYear)
                .ThenInclude(dpy => dpy.DiplomaProgram)
                .OrderByDescending(dpys => dpys.AcademicYear.Title)
                .ThenBy(dpys => dpys.DiplomaProgramYear.DiplomaProgram.Title)
                .ThenBy(dpys => dpys.DiplomaProgramYear.Title)
                .ThenBy(dpys => dpys.Title)
                .ToList();

            foreach (var section in dpysList)
            {
                // create a new dropdown item
                // add it to dropdown list
                dropdownItems.Add(new SectionDropdownItem {
                    Id          = section.Id,
                    DisplayName = $"{section.AcademicYear.Title} - {section.DiplomaProgramYear.DiplomaProgram.Title} - {section.DiplomaProgramYear.Title} - {section.Title}"
                });
            }
            AdvisingAssignment = await _context.AdvisingAssignments
                                 .Include(a => a.DiplomaProgramYearSection)
                                 .Include(a => a.Instructor).FirstOrDefaultAsync(m => m.Id == id);

            if (AdvisingAssignment == null)
            {
                return(NotFound());
            }
            ViewData["DiplomaProgramYearSectionId"] = new SelectList(dropdownItems, "Id", "DisplayName");
            ViewData["InstructorId"]
                = new SelectList(_context.Instructors
                                 , "Id"
                                 , "FullName");
            return(Page());
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            AdvisingAssignment = await _context.AdvisingAssignments
                                 .Include(a => a.DiplomaProgramYearSection)
                                 .Include(a => a.Instructor).FirstOrDefaultAsync(m => m.Id == id);

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

            AdvisingAssignment = await _context.AdvisingAssignments
                                 .Include(a => a.DiplomaProgramYearSection)
                                 .ThenInclude(d => d.DiplomaProgramYear)
                                 .ThenInclude(d => d.DiplomaProgram)
                                 .Include(a => a.Instructor).FirstOrDefaultAsync(m => m.Id == id);

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

            var LongText = _context.DiplomaProgramYearSections
                           .Select(d => new
            {
                Id       = d.Id,
                fulltext = d.DiplomaProgramYear.DiplomaProgram.Title + " - " + d.DiplomaProgramYear.Title + " - " + d.Title
            });

            ViewData["DiplomaProgramYearSectionId"] = new SelectList(LongText, "Id", "fulltext");
            // Select all records from the database and store in a variable
            // Create a new objects the array and concatenate the first and last names together


            var fullname = _context.Instructors.Select(i => new{ Id = i.Id, fullname = i.FirstName + " " + i.LastName });

            ViewData["InstructorId"] = new SelectList(fullname, "Id", "fullname");
            // Pass the fullNames variable into the ViewData
            //ViewData['InstructorId'] = new SelectList(fullNames, "Id", "fullNames");

            return(Page());
        }