public IActionResult addStudentBatch(studentBatchViewModel model)
        {
            StudentInBatch studentInBatch = new StudentInBatch()
            {
                Student_Id = int.Parse(model.selectedStudent),
                Batch_Id   = int.Parse(model.selectedBatch)
            };

            _studentBatchRepo.AddStudentInBatch(studentInBatch);
            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public ViewResult ViewStudent(int id)
        {
            Student stu = _student.GetStudent(id); //fetch the student object

            List <Guarantor> guarantor = _guarantorRepo.GetAllGuarantor().Where(g => g._student_id == stu.ID).ToList();

            List <Project> project = _projectRepo.GetAllProjects().Where(p => p.StudentId == stu.ID).ToList();

            StudentInBatch studentInBatch = _studentBatchRepo.GetAllStudentInBatchs().Where(s => s.Student_Id == stu.ID).FirstOrDefault();

            if (studentInBatch != null)
            {
                Batch batch = _batchRepo.GetAllBatch().Where(b => b.Id == studentInBatch.Batch_Id).FirstOrDefault(); // pass the batch id to the GetBatch method to fetch an object of the batch

                Programme program = _programRepo.GetAllProgrammes().Where(p => p.Id == batch.Program_Id).FirstOrDefault();

                if (studentInBatch != null || batch != null || program != null || guarantor != null || project != null)
                {
                    DashboardView dashboardView1 = new DashboardView()
                    {
                        student   = stu,
                        batch     = batch,
                        project   = project,
                        program   = program,
                        guarantor = guarantor,
                        pageTitle = "Student View"
                    };
                    return(View(dashboardView1));
                }
                else
                {
                    DashboardView dashboardView = new DashboardView()
                    {
                        student   = stu,
                        error     = "This Information is not Avialable at the Moment",
                        pageTitle = "Student View"
                    };
                    return(View(dashboardView));
                }
            }
            else
            {
                DashboardView dashboardView = new DashboardView()
                {
                    student   = stu,
                    error     = "This Information is not Avialable at the Moment",
                    pageTitle = "Student View"
                };
                return(View(dashboardView));
            }
        }
Beispiel #3
0
        public IActionResult AssignToBatch(StudentBatchViewModel model)
        {
            var Selected     = model.StudentId;
            int modelBatchId = model.BatchId;

            foreach (var item in Selected)
            {
                StudentInBatch sb = new StudentInBatch()
                {
                    BatchesId  = modelBatchId,
                    EmployeeId = int.Parse(item)
                };
                _programmes.AssignStudentToBatch(sb);
            }
            return(RedirectToAction("listbatch"));
        }
Beispiel #4
0
        public IActionResult addStudentBatch(studentBatchViewModel model)
        {
            //get the batchID and the studentID from the model
            //int batchID = int.Parse(model.selectedBatch);
            int studentID = int.Parse(model.selectedStudent);

            //int bid = model.Id;

            if (ModelState.IsValid)
            {
                //check if there are duplicates
                var studentinbatch = _studentBatchRepo.GetAllStudentInBatchs().Where(c => c.Batch_Id == model.Id && c.Student_Id == studentID).FirstOrDefault();
                if (studentinbatch == null)
                {
                    StudentInBatch studentInBatch = new StudentInBatch()
                    {
                        Student_Id     = studentID,
                        Batch_Id       = model.Id,
                        Student_Status = model.studentStaus,
                        Grade          = model.studentGrade
                    };
                    _studentBatchRepo.AddStudentInBatch(studentInBatch);

                    //add a program to this Batch
                    //Programme program = new Programme()
                    //{
                    //    BatchId = batchID,
                    //    Program_Name = model.programType,
                    //    Duration = model.duration
                    //};
                    //_program.AddProgramme(program);
                    return(RedirectToAction("Index"));
                }

                ModelState.AddModelError("duplicate keys", "Already asigned");
                List <Student>        studentlist           = _studentRepo.GetAllStudent().ToList();
                List <Batch>          batches               = _batchRepo.GetAllBatch().ToList();
                studentBatchViewModel studentBatchViewModel = new studentBatchViewModel()
                {
                    studentList = studentlist,
                    batchList   = batches
                };
                return(View(studentBatchViewModel));
            }
            return(View(model));
        }