Exemple #1
0
        public ActionResult UpdateGroupDetails(int id)
        {
            StudentGroupViewModel stdgrp = (from grp in db.groups
                                            join sgrp in db.Student_Group on grp.Id equals sgrp.Group_Id
                                            join std1 in db.Students on sgrp.Student_1_ID equals std1.ID
                                            join std2 in db.Students on sgrp.Student_2_ID equals std2.ID

                                            where grp.Id == id
                                            select new StudentGroupViewModel
            {
                group_id = grp.Id,
                Group_Name = grp.GroupName,
                Student1_Name = std1.Student_Name,
                Student2_Name = std2.Student_Name,
            }).FirstOrDefault();


            var advisorname = db.Student_Advisor_Request.Where(p => p.Group_Id == stdgrp.group_id && p.Is_Accepted == true).FirstOrDefault();

            if (advisorname != null)
            {
                int advid   = Convert.ToInt32(advisorname.Advisor_Id);
                var advname = db.Advisors.Where(p => p.Id == advid).FirstOrDefault();
                stdgrp.AdvisorName = advname.AdvisorsName;
            }
            else
            {
                stdgrp.AdvisorName = "No Advisor Assigned";
            }

            return(View(stdgrp));
        }
        // GET: StudentGroups
        public ActionResult Index()
        {
            //string username = User.Identity.Name;
            //string userid = ((ClaimsPrincipal)User).Claims?.Where(c => c.Type == ClaimTypes.GroupSid).FirstOrDefault()?.Value ?? "";

            List <StudentGroupViewModel> model = new List <StudentGroupViewModel>();

            JohaMeriSQL1Entities entities = new JohaMeriSQL1Entities();

            try
            {
                List <StudentGroup> treatoffs = entities.StudentGroup.ToList();

                // muodostetaan näkymämalli tietokannan rivien pohjalta

                foreach (StudentGroup stg in treatoffs)
                {
                    StudentGroupViewModel view = new StudentGroupViewModel();
                    view.StudentGroup_id  = stg.StudentGroup_id;
                    view.StudentGroupName = stg.StudentGroupName;
                    view.Active           = stg.Active;
                    view.CreatedAt        = stg.CreatedAt;
                    view.LastModifiedAt   = stg.LastModifiedAt;
                    view.DeletedAt        = stg.DeletedAt;

                    model.Add(view);
                }
            }
            finally
            {
                entities.Dispose();
            }

            return(View(model));
        }//Index
Exemple #3
0
        public ActionResult InsertGroup(StudentGroupViewModel SGVM, int term_id)
        {
            checkLogin();

            SGVM.NewGroup.TERM = term_id;
            SGVM.NewGroup.ID   = GS.getNewID();

            foreach (var key in ModelState.Keys)
            {
                if (!key.Contains("NewGroup"))
                {
                    ModelState[key].Errors.Clear(); // only need to check new subject fields
                }
            }

            if (!ModelState.IsValid)
            {
                return(View("StudentGroup", SGVM)); // redirect to form with data
            }
            SGVM.groupList.Add(SGVM.NewGroup);
            SGVM.NewGroup    = new STUDENT_GROUP(); //gen new group
            SGVM.TermList    = CP.termSelectList;
            SGVM.UserList    = CP.userSelectList;
            SGVM.AllUserList = CP.AllUser;

            ModelState.Clear();
            TempData["showForm"] = true;
            return(View("StudentGroup", SGVM));
        }
Exemple #4
0
        }//Edit

        // GET: StudentGroups/Delete/5
        public ActionResult Delete(int?id)
        {
            string username = User.Identity.Name;
            string userid   = ((ClaimsPrincipal)User).Claims?.Where(c => c.Type == ClaimTypes.GroupSid).FirstOrDefault()?.Value ?? "";

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StudentGroup stg = db.StudentGroup.Find(id);

            if (stg == null)
            {
                return(HttpNotFound());
            }

            StudentGroupViewModel view = new StudentGroupViewModel();

            view.StudentGroup_id  = stg.StudentGroup_id;
            view.StudentGroupName = stg.StudentGroupName;
            view.Active           = stg.Active;
            view.CreatedAt        = stg.CreatedAt;
            view.LastModifiedAt   = stg.LastModifiedAt;
            view.DeletedAt        = stg.DeletedAt;

            return(View(view));
        }//Delete
        }//details

        // GET: StudentGroups/Create
        public ActionResult Create()
        {
            JohaMeriSQL1Entities db = new JohaMeriSQL1Entities();

            StudentGroupViewModel model = new StudentGroupViewModel();

            return(View());
        }//create
        // GET: StudentGroups/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StudentGroup studentGroup = _studentGroupService.Find(id);

            if (studentGroup == null)
            {
                return(HttpNotFound());
            }


            var associatedExams = _examCoreStudentGroupService.GetAll().Where(x => x.StudentGroupID == id).ToList();

            List <ExamCoreStudentGroupViewModel> lista = new List <ExamCoreStudentGroupViewModel>();

            foreach (var associate in associatedExams)
            {
                var tmp = new ExamCoreStudentGroupViewModel();
                tmp.Id = associate.Id;
                if (associate.IsGenerated != null)
                {
                    tmp.IsGenerated = (bool)associate.IsGenerated;
                }
                if (associate.IsValidated != null)
                {
                    tmp.IsValidated = (bool)associate.IsValidated;
                }
                tmp.ZIPArchiveName = associate.ZIPArchiveName;
                tmp.ExamCore       = _examCoreService.GetByID(associate.ExamCoreID);
                lista.Add(tmp);
            }



            var examsCoreVM = _studentGroupService.GetExamsCoreByStudentGroup(studentGroup.Id).ToList().Select(x => new ExamCoreStudentGroupViewModel()
            {
                ExamCore = x
            }).ToList();

            foreach (var item in examsCoreVM)
            {
                item.IsGenerated    = _examCoreStudentGroupService.CheckIfExamCoreIsGenerated(item.ExamCore.Id, studentGroup.Id);
                item.IsValidated    = _examCoreStudentGroupService.CheckIfExamCoreIsValidated(item.ExamCore.Id, studentGroup.Id);
                item.ZIPArchiveName = _examCoreStudentGroupService.GetGenerategExamArchivePath(item.ExamCore.Id, studentGroup.Id);
            }

            StudentGroupViewModel viewModel = new StudentGroupViewModel()
            {
                StudentGroup = studentGroup,
                Students     = _studentGroupService.GetStudentsByStudentGroup(studentGroup.Id).ToList(),
                ExamsCore    = lista
            };

            return(View(viewModel));
        }
Exemple #7
0
        // GET: StudentGroup
        public ActionResult Index()
        {
            var studentGroupViewModel = new StudentGroupViewModel()
            {
                StudentGroups = studentGroupFacade.GetAllStudentGroups()
            };

            return(View(studentGroupViewModel));
        }
Exemple #8
0
        public ActionResult StudentGroup(StudentGroupViewModel SGVM)
        {
            checkLogin();

            bool result = true;

            foreach (var group in SGVM.InactiveGroupsList) //remove groups wanted to remove
            {
                if (result && group > 0)
                {
                    result = false;
                    result = DBS.InactiveRecord("STUDENT_GROUP", group, CP.userID);
                }
            }

            if (result)
            {
                foreach (var group in SGVM.groupList) //add new groups
                {
                    if (result)
                    {
                        if (group.ID < 1)
                        {
                            result         = false;
                            group.ADD_BY   = CP.userID;
                            group.ADD_DATE = DateTime.Now;
                            group.ACTIVE   = true;
                            result         = DBS.addRecord(group);
                        }
                        else
                        {
                            result            = false;
                            group.MODIFY_BY   = CP.userID;
                            group.MODIFY_DATE = DateTime.Now;
                            result            = DBS.updateRecord(group);
                        }
                    }
                }
            }

            ModelState.Clear();
            if (result)
            {
                TempData[Constant.msg_success] = Constant.ChangeSucceed;
                if (SGVM.SelectedTerm == CP.currentTerm.ID)
                {
                    Session["currentStudentGroups"] = DBS.findActiveCurrentRecords <STUDENT_GROUP>(); //reset current group
                }
            }
            else
            {
                TempData[Constant.msg_error] = Constant.ChangeFailed;
            }

            return(StudentGroup(SGVM.SelectedTerm));
        }
Exemple #9
0
        }//details

        // GET: StudentGroups/Create
        public ActionResult Create()
        {
            string username = User.Identity.Name;
            string userid   = ((ClaimsPrincipal)User).Claims?.Where(c => c.Type == ClaimTypes.GroupSid).FirstOrDefault()?.Value ?? "";

            JohaMeriSQL1Entities db = new JohaMeriSQL1Entities();

            StudentGroupViewModel model = new StudentGroupViewModel();

            return(View());
        }//create
Exemple #10
0
        public JsonResult UpdateGroupDetails(StudentGroupViewModel grp)
        {
            group gp = new group()
            {
                Id = grp.group_id
            };

            db.groups.Attach(gp);
            gp.GroupName = grp.Group_Name;
            //user.Is_Pending = false;

            db.SaveChanges();
            notification not = new notification();

            not.Notification_Msg = "Your Group name is Changed to " + grp.Group_Name + " By Admin";
            not.Group_Id         = grp.group_id;
            NotificationAdd(grp.group_id);
            return(Json(new { success = true, msg = "Updated" }, JsonRequestBehavior.AllowGet));
        }
Exemple #11
0
        }//Index

        // GET: StudentGroups/Details/5
        public ActionResult Details(int?id)
        {
            string username = User.Identity.Name;
            string userid   = ((ClaimsPrincipal)User).Claims?.Where(c => c.Type == ClaimTypes.GroupSid).FirstOrDefault()?.Value ?? "";

            StudentGroupViewModel model = new StudentGroupViewModel();

            JohaMeriSQL1Entities entities = new JohaMeriSQL1Entities();

            try
            {
                List <StudentGroup> stugs = entities.StudentGroup.ToList();

                // muodostetaan näkymämalli tietokannan rivien pohjalta
                foreach (StudentGroup stg in stugs)
                {
                    StudentGroupViewModel view = new StudentGroupViewModel();
                    view.StudentGroup_id  = stg.StudentGroup_id;
                    view.StudentGroupName = stg.StudentGroupName;
                    view.Active           = stg.Active;
                    view.CreatedAt        = stg.CreatedAt;
                    view.LastModifiedAt   = stg.LastModifiedAt;
                    view.DeletedAt        = stg.DeletedAt;

                    model = view;
                }

                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                StudentGroup studentGroup = db.StudentGroup.Find(id);
                if (studentGroup == null)
                {
                    return(HttpNotFound());
                }
            }
            finally
            {
                entities.Dispose();
            }
            return(View(model));
        }//details
Exemple #12
0
        public ActionResult InactiveGroup(StudentGroupViewModel SGVM, int?group_id)
        {
            checkLogin();

            SGVM.groupList.Remove(SGVM.groupList.Where(g => g.ID == group_id).First());

            if (group_id > 0)
            {
                SGVM.InactiveGroupsList.Add((int)group_id);
            }

            SGVM.TermList    = CP.termSelectList;
            SGVM.UserList    = CP.userSelectList;
            SGVM.AllUserList = CP.AllUser;

            ModelState.Clear();
            TempData["showForm"] = true;
            return(View("StudentGroup", SGVM));
        }
        // GET: StudentGroups/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var          userID       = User.Identity.GetUserId();
            StudentGroup studentGroup = _studentGroupService.Find(id);

            if (studentGroup == null)
            {
                return(HttpNotFound());
            }
            StudentGroupViewModel viewModel = new StudentGroupViewModel()
            {
                StudentGroup = studentGroup,
                Students     = _studentGroupService.GetStudentsByStudentGroup(studentGroup.Id).ToList(),
                ExamsCore    = _studentGroupService.GetExamsCoreByStudentGroup(studentGroup.Id).Select(x => new ExamCoreStudentGroupViewModel()
                {
                    ExamCore = x
                }).ToList()
            };

            ViewBag.StudentsList = new SelectList(_studentGroupService.GetStudentNotInStudentGroup(studentGroup.Id).Where(x => x.Owner == userID).Select(p =>
                                                                                                                                                         new SelectListItem
            {
                Value = p.Id.ToString(),
                Text  = p.Email
            }),
                                                  "Value",
                                                  "Text");
            ViewBag.ExamsCoreList = new SelectList(_studentGroupService.GetExamsCoreNotInStudentGroup(studentGroup.Id).Where(x => x.Owner == userID).Select(p =>
                                                                                                                                                            new SelectListItem
            {
                Value = p.Id.ToString(),
                Text  = p.Name
            }),
                                                   "Value",
                                                   "Text");

            return(View(viewModel));
        }
        }//Index

        // GET: StudentGroups/Details/5
        public ActionResult Details(int?id)
        {
            StudentGroupViewModel model = new StudentGroupViewModel();

            JohaMeriSQL1Entities entities = new JohaMeriSQL1Entities();

            try
            {
                List <StudentGroup> stugs = entities.StudentGroup.ToList();

                // muodostetaan näkymämalli tietokannan rivien pohjalta
                foreach (StudentGroup stg in stugs)
                {
                    StudentGroupViewModel view = new StudentGroupViewModel();
                    view.StudentGroup_id  = stg.StudentGroup_id;
                    view.StudentGroupName = stg.StudentGroupName;
                    view.Active           = stg.Active;
                    view.CreatedAt        = stg.CreatedAt;
                    view.LastModifiedAt   = stg.LastModifiedAt;
                    view.DeletedAt        = stg.DeletedAt;

                    model = view;
                }

                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                StudentGroup studentGroup = db.StudentGroup.Find(id);
                if (studentGroup == null)
                {
                    return(HttpNotFound());
                }
            }
            finally
            {
                entities.Dispose();
            }
            return(View(model));
        }//details
Exemple #15
0
        public ActionResult StudentGroup(int?term_id)  // term id
        {
            checkLogin();

            StudentGroupViewModel SGVM = new StudentGroupViewModel();

            SGVM.TermList     = CP.termSelectList;
            SGVM.UserList     = CP.userSelectList;
            SGVM.SelectedTerm = CP.currentTerm.ID;
            SGVM.groupList    = DBS.findActiveCurrentRecords <STUDENT_GROUP>();
            Session["currentStudentGroups"] = SGVM.groupList;
            SGVM.AllUserList = CP.AllUser;

            if (term_id != null)
            {
                SGVM.groupList    = DBS.findActiveRecordsBySingleParm <STUDENT_GROUP>("TERM", (int)term_id);
                SGVM.SelectedTerm = (int)term_id;
            }

            ModelState.Clear();
            return(View(SGVM));
        }
        }//Edit

        // GET: StudentGroups/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StudentGroup stg = db.StudentGroup.Find(id);

            if (stg == null)
            {
                return(HttpNotFound());
            }

            StudentGroupViewModel view = new StudentGroupViewModel();

            view.StudentGroup_id  = stg.StudentGroup_id;
            view.StudentGroupName = stg.StudentGroupName;
            view.Active           = stg.Active;
            view.CreatedAt        = stg.CreatedAt;
            view.LastModifiedAt   = stg.LastModifiedAt;
            view.DeletedAt        = stg.DeletedAt;

            return(View(view));
        }//Delete
Exemple #17
0
        // GET: Students
        public async Task <IActionResult> Index(string studentGroup, string searchString)
        {
            IQueryable <string> groupQuery = from m in _context.Student
                                             orderby m.Group
                                             select m.Group;
            var students = from m in _context.Student
                           select m;

            if (!string.IsNullOrEmpty(searchString))
            {
                students = students.Where(s => s.Lastname.Contains(searchString));
            }
            if (!string.IsNullOrEmpty(studentGroup))
            {
                students = students.Where(x => x.Group == studentGroup);
            }
            var studentGroupVM = new StudentGroupViewModel
            {
                Groups   = new SelectList(await groupQuery.Distinct().ToListAsync()),
                Students = await students.ToListAsync()
            };

            return(View(studentGroupVM));
        }