Exemple #1
0
        public async Task <ActionResult> View(int id)
        {
            StudentModel student = null;

            try
            {
                student = await StudentService.GetStudent(id);
            }
            catch (Exception e)
            {
                string message = string.Format("Student ID {0} not found", id);
                MvcApplication.LogException(new ArgumentException(message, nameof(id), e));
                return(RedirectToAction("NotFound", "Error"));
            }

            if (student == null)
            {
                string message = string.Format("Student ID {0} returned null", id);
                MvcApplication.LogException(new ArgumentException(message, nameof(id)));
                return(RedirectToAction("NotFound", "Error"));
            }

            ViewBag.StudyAbroad = await StudyAbroadService.GetAllForStudent(id);

            ViewBag.Notes = await StudentNoteService.GetAllNotes(id);

            ViewBag.ShowActionButtons = true;
            await PrepareViewBag();
            await PrepareStudyAbroadDropDowns();

            return(View(student));
        }
Exemple #2
0
        public async Task <ActionResult> List(int studentId)
        {
            try
            {
                ViewBag.Student = await StudentService.GetStudent(studentId);
            }
            catch (Exception e)
            {
                string message = string.Format("Student ID {0} not found", studentId);
                MvcApplication.LogException(new ArgumentException(message, nameof(studentId), e));
                return(RedirectToAction("NotFound", "Error"));
            }

            ViewBag.Notes = await StudentNoteService.GetAllNotes(studentId);

            return(View());
        }