public async Task <ActionResult> Edit(int id)
        {
            StudyAbroadViewModel study = await StudyAbroadService.FindById(id);

            if (study == null)
            {
                string message = string.Format("Study abroad experience ID {0} not found", id);
                MvcApplication.LogException(new ArgumentException(message, nameof(id)));
                return(RedirectToAction("NotFound", "Error"));
            }

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

            EditStudyAbroadViewModel model = (EditStudyAbroadViewModel)study;

            await PrepareDropDowns();

            return(View(model));
        }
        private IEnumerable <StudyAbroadViewModel> ProcessRecords(IEnumerable <dynamic> rows)
        {
            ICollection <StudyAbroadViewModel> studyAbroad = new List <StudyAbroadViewModel>();

            foreach (IDictionary <string, object> row in rows)
            {
                StudyAbroadViewModel study = new StudyAbroadViewModel()
                {
                    Id            = (int)row["Id"],
                    StudentId     = (int)row["StudentId"],
                    Semester      = (int)row["Semester"],
                    Year          = (int)row["Year"],
                    CreditBearing = (bool)row["CreditBearing"],
                    Internship    = (bool)row["Internship"],
                    CountryId     = (int)row["CountryId"],
                    ProgramId     = (int)row["ProgramId"],
                    City          = row["City"] as string
                };

                if (row.ContainsKey("StartDate") && row["StartDate"] != null)
                {
                    study.StartDate = DateTimeFilter.UtcToLocal((DateTime)row["StartDate"]);
                }

                if (row.ContainsKey("EndDate") && row["EndDate"] != null)
                {
                    study.EndDate = DateTimeFilter.UtcToLocal((DateTime)row["EndDate"]);
                }

                if (row.ContainsKey("ProgramTypeIds") && row["ProgramTypeIds"] != null)
                {
                    study.ProgramTypes = Array.ConvertAll(((string)row["ProgramTypeIds"]).Split(','), int.Parse);
                }

                study.Student = new StudentModel()
                {
                    FirstName  = (string)row["FirstName"],
                    MiddleName = row["MiddleName"] as string,
                    LastName   = (string)row["LastName"]
                };

                studyAbroad.Add(study);
            }

            return(studyAbroad);
        }