Ejemplo n.º 1
0
        public async Task<ActionResult> Edit(StudentViewModel model)
        {
            if (ModelState.IsValid)
            {
                Mapper.CreateMap<StudentViewModel, Student>();
                Student student = await db.Students.FindAsync(model.ID).ConfigureAwait(false);
                Mapper.Map<StudentViewModel, Student>(model, student);

                db.Entry(student).State = EntityState.Modified;
                await db.SaveChangesAsync().ConfigureAwait(false);
                return RedirectToAction("Index");
            }

            var leaList = await cactus.CactusInstitutions.OrderBy(m => m.Name).ToListAsync().ConfigureAwait(false);

            leaList.Insert(0, new CactusInstitution() { Name = "HOME SCHOOL", ID = GlobalVariables.HOMESCHOOLID });
            leaList.Insert(0, new CactusInstitution() { Name = "PRIVATE SCHOOL", ID = GlobalVariables.PRIVATESCHOOLID });

            ViewBag.EnrollmentLocationID = new SelectList(leaList, "ID", "Name", model.EnrollmentLocationID);
            ViewBag.EnrollmentLocationSchoolNamesID = new SelectList(cactus.CactusSchools.Where(m => m.District == model.EnrollmentLocationID), "ID", "Name", model.EnrollmentLocationSchoolNamesID);
            return View(model);
        }
Ejemplo n.º 2
0
        private async Task<StudentViewModel> GetClientSelectLists(StudentViewModel model)
        {
            try
            {
                //Look up Lists of Leas
                model.EnrollmentLocation = await GetEnrollmentLocations().ConfigureAwait(false);

                //Look up Lists of Schools
                model.EnrollmentLocationSchoolNames = GetSchoolNames();

                return model;
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets SSID from SSID Server
        /// </summary>
        /// <param name="studentVm"></param>
        /// <returns></returns>
        public async Task<string> GetSSID(StudentViewModel studentVm)
        {
            var result = await ssidFindingService.GetSsid(studentVm);

            if (result != null)
            {
                return result;
            }

            throw new NullReferenceException();
        }
Ejemplo n.º 4
0
        // GET: Students/Create
        public async Task<ActionResult> Create()
        {
            try
            {


                // Check to see if this information already exists.  If not then create one.
                var userIdentity = User.Identity.GetUserId();
                var student = await db.Students.FirstOrDefaultAsync(u => u.UserId == userIdentity).ConfigureAwait(false);
                if (student != null)
                {
                    //Delete entry in table make student re-enter data.
                    db.Students.Remove(student);
                }

                StudentViewModel model = new StudentViewModel();
                model = await GetClientSelectLists(model).ConfigureAwait(false); // Create SelectLists for Enrollment and Credit Exceptions
                return View(model);
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
                return View("Error");
            }

        }