Ejemplo n.º 1
0
        // Populate Student View Model
        public StudentViewModel PopulateViewModel(StudentViewModel viewModel)
        {
            viewModel.CourseOfferings = _courseService.GetAllCourseOfferings();
            viewModel.CourseOfferings.Sort(new CourseOfferingComparer());

            return viewModel;
        }
Ejemplo n.º 2
0
        public ActionResult Add(StudentViewModel input)
        {
            // Populate VM
            var viewModel = PopulateViewModel(input);

            // Validate model state
            if (!ModelState.IsValid) return View(input);

            // Attempt to add the student to the database/course offering
            try
            {
                // Get the created student from the factory
                var studentFactory = new StudentFactory();
                var student = studentFactory.CreateStudent(input.Number, input.Name, input.Type);

                // Get the course offering
                var offering = _courseService.GetCourseOffering(input.SelectedCourseId, input.SelectedYear, input.SelectedSemester);

                // Add the student
                _courseService.AddStudent(student, offering);
                
            }
            catch (Exception)
            {
                TempData["Error"] = "Something went wrong";
            }

            return RedirectToAction("Add", viewModel);
        }
 // GET: Students/Create
 public ActionResult Create()
 {
     var viewModel = new StudentViewModel();
     var classes = db.SchoolClasses.ToList();
     viewModel.Classes = db.SchoolClasses.Select(x => new SelectListItem { Value=x.SchoolClassId.ToString(), Text=x.Name }).ToList<SelectListItem>();
     return View(viewModel);
 }
Ejemplo n.º 4
0
        public ActionResult Edit(StudentViewModel model)
        {
            if (!ModelState.IsValid)
                return View(model);

            var edited = DecomposeStudentViewModel(model);
            StudentManager.Update(edited);
            return RedirectToAction("List");
        }
Ejemplo n.º 5
0
        public PartialViewResult GetStudentsInOffering(string offeringId, int year, string semester)
        {
            // Get the selected course offering
            var offering = _courseService.GetCourseOffering(offeringId, year, semester);

            // Get students in offering and sort based out custom comparer
            var students = _courseService.GetAllStudentsByOffering(offering);
            students.Sort(StudentComparer.CustomSort);

            // Update view model with students in course offering
            var viewModel = new StudentViewModel()
            {
                Students = students
            };

            return PartialView("_DisplayStudents", viewModel);
        }
Ejemplo n.º 6
0
        public ActionResult StudentsUpdate([DataSourceRequest]DataSourceRequest request, StudentViewModel student)
        {
            StudentViewModel result = null;

            if (this.ModelState.IsValid)
            {
                var entity = this.Mapper.Map<StudentInfo>(student);
                this.students.Update(entity);

                result = this.Mapper.Map<StudentViewModel>(this.students.GetById(entity.StudentId));
            }

            if (result != null)
            {
                return this.Json(new[] { result }.ToDataSourceResult(request, this.ModelState));
            }

            return this.Json(new[] { student }.ToDataSourceResult(request, this.ModelState));
        }
        public ApplicationViewModel(MainWindow mainWindow, IEventAggregator eventAggregator, ISettingsService settingsService,
            CollegeViewModel collegeVM, StudentViewModel studentVM,
           Func<IndividualCollegeViewModel> individualCollegeVM, Func<IndividualStudentViewModel> individualStudentVM)
        {
            this.CurrentView = mainWindow;
            this.CurrentView.DataContext = this;
            this._eventAggregator = eventAggregator;
            this._settingsService = settingsService;
            this._collegeVM = collegeVM;
            this._studentVM = studentVM;
            this._individualCollegeVMFactory = individualCollegeVM;
            this._individualStudentVMFactory = individualStudentVM;

            AddColleges();
            AddStudentsToColleges();

            UserControl ucStudentDetails = this.CurrentView.FindName("ucStudentDetails") as UserControl;
            _studentGridView = ucStudentDetails.FindName("rgvStudentList") as RadGridView;

            this.CurrentView.Show();
        }
        public void GivenBuilder_WhenCallingBuildImplicitly_ThenReturnAnObject()
        {
            StudentViewModel viewModel = Builder <StudentViewModel> .CreateNew();

            viewModel.ShouldBeOfType <StudentViewModel>();
        }
Ejemplo n.º 9
0
 public MainViewModel()
 {
     StudentViewModel = new StudentViewModel();
 }
Ejemplo n.º 10
0
        public async Task <IActionResult> UpdateStudent(Int64 id)
        {
            //GEt the List of class
            var i = _context.Class.ToList();

            ViewBag.Class = i;
            //Get the specific student
            var std = await _context.Student.Where(s => s.StudentId == id).ToListAsync();



            var grd = await _context.GuardianInfo.Where(a => a.StudentID == id).ToListAsync();

            var query = (from st in std
                         join g in grd on st.StudentId equals g.StudentID
                         where st.StudentId == g.StudentID
                         select new
            {
                stdntid = st.StudentId,
                stdntname = st.StudentName,
                stdntcls = st.StudentClass,
                stdntgender = st.StudentGender,
                stdntphoto = st.StudentPhoto,
                stdntcaddrss = st.StudentCAddress,
                stdntpaddrss = st.StudentPAddress,
                stdntdoa = st.DateOfAdmission,
                stdntnation = st.StudentNationality,
                stdntyear = st.Year,
                dob = st.StudentDOB,
                stdntbg = st.StudentBG,

                //Guardian Info

                GNameMA = g.GNameF,
                GNameMO = g.GNameM,
                GPhoneFA = g.GPhoneF,
                GPhoneMO = g.GPhoneM,
                GEmailMO = g.GEmailM,
                GEmailFA = g.GEmailF,
                GOccupationFA = g.GOccupationF,
                GOccupationMO = g.GOccupationM,
                GOrganisationFA = g.GOrganisationF,
                GOrganisationMO = g.GOrganisationM,
                GDesignationFA = g.GDesignationF,
                GDesignationMO = g.GDesignationM
            }).FirstOrDefault();

            StudentViewModel svm = new StudentViewModel()
            {
                stdntnameVM    = query.stdntname,
                stdntidVM      = query.stdntid,
                stdntclsVM     = query.stdntcls,
                stdntgenderVM  = query.stdntgender,
                stdntphotoVM   = query.stdntphoto,
                stdntcaddrssVM = query.stdntcaddrss,
                stdntpaddrssVM = query.stdntpaddrss,
                stdntdoaVM     = query.stdntdoa,
                stdntnationVM  = query.stdntnation,
                stdntyearVM    = query.stdntyear,
                dobVM          = query.dob,
                ///Guardian info
                gnameFVM         = query.GNameMA,
                gnameMVM         = query.GNameMA,
                gphoneFVM        = query.GPhoneFA,
                gphoneMVM        = query.GPhoneMO,
                gemailFVM        = query.GEmailFA,
                gemailMVM        = query.GEmailMO,
                goccupationFVM   = query.GOccupationFA,
                goccupationMVM   = query.GOccupationMO,
                gorganisationFVM = query.GOrganisationFA,
                gorganisationMVM = query.GOrganisationMO,
                gdesignationFVM  = query.GDesignationFA,
                gdesignationsMVM = query.GDesignationMO
            };



            return(View(svm));
        }
Ejemplo n.º 11
0
 public async Task <int> UpdateStudent(StudentViewModel instructor)
 {
     _dbContext.Students.Update(_map.Map <Student>(instructor));
     return(await _dbContext.SaveChangesAsync().ConfigureAwait(false));
 }
Ejemplo n.º 12
0
        public ActionResult Index(long?courseId, long?specialtyId, long?groupId, int?yearOfEntrance)
        {
            var courses = _courseService.Queryable().ToList();

            if (courseId == null)
            {
                var firstCourse = courses.FirstOrDefault();
                courseId = firstCourse == null ? -1 : firstCourse.CourseId;
            }

            var specialties = _specialtyService
                              .Query(specialty => specialty.CourseId == (long)courseId)
                              .Select()
                              .ToList();

            if (specialtyId == null)
            {
                var firstSpecialty = specialties.FirstOrDefault();
                specialtyId = firstSpecialty == null ? -1 : firstSpecialty.SpecialtyId;
            }
            var groups = _groupService.Query(group => group.SpecialtyId == (long)specialtyId &&
                                             group.Specialty.CourseId == (long)courseId)
                         .Select()
                         .ToList();

            if (groupId == null)
            {
                var firstGroup = groups.FirstOrDefault();
                groupId = firstGroup == null ? -1 : firstGroup.GroupId;
            }

            var yearOfEntrances = new List <int>();
            var temp            = _studentService
                                  .Query(student => student.GroupId == (long)groupId)
                                  .Select(student => student.YearOfEntrance).ToList();

            foreach (var value in temp.Where(value => !yearOfEntrances.Contains(value)))
            {
                yearOfEntrances.Add(value);
            }

            yearOfEntrances = yearOfEntrances.OrderBy(i => i).ToList();
            if (yearOfEntrance == null)
            {
                var firstYearOfEntrance = yearOfEntrances.FirstOrDefault();
                yearOfEntrance = firstYearOfEntrance;
            }

            var model = new StudentViewModel
            {
                Courses         = new SelectList(courses, "CourseId", "CourseNumber", courseId),
                Specialties     = new SelectList(specialties, "SpecialtyId", "Name", specialtyId),
                Groups          = new SelectList(groups, "GroupId", "GroupNumber", groupId),
                YearOfEntrances = new SelectList(yearOfEntrances),
                YearOfEntrance  = (int)yearOfEntrance,
                GroupId         = (long)groupId,
                Students        = _studentService.Query(student => student.GroupId == groupId && student.YearOfEntrance == yearOfEntrance)
                                  .Select(student => new StudentRowViewModel
                {
                    CourseNumber   = student.Group.Specialty.Course.CourseNumber,
                    GroupNumber    = student.Group.GroupNumber,
                    SpecialtyName  = student.Group.Specialty.Name,
                    FirstName      = student.FirstName,
                    YearOfEntrance = student.YearOfEntrance,
                    LastName       = student.LastName,
                    MiddleName     = student.MiddleName,
                    StudentId      = student.StudentId,
                    Login          = student.Login,
                    Password       = student.Password
                }).ToList()
            };

            var gv = new GridView {
                DataSource = model.Students
            };

            gv.DataBind();
            Session["Students"] = gv;

            return(View(model));
        }
Ejemplo n.º 13
0
 public IActionResult Add(StudentViewModel student)
 {
     db.Student.Add(student);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 14
0
        public ActionResult Vulnerabilities(StudentViewModel student)
        {
            //solo si se ha iniciado sesion
            if (Session["UserGroup"] != null)
            {
                //se crea un student del viewModel
                VulnerabilitiesViewModel objVulnerabilities = new VulnerabilitiesViewModel();

                //se guarda el nombre y la matricula
                objVulnerabilities.Nombre    = student.Nombre;
                objVulnerabilities.Matricula = student.Matricula;

                //se guarda la matricula en una variable
                string registration = student.Matricula;

                #region GUARDAR VULNERABILIDADES YA CONSULTADAS

                //convertimos a string para poder usarlas como radio buttons
                objVulnerabilities.Vul1 = student.Vul1.ToString();
                objVulnerabilities.Vul2 = student.Vul2.ToString();
                objVulnerabilities.Vul3 = student.Vul3.ToString();
                objVulnerabilities.Vul4 = student.Vul4.ToString();

                #endregion

                #region OBTENER COMENTARIOS DE VULNERABILIDADES

                //se obtienen los comentarios de cada una de las vulnerabilidades
                var queryVul1 = (from sv in dbCtx.StudentVulnerabilities
                                 join s in dbCtx.Students on sv.StudentID equals s.ID
                                 where s.Registration == registration && sv.VulnerabilityID == 1
                                 select new
                {
                    coments = sv.VulComments
                }).SingleOrDefault();
                var queryVul2 = (from sv in dbCtx.StudentVulnerabilities
                                 join s in dbCtx.Students on sv.StudentID equals s.ID
                                 where s.Registration == registration && sv.VulnerabilityID == 2
                                 orderby sv.VulnerabilityID
                                 select new
                {
                    coments = sv.VulComments
                }).SingleOrDefault();
                var queryVul3 = (from sv in dbCtx.StudentVulnerabilities
                                 join s in dbCtx.Students on sv.StudentID equals s.ID
                                 where s.Registration == registration && sv.VulnerabilityID == 3
                                 orderby sv.VulnerabilityID
                                 select new
                {
                    coments = sv.VulComments
                }).SingleOrDefault();
                var queryVul4 = (from sv in dbCtx.StudentVulnerabilities
                                 join s in dbCtx.Students on sv.StudentID equals s.ID
                                 where s.Registration == registration && sv.VulnerabilityID == 4
                                 orderby sv.VulnerabilityID
                                 select new
                {
                    coments = sv.VulComments
                }).SingleOrDefault();

                //agregar valores de los comentarios
                objVulnerabilities.ComentsVul1 = queryVul1.coments;
                objVulnerabilities.ComentsVul2 = queryVul2.coments;
                objVulnerabilities.ComentsVul3 = queryVul3.coments;
                objVulnerabilities.ComentsVul4 = queryVul4.coments;

                #endregion

                //se retorna la vista
                return(View(objVulnerabilities));
            }
            else
            {
                //si no se ha hecho login entonces regresa al login
                return(RedirectToAction("Login", "Login"));
            }
        }
Ejemplo n.º 15
0
        public StudentDTO AddToWaitingList(int courseId, StudentViewModel waiting)
        {
            // Student needs to be a registered user
            // Check if student exists
            var studentExistsInDatabase = (from c in _db.Students
                                           where c.SSN == waiting.SSN
                                           select c).SingleOrDefault();

            // If the student does not exist in database
            // Throw exception
            if (studentExistsInDatabase == null)
            {
                throw new StudentNotExistsException();
            }

            // Check if course exist
            var courseExistsInDatabase = (from c in _db.Courses
                                          where c.Id == courseId
                                          select c).SingleOrDefault();

            // If the course does not exist
            // Throw exception
            if (courseExistsInDatabase == null)
            {
                throw new CourseNotExistsException();
            }

            // Check if student is already on waiting list
            var StudentStatus = (from c in _db.Enrollments
                                 where c.StudentSSN == waiting.SSN &&
                                 c.CourseId == courseId
                                 select c.Status).SingleOrDefault();

            // If the student is on the waiting list
            // Throw exception
            if (StudentStatus == "Waiting")
            {
                throw new DuplicateWaitingException();
            }

            // If the student is enrolled in course
            // Throw exception
            if (StudentStatus == "Enrolled")
            {
                throw new DublicateEnrolledException();
            }

            if (StudentStatus == "Deleted")
            {
                var FindStudent = (from c in _db.Enrollments
                                   where c.StudentSSN == waiting.SSN &&
                                   c.CourseId == courseId
                                   select c).SingleOrDefault();

                FindStudent.Status = "Waiting";
                _db.Enrollments.Update(FindStudent);
            }
            else
            {
                _db.Enrollments.Add(
                    new Enrollment {
                    CourseId = courseId, StudentSSN = waiting.SSN, Status = "Waiting"
                });
            }

            _db.SaveChanges();

            return(new StudentDTO
            {
                SSN = waiting.SSN,
                Name = (from st in _db.Students
                        where st.SSN == waiting.SSN
                        select st).SingleOrDefault().Name
            });
        }
Ejemplo n.º 16
0
        public StudentDTO AddStudentToCourse(int courseId, StudentViewModel newStudent)
        {
            // Student needs to be a registered user
            // Check if student exists
            var studentExistsInDatabase = (from c in _db.Students
                                           where c.SSN == newStudent.SSN
                                           select c).SingleOrDefault();

            if (studentExistsInDatabase == null)
            {
                throw new StudentNotExistsException();
            }

            // Check if course exists in database
            var courseExistsInDatabase = (from c in _db.Courses
                                          where c.Id == courseId
                                          select c).SingleOrDefault();

            if (courseExistsInDatabase == null)
            {
                throw new CourseNotExistsException();
            }

            // Check if student is already enrolled in course
            var studentIsEnrolled = (from c in _db.Enrollments
                                     where c.StudentSSN == newStudent.SSN &&
                                     c.CourseId == courseId &&
                                     c.Status == "Enrolled"
                                     select c).SingleOrDefault();

            if (studentIsEnrolled != null)
            {
                throw new DublicateEnrolledException();
            }

            // Check course max capacity
            var studentCapacity = (from c in _db.Courses
                                   where c.Id == courseId
                                   select c).SingleOrDefault();

            // Check course capacity status
            int studentCapacityStatus = (from c in _db.Enrollments
                                         where c.CourseId == courseId &&
                                         c.Status == "Enrolled"
                                         select c).Count();

            if (studentCapacity.MaxStudents == studentCapacityStatus)
            {
                throw new MaxCapacityException();
            }



            // Check if student is already on the waiting list
            // before enrolling him
            var studentIsWaiting = (from c in _db.Enrollments
                                    where c.StudentSSN == newStudent.SSN &&
                                    c.CourseId == courseId &&
                                    c.Status == "Waiting"
                                    select c).SingleOrDefault();

            // Check if student is deleted
            // before enrolling him
            var studentIsDeleted = (from c in _db.Enrollments
                                    where c.StudentSSN == newStudent.SSN &&
                                    c.CourseId == courseId &&
                                    c.Status == "Deleted"
                                    select c).SingleOrDefault();

            // Removing deleted status
            if (studentIsDeleted != null)
            {
                studentIsDeleted.Status = "Enrolled";
                _db.Enrollments.Update(studentIsDeleted);
                // Removing waiting status
            }
            else if (studentIsWaiting != null)
            {
                studentIsWaiting.Status = "Enrolled";
                _db.Enrollments.Update(studentIsWaiting);
            }
            else
            {
                _db.Enrollments.Add(new Enrollment {
                    CourseId = courseId, StudentSSN = newStudent.SSN, Status = "Enrolled"
                });
            }

            _db.SaveChanges();

            return(new StudentDTO
            {
                SSN = newStudent.SSN,
                Name = (from st in _db.Students
                        where st.SSN == newStudent.SSN
                        select st).SingleOrDefault().Name
            });
        }
Ejemplo n.º 17
0
        public IActionResult UpdateStudent(StudentViewModel update)
        {
            Student s = new Student();

            s.StudentHallID = update.studenthallidVM;
            s.DOB           = update.dobVM;
            s.StudentName   = update.studentnameVM;
            s.Department    = update.departmentVM;
            s.ContactNo     = update.contactnoVM;
            s.Date          = DateTime.Now;
            dbc.Student.Update(s);
            dbc.SaveChanges();
            ModelState.Clear();
            var x = dbc.User.Where(q => q.UserID == update.studenthallidVM).FirstOrDefault();

            if (x != null)
            {
                x.UserName = update.studentnameVM;
                dbc.User.Update(x);
                dbc.SaveChanges();
            }
            else
            {
                return(RedirectToAction("StudentList"));
            }
            var y = dbc.Payment.Where(q => q.StudentHallID == update.studenthallidVM).FirstOrDefault();

            if (y != null)
            {
                y.StudentName = update.studentnameVM;
                y.Department  = update.departmentVM;
                dbc.Payment.Update(y);
                dbc.SaveChanges();
            }
            else
            {
                return(RedirectToAction("StudentList"));
            }
            var z = dbc.AssignedRoom.Where(q => q.StudentHallID == update.studenthallidVM).FirstOrDefault();

            if (z != null)
            {
                z.StudentName = update.studentnameVM;
                z.Department  = update.departmentVM;
                dbc.AssignedRoom.Update(z);
                dbc.SaveChanges();
            }
            var u = dbc.MealDistribution.Where(q => q.StudentHallID == update.studenthallidVM).ToList();

            if (u != null)
            {
                foreach (var item in u)
                {
                    item.StudentName = update.studentnameVM;
                    dbc.MealDistribution.Update(item);
                    dbc.SaveChanges();
                }
            }
            else
            {
                return(RedirectToAction("StudentList"));
            }
            return(RedirectToAction("StudentList"));
        }
Ejemplo n.º 18
0
        public async Task <HttpResponseMessage> AddStudentToGroup(Guid groupId, [FromBody] StudentViewModel student)
        {
            await _groupService.AddStudentToGroup(groupId, Mapper.Map <StudentDto>(student));

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Ejemplo n.º 19
0
        public IActionResult UpdateStudent(StudentViewModel student)
        {
            var std = university.UpdateStudent(student);

            return(RedirectToAction("Students"));
        }
        // get student info by id
        public JsonResult GetStudentInfoById(int id)
        {
            StudentViewModel student = studentManager.GetStudentById(id);

            return(Json(student));
        }
        // get student info by studentId
        public JsonResult GetStudentById(int studentId)
        {
            StudentViewModel studentViewModel = studentManager.GetStudentById(studentId);

            return(Json(studentViewModel));
        }
Ejemplo n.º 22
0
        //Vamos a obtener como parametros la matricula del estudante selecionado
        public ActionResult Student(StudentsViewModel student)
        {
            //Se valida si se ha iniciado sesion
            if (Session["UserGroup"] != null)
            {
                //Se crea un student del viewModel
                StudentViewModel objEstudiante = new StudentViewModel();

                //Se guarda el nombre y la matricula
                objEstudiante.Nombre    = student.Nombre;
                objEstudiante.Matricula = student.Matricula;

                //Se guarda la matricula en una variable
                string matricula = student.Matricula;


                #region OBTENER FOTO DE ESTUDIANTE EN BASE A MATRICULA

                //como tenemos las fotos guardadas con matricula no necesitamos hacer un query
                //a la matricula se le agrega el .jpg
                string path = matricula + ".jpg";

                //se agrega al ViewModel
                objEstudiante.Matricula = matricula;
                objEstudiante.PhotoPath = path;

                #endregion

                #region OBTENER DATOS ESTUDIANTE EN BASE A MATRICULA

                //se obtiene la informacion del alumno
                var queryStudent = (from s in dbCtx.Students
                                    join cg in dbCtx.ClassGroups on s.ClassGroupID equals cg.ID
                                    join ms in dbCtx.MaritalStatuses on s.MaritalStatusID equals ms.ID
                                    join c in dbCtx.Careers on s.CareerID equals c.ID
                                    join m in dbCtx.Modalities on s.ModalityID equals m.ID
                                    join tu in dbCtx.Turns on s.TurnID equals tu.ID
                                    join si in dbCtx.Situations on s.SituationID equals si.ID
                                    where s.Registration == matricula
                                    select new
                {
                    nombre = s.FirstMidName,
                    apellidoP = s.LastNameP,
                    apellidoM = s.LastNameM,
                    birthDate = s.BirthDate,
                    curp = s.CURP,
                    rfc = s.RFC,
                    maritalStatus = ms.Description,
                    perPhone = s.PersonalPhone,
                    perEmail = s.PersonalEmail,
                    emerPhone = s.EmergencyPhone,
                    academEmail = s.AcademicEmail,
                    carrera = c.Description,
                    modalidad = m.Description,
                    turno = tu.Description,
                    cuatrimestre = cg.Term,
                    situacion = si.Description,
                    seccion = cg.Section
                }).SingleOrDefault();

                //se le agregan los valores
                objEstudiante.FirstMidName   = queryStudent.nombre;
                objEstudiante.LastNameP      = queryStudent.apellidoP;
                objEstudiante.LastNameM      = queryStudent.apellidoM;
                objEstudiante.BirthDate      = queryStudent.birthDate;
                objEstudiante.CURP           = queryStudent.curp;
                objEstudiante.RFC            = queryStudent.rfc;
                objEstudiante.MaritalStatus  = queryStudent.maritalStatus;
                objEstudiante.PersonalPhone  = queryStudent.perPhone;
                objEstudiante.PersonalEmail  = queryStudent.perEmail;
                objEstudiante.EmergencyPhone = queryStudent.emerPhone;
                objEstudiante.AcademicEmail  = queryStudent.academEmail;
                objEstudiante.Career         = queryStudent.carrera;
                objEstudiante.Modality       = queryStudent.modalidad;
                objEstudiante.Turn           = queryStudent.turno;
                objEstudiante.Term           = queryStudent.cuatrimestre;
                objEstudiante.Section        = queryStudent.seccion;
                objEstudiante.Situation      = queryStudent.situacion;

                //se agregan al objEstudiante las vulnerabilidades del parametro student
                objEstudiante.Vul1 = student.Vul1;
                objEstudiante.Vul2 = student.Vul2;
                objEstudiante.Vul3 = student.Vul3;
                objEstudiante.Vul4 = student.Vul4;


                #endregion

                #region OBTENER MATERIAS
                // se buscan las materias que lleva el alumno
                var queryMaterias = (from sc in dbCtx.StudentCourses
                                     join c in dbCtx.Courses on sc.CourseID equals c.ID
                                     join s in dbCtx.Students on sc.StudentID equals s.ID
                                     where s.Registration == matricula
                                     //para obtener solo una vez la materia y no por cada unidad
                                     group sc by c.Description into g
                                     select new
                {
                    materia = g.Key
                }).ToList();


                //lista para almacenar las materias
                List <string> materias = new List <string>();

                //por cada materia se agrega un elemento a la lista
                foreach (var materia in queryMaterias)
                {
                    materias.Add(materia.materia);
                }

                //se guarda la lista en un view bag
                ViewBag.Materias = materias;

                #endregion

                //Se retorna la vista con el estudiante de StudentViewModel
                return(View(objEstudiante));
            }
            else
            {
                return(RedirectToAction("Login", "Login"));
            }
        }
Ejemplo n.º 23
0
 public StudentGateway()
 {
     studentModel     = new StudentModel();
     studentViewModel = new StudentViewModel();
 }
Ejemplo n.º 24
0
        public ActionResult Index(StudentViewModel model, int?page, string searchCheck, string Semester_ID)
        {
            List <Student> students     = new List <Student>();
            string         SearchString = model.Email;

            if (searchCheck != null)
            {
                students = unitOfWork.Students.GetPageList();
            }
            else
            {
                page = 1;
            }
            if (!String.IsNullOrEmpty(searchCheck))
            {
                if (!String.IsNullOrWhiteSpace(SearchString))
                {
                    students = students.Where(s => s.Email.Trim().ToUpper().Contains(SearchString.Trim().ToUpper())).ToList();
                }
                if (!String.IsNullOrWhiteSpace(model.Semester_ID))
                {
                    students = students.Where(s => s.Semester_ID.Trim().Equals(model.Semester_ID.Trim())).ToList();
                }
                if (!String.IsNullOrWhiteSpace(model.Campus_ID))
                {
                    students = students.Where(s => s.Campus_ID.Trim().Equals(model.Campus_ID.Trim())).ToList();
                }
                if (students.Count == 0)
                {
                    ViewBag.Nodata = "Showing 0 results";
                }
                else
                {
                    ViewBag.Nodata = "";
                }
            }
            List <SelectListItem> semesterList = new List <SelectListItem>();
            var semester = unitOfWork.Semesters.GetAll();

            foreach (var sem in semester)
            {
                semesterList.Add(new SelectListItem
                {
                    Text  = sem.Semester_Name,
                    Value = sem.Semester_ID
                });
            }
            List <SelectListItem> campusList = new List <SelectListItem>();
            var campus = unitOfWork.Campus.GetAll();

            foreach (var cam in campus)
            {
                campusList.Add(new SelectListItem
                {
                    Text  = cam.Campus_Name,
                    Value = cam.Campus_ID
                });
            }
            model.lstSemester = semesterList;
            model.lstCampus   = campusList;
            model.searchCheck = searchCheck;
            int pageSize   = 30;
            int pageNumber = (page ?? 1);
            List <StudentSubjectView> lst = new List <StudentSubjectView>();

            foreach (var stud in students)
            {
                lst.Add(new StudentSubjectView
                {
                    Roll      = stud.Roll,
                    Full_Name = stud.Full_Name,
                    Email     = stud.Email,
                    Campus_ID = stud.Campus_ID,
                    Semester  = stud.Semester,
                    Subject   = unitOfWork.SubjectStudent.getListSubject(stud.Roll + "^" + stud.Semester_ID).ToString()
                });
            }
            model.PageList = lst.ToList().ToPagedList(pageNumber, pageSize);
            ViewBag.Count  = lst.Count();
            return(View(model));
        }
        public StudentViewModel Update(Guid idEnvironment, StudentViewModel studentViewModel)
        {
            Student student = _mapper.Map <Student>(studentViewModel);

            return(_mapper.Map <StudentViewModel>(_studentService.Update(idEnvironment, student)));
        }
Ejemplo n.º 26
0
 public IActionResult Edit(StudentViewModel student)
 {
     db.Entry(student).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
        public async Task <ActionResult> CreateStudent(StudentViewModel oStudentVM)
        {
            TempData["UserMessage"] = new MessageVM()
            {
                IsSuccessful = false, Title = "Error!", Message = "Something went wrong."
            };

            if (Helpers.Helpers.IsStaff(User))
            {
                return(RedirectToAction("Index", "Staff"));
            }

            if (!ModelState.IsValid)
            {
                return(View(oStudentVM));
            }

            Parent oParent = db.Parents.Include("Children").SingleOrDefault(p => p.ParentId == SessionSingleton.Current.ParentId);

            if (oParent == null) //Error. Parent DNE.
            {
                throw new ArgumentException("CreateStudent(StudentViewModel oStudentVM) - Parent DNE");
            }

            Student oStudent = new Student()
            {
                //-- Default values --
                Username    = User.Identity.Name,
                Email       = User.Identity.Name,
                Active      = 1,
                DateCreated = DateTime.Now,
                LastActive  = DateTime.Now,
                //-- end of Default values --

                //-- VM to Model --
                FirstName = oStudentVM.FirstName,
                LastName  = oStudentVM.LastName,
                Gender    = oStudentVM.Gender,
                Phone     = oStudentVM.Phone,
                Courses   = new List <Course>(),
                Teachers  = new List <Teacher>(),
                //WeeklyQuestions = new List<QuestionHistory>(),
                //QuestionHistorys = new List<QuestionHistory>()
                //-- end of VM to Model --
            };

            oParent.Children.Add(oStudent);//Add Student to Parent

            try
            {
                if (db.SaveChanges() <= 0)
                {
                    return(View(oStudent));
                }
            }
            catch (Exception e)
            {
                return(View(oStudent));
            }

            TempData["UserMessage"] = new MessageVM()
            {
                IsSuccessful = true, Title = "Success!", Message = "Your child has been successfully added."
            };

            return(RedirectToAction("Index", new { StudentId = oStudent.StudentId, CourseId = 0 }));
        }
Ejemplo n.º 28
0
        public StudentAddView()
        {
            InitializeComponent();

            BindingContext = StudentViewModel.GetInstance();
        }
Ejemplo n.º 29
0
        public static StudentViewModel Sort(List <Student> students, SortingEnum sortState)
        {
            var model = new StudentViewModel
            {
                LastNameSortState = sortState == SortingEnum.LastNameAsc
                    ? SortingEnum.LastNameDesc
                    : SortingEnum.LastNameAsc,
                CreatedDateSortState = sortState == SortingEnum.CreatedDateAsc
                    ? SortingEnum.CreatedDateDesc
                    : SortingEnum.CreatedDateAsc,
                DateOfBirthdaySortState = sortState == SortingEnum.DateOfBirthdayAsc
                    ? SortingEnum.DateOfBirthdayDesc
                    : SortingEnum.DateOfBirthdayAsc,
                ParentLastNameSortState = sortState == SortingEnum.ParentLastNameAsc
                    ? SortingEnum.ParentLastNameDesc
                    : SortingEnum.ParentLastNameAsc,
                PhoneNumberSortState = sortState == SortingEnum.PhoneNumberAsc
                    ? SortingEnum.PhoneNumberDesc
                    : SortingEnum.PhoneNumberAsc,
                StatusSortState = sortState == SortingEnum.StatusAsc
                    ? SortingEnum.StatusDesc
                    : SortingEnum.StatusAsc,
                GroupSortState = sortState == SortingEnum.GroupAsc
                    ? SortingEnum.GroupDesc
                    : SortingEnum.GroupAsc,
                TrialDateSortState = sortState == SortingEnum.TrialDateAsc
                    ? SortingEnum.TrialDateDesc
                    : SortingEnum.TrialDateAsc,
                LevelSortState = sortState == SortingEnum.LevelAsc
                    ? SortingEnum.LevelDesc
                    : SortingEnum.LevelAsc,
                CommentSortState = sortState == SortingEnum.CommentAsc
                    ? SortingEnum.CommentDesc
                    : SortingEnum.CommentAsc,
                ChangeStatusSortState = sortState == SortingEnum.ChangeStatusAsc
                    ? SortingEnum.ChangeStatusDesc
                    : SortingEnum.ChangeStatusAsc
            };



            switch (sortState)
            {
            case SortingEnum.LastNameAsc:
                students = students.OrderBy(s => s.LastName ?? s.Name ?? s.FatherName).ToList();
                break;

            case SortingEnum.LastNameDesc:
                students = students.OrderByDescending(s => s.LastName ?? s.Name ?? s.FatherName).ToList();
                break;

            case SortingEnum.CreatedDateAsc:
                students = students.OrderBy(s => s.CreatedDate).ToList();
                break;

            case SortingEnum.CreatedDateDesc:
                students = students.OrderByDescending(s => s.CreatedDate).ToList();
                break;

            case SortingEnum.DateOfBirthdayAsc:
                students = students.OrderBy(s => s.DateOfBirthday).ToList();
                break;

            case SortingEnum.DateOfBirthdayDesc:
                students = students.OrderByDescending(s => s.DateOfBirthday).ToList();
                break;

            case SortingEnum.ParentLastNameAsc:
                students = students.OrderBy(s => s.ParentLastName).ToList();
                break;

            case SortingEnum.ParentLastNameDesc:
                students = students.OrderByDescending(s => s.ParentLastName).ToList();
                break;

            case SortingEnum.PhoneNumberAsc:
                students = students.OrderBy(s => s.PhoneNumber).ToList();
                break;

            case SortingEnum.PhoneNumberDesc:
                students = students.OrderByDescending(s => s.PhoneNumber).ToList();
                break;

            case SortingEnum.StatusAsc:
                students = students.OrderBy(s => s.Status).ToList();
                break;

            case SortingEnum.StatusDesc:
                students = students.OrderByDescending(s => s.Status).ToList();
                break;

            case SortingEnum.GroupAsc:
                students = students.OrderBy(s => s.Group).ToList();
                break;

            case SortingEnum.GroupDesc:
                students = students.OrderByDescending(s => s.Group).ToList();
                break;

            case SortingEnum.TrialDateAsc:
                students = students.OrderBy(s => s.TrialDate).ToList();
                break;

            case SortingEnum.TrialDateDesc:
                students = students.OrderByDescending(s => s.TrialDate).ToList();
                break;

            case SortingEnum.LevelAsc:
                students = students.OrderBy(s => s.Level).ToList();
                break;

            case SortingEnum.LevelDesc:
                students = students.OrderByDescending(s => s.Level).ToList();
                break;

            case SortingEnum.CommentAsc:
                students = students.OrderBy(s => s.Comments).ToList();
                break;

            case SortingEnum.CommentDesc:
                students = students.OrderByDescending(s => s.Comments).ToList();
                break;

            case SortingEnum.ChangeStatusAsc:
                students = students.OrderBy(s => s.ChangeStatusDate).ToList();
                break;

            case SortingEnum.ChangeStatusDesc:
                students = students.OrderByDescending(s => s.ChangeStatusDate).ToList();
                break;
            }


            model.Student = students;


            return(model);
        }
Ejemplo n.º 30
0
        public async Task <IActionResult> AddStudent(StudentViewModel std)
        {
            //GEt the List of class
            var i = _context.Class.ToList();

            //Insert a new element in position 0
            i.Insert(0, new Class {
                ClassId = 0, ClassName = "Select"
            });
            ViewBag.Class = i;
            // Create a student and save to the database
            Student st = new Student()
            {
                StudentId          = std.stdntidVM,
                StudentName        = std.stdntnameVM,
                StudentCAddress    = std.stdntcaddrssVM,
                StudentPAddress    = std.stdntpaddrssVM,
                StudentNationality = std.stdntnationVM,
                StudentDOB         = std.dobVM,
                StudentGender      = std.stdntgenderVM,
                DateOfAdmission    = DateTime.Now.Date,
                StudentClass       = std.stdntclsVM,
                StudentPhoto       = std.stdntphotoVM,
                Year = DateTime.Now.Year
            };

            _context.Student.Add(st);
            await _context.SaveChangesAsync();

            //Get the id of saved student

            var StudentId = st.StudentId;
            //Create guradian info for that student and save  it
            GuardianInfo gi = new GuardianInfo()
            {
                SL             = 0,
                StudentID      = StudentId,
                GNameF         = std.gnameFVM,
                GNameM         = std.gnameMVM,
                GPhoneF        = std.gphoneFVM,
                GPhoneM        = std.gphoneMVM,
                GEmailF        = std.gemailFVM,
                GEmailM        = std.gemailMVM,
                GOccupationF   = std.goccupationFVM,
                GOccupationM   = std.goccupationMVM,
                GOrganisationF = std.gorganisationFVM,
                GOrganisationM = std.gorganisationMVM,
                GDesignationF  = std.gdesignationFVM,
                GDesignationM  = std.gdesignationsMVM
            };

            _context.GuardianInfo.Add(gi);
            await _context.SaveChangesAsync();

            // Create random password
            PasswordCreator ps = new PasswordCreator();
            //Insert the login information for student login and save
            Login lg = new Login()
            {
                SL               = 0,
                Username         = StudentId.ToString(),
                Password         = ps.RandomPassword(),
                FirstLoginStatus = true,
                ActiveStatus     = true,
                RoleId           = 1,
                DistinguishId    = StudentId,
            };

            lg.CurrentPassword = lg.Password;
            _context.Login.Add(lg);
            await _context.SaveChangesAsync();

            //Clear the modelstate
            ModelState.Clear();


            return(View());
        }
 private StudentBo BuiltStudentBo(StudentViewModel studentViewModel)
 {
     return((StudentBo) new StudentBo().InjectFrom(studentViewModel));
 }
Ejemplo n.º 32
0
        public IActionResult Details(Int64 id)
        {
            var std = _context.Student.Where(s => s.StudentId == id).ToList();

            if (std.Count != 0)
            {
                var grd = _context.GuardianInfo.Where(a => a.StudentID == id).ToList();
                if (grd.Count != 0)
                {
                    var query = (from st in std
                                 join g in grd on st.StudentId equals g.StudentID
                                 where st.StudentId == g.StudentID
                                 select new
                    {
                        stdntid = st.StudentId,
                        stdntname = st.StudentName,
                        stdntcls = st.StudentClass,
                        stdntgender = st.StudentGender,
                        stdntphoto = st.StudentPhoto,
                        stdntcaddrss = st.StudentCAddress,
                        stdntpaddrss = st.StudentPAddress,
                        stdntdoa = st.DateOfAdmission,
                        stdntnation = st.StudentNationality,
                        stdntyear = st.Year,
                        dob = st.StudentDOB,
                        stdntbg = st.StudentBG,

                        //Guardian Info

                        GNameMA = g.GNameF,
                        GNameMO = g.GNameM,
                        GPhoneFA = g.GPhoneF,
                        GPhoneMO = g.GPhoneM,
                        GEmailMO = g.GEmailM,
                        GEmailFA = g.GEmailF,
                        GOccupationFA = g.GOccupationF,
                        GOccupationMO = g.GOccupationM,
                        GOrganisationFA = g.GOrganisationF,
                        GOrganisationMO = g.GOrganisationM,
                        GDesignationFA = g.GDesignationF,
                        GDesignationMO = g.GDesignationM
                    }).FirstOrDefault();

                    StudentViewModel svm = new StudentViewModel()
                    {
                        stdntnameVM    = query.stdntname,
                        stdntidVM      = query.stdntid,
                        stdntclsVM     = query.stdntcls,
                        stdntgenderVM  = query.stdntgender,
                        stdntphotoVM   = query.stdntphoto,
                        stdntcaddrssVM = query.stdntcaddrss,
                        stdntpaddrssVM = query.stdntpaddrss,
                        stdntdoaVM     = query.stdntdoa,
                        stdntnationVM  = query.stdntnation,
                        stdntyearVM    = query.stdntyear,
                        dobVM          = query.dob,
                        ///Guardian info
                        gnameFVM         = query.GNameMA,
                        gnameMVM         = query.GNameMA,
                        gphoneFVM        = query.GPhoneFA,
                        gphoneMVM        = query.GPhoneMO,
                        gemailFVM        = query.GEmailFA,
                        gemailMVM        = query.GEmailMO,
                        goccupationFVM   = query.GOccupationFA,
                        goccupationMVM   = query.GOccupationMO,
                        gorganisationFVM = query.GOrganisationFA,
                        gorganisationMVM = query.GOrganisationMO,
                        gdesignationFVM  = query.GDesignationFA,
                        gdesignationsMVM = query.GDesignationMO
                    };

                    return(View(svm));
                }
                else
                {
                    return(NotFound());
                }
            }
            else
            {
                return(NotFound());
            }
        }
Ejemplo n.º 33
0
        public StudentViewModel GetStudentInformationById(int id)
        {
            try
            {
                CommandObj.CommandText = "spGetStudentInformationById";
                CommandObj.CommandType = CommandType.StoredProcedure;
                CommandObj.Parameters.Clear();
                CommandObj.Parameters.AddWithValue("@Id", id);
                StudentViewModel student = null;
                ConnectionObj.Open();
                SqlDataReader reader = CommandObj.ExecuteReader();
                if (reader.Read())
                {
                    student = new StudentViewModel
                    {
                        Id = Convert.ToInt32(reader["Id"].ToString()),
                        RegNo = reader["RegNo"].ToString(),
                        Name = reader["Name"].ToString(),
                        Email = reader["Email"].ToString(),
                        ContactNo = reader["ContactNo"].ToString(),
                        RegisterationDate = Convert.ToDateTime(reader["RegisterationDate"].ToString()),
                        Address = reader["Address"].ToString(),
                        Department = reader["Department"].ToString()
                    };
                }

                reader.Close();
                return student;
            }
            catch (Exception exception)
            {
                throw new Exception("Unable to get student information",exception);
            }
            finally
            {
                CommandObj.Dispose();
                ConnectionObj.Close();
            }
        }
Ejemplo n.º 34
0
        public JsonResult GetStudentById(int studentId)
        {
            StudentViewModel student = studentManager.GetStudentInformationById(studentId);

            return(Json(student, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 35
0
 public ActionResult Index()
 {
     ApplicationUser currentUser = db.Users.Find(User.Identity.GetUserId());
     var popularTutorials = db.Tutorials.OrderByDescending(x => x.Votes).Take(5).ToList();
     if (currentUser.LearningPathModel == null)
     {
         currentUser.LearningPathModel = new LearningPathModel();
     }
     if (isStudent())
     {
         StudentViewModel studentVM = new StudentViewModel
         {
             CurrentUser = currentUser,
             PopularTutorials = popularTutorials
         };
         return View("Student", studentVM);
     }
     else
     {
         var educatorsTutorials = db.Tutorials.Where(x => x.EducatorId == currentUser.Id).ToList();
         educatorsTutorials.ForEach(x => currentUser.Points += x.Votes);
         var educatorsQuizzes = db.Quiz.Where(x => x.EducatorId == currentUser.Id).ToList();
         List<CollaborativeTutorial> acttt = GetAddedCollaboratorsList(educatorsTutorials);
         EducatorViewModel eduViewModel = new EducatorViewModel()
         {
             EducatorTutorials = educatorsTutorials,
             CollaborativeTutorials = GetCollabTutorials(),
             EducatorQuizzes = educatorsQuizzes,
             Points = currentUser.Points,
             PopularTutorials = popularTutorials,
             AddedCollaboratorsToTheseTutorials = acttt
         };
         return View("Educator", eduViewModel);
     }
 }
Ejemplo n.º 36
0
        public async Task <IActionResult> UpdateStudent(int id, [FromBody] StudentViewModel model)
        {
            Result result = await _studentGateway.Update(id, model.FirstName, model.LastName, model.BirthDate, model.GitHubLogin);

            return(this.CreateResult(result));
        }
Ejemplo n.º 37
0
 public MainWindow()
 {
     InitializeComponent();
     DataContext = new StudentViewModel();
 }
Ejemplo n.º 38
0
 // GET: Students/Edit/5
 public ActionResult Edit(Guid? id)
 {
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     Student student = db.Students.Find(id);
     if (student == null)
     {
         return HttpNotFound();
     }
     StudentViewModel studentVM = new StudentViewModel();
     studentVM.Name = student.Name;
     studentVM.Email = student.Email;
     studentVM.ParentEmail = student.ParentEmail;
     studentVM.PhoneNumber = student.PhoneNumber;
     studentVM.StudentId = student.StudentId;
     studentVM.StudentClassId = student.StudentClassId;
     studentVM.Classes = db.SchoolClasses.Select(x => new SelectListItem { Text = x.Name, Value = x.SchoolClassId.ToString() });
     return View(studentVM);
 }
Ejemplo n.º 39
0
 public ActionResult Create()
 {
     var viewModel = new StudentViewModel();
     return View(viewModel);
 }
 public int?UpdateStudent(StudentViewModel student)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 41
0
 public ActionResult Create(StudentViewModel model)
 {
     var student = DecomposeStudentViewModel(model);
     StudentManager.Create(student);
     return RedirectToAction("List");
 }
Ejemplo n.º 42
0
 public EditStudent(StudentViewModel student)
 {
     InitializeComponent();
     this.student     = student;
     grid.DataContext = student;
 }
Ejemplo n.º 43
0
 private Student DecomposeStudentViewModel(StudentViewModel Student)
 {
     var student = Map<StudentViewModel, Student>(Student);
     var group = Site.GroupManager.Get(Student.GroupId);
     student.Group = group;
     student.Image = SaveImage(Student.ImageFile, Student.Id).Or(Student.Image);
     return student;
 }