public ActionResult Counsellor(string UserID)
        {
            GetCurrentUserInViewBag();
            var currentUserId = User.Identity.GetUserId();

            StudentCounsellingViewModel vm   = new StudentCounsellingViewModel();
            CounsellingForm             form = new CounsellingForm();

            var Student = db.Students.FirstOrDefault(x => x.UserID == UserID);

            vm.StudentUserID     = Student.UserID;
            vm.StudentFirstName  = Student.StudentFirstName;
            vm.StudentMiddleName = Student.StudentMiddleName;
            vm.StudentLastName   = Student.StudentLastName;
            vm.Program           = Student.Program;
            vm.YearLevel         = Student.YearLevel;
            vm.StudentID         = Student.StudentID;


            var counsellor = db.Counsellor.FirstOrDefault(x => x.UserID == currentUserId);

            vm.CounsellorLastName   = counsellor.CounsellorLastName;
            vm.CounsellorFirstName  = counsellor.CounsellorFirstName;
            vm.CounsellorMiddleName = counsellor.CounsellorMiddleName;

            vm.CompletionDate = DateTime.Now;

            vm.Session        = form.Session;
            vm.PctionPlan     = form.PctionPlan;
            vm.Recommendation = form.Recommendation;
            vm.Followup       = form.Followup;

            return(View(vm));
        }
        public ActionResult Details(StudentCounsellingViewModel vm, int AnecdotalRecordID)
        {
            GetCurrentUserInViewBag();

            AnecdotalRecord report = db.AnecdotalRecord.FirstOrDefault(x => x.AnecdotalRecordID == AnecdotalRecordID);

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

            report.Summary = vm.Summary;

            int result = db.SaveChanges();

            if (result > 0)
            {
                TempData["Message"] = "Counselor notes and summary successfully saved!";
            }
            else
            {
                var errors = ModelState.Values.SelectMany(v => v.Errors);
                TempData["Error"] = errors;
            }

            return(RedirectToAction("Index", "Home"));
        }
        public ActionResult Search(string searchStringStudentID)
        {
            GetCurrentUserInViewBag();
            var currentUserId = User.Identity.GetUserId();
            StudentCounsellingViewModel vm   = new StudentCounsellingViewModel();
            CounsellingForm             form = new CounsellingForm();
            Student student = new Student();

            var check = db.Students
                        .Where(d => d.StudentID == searchStringStudentID)
                        .Count();

            if (check != 0)
            {
                var Student = db.Students.FirstOrDefault(x => x.StudentID == searchStringStudentID);

                vm.StudentUserID     = Student.UserID;
                vm.StudentFirstName  = Student.StudentFirstName;
                vm.StudentMiddleName = Student.StudentMiddleName;
                vm.StudentLastName   = Student.StudentLastName;
                vm.Program           = Student.Program;
                vm.YearLevel         = Student.YearLevel;

                TempData["StudentUserID"] = Student.UserID;
                return(RedirectToAction("Counsellor"));
            }
            else
            {
                TempData["Error"] = "No student number: " + searchStringStudentID + " found!";
            }


            return(View(vm));
        }
        public ActionResult Report(int AnecdotalRecordID)
        {
            GetCurrentUserInViewBag();
            var currentUserId = User.Identity.GetUserId();

            var FormID = db.AnecdotalRecord.FirstOrDefault(x => x.AnecdotalRecordID == AnecdotalRecordID);

            var StudentUserID = FormID.StudentUserID;

            Student student = db.Students.Find(StudentUserID);

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

            var record = db.AnecdotalRecord.FirstOrDefault(x => x.StudentUserID == StudentUserID);

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

            StudentCounsellingViewModel vm = new StudentCounsellingViewModel();

            vm.StudentUserID     = student.UserID;
            vm.StudentID         = student.StudentID;
            vm.Program           = student.Program;
            vm.YearLevel         = student.YearLevel;
            vm.StudentFirstName  = student.StudentFirstName;
            vm.StudentMiddleName = student.StudentMiddleName;
            vm.StudentLastName   = student.StudentLastName;

            var counselloR = db.Counsellor.FirstOrDefault(x => x.UserID == currentUserId);

            if (counselloR != null)
            {
                vm.CounsellorLastName   = counselloR.CounsellorLastName;
                vm.CounsellorFirstName  = counselloR.CounsellorFirstName;
                vm.CounsellorMiddleName = counselloR.CounsellorMiddleName;
            }


            vm.CompletionDate   = record.CompletionDate;
            vm.Place            = record.Place;
            vm.Observer         = record.Observer;
            vm.BehaviorObserved = record.BehaviorObserved;
            vm.Action           = record.Action;
            vm.Summary          = record.Summary;

            return(View(vm));
        }
        public ActionResult Details(int CounsellingFormID)
        {
            GetCurrentUserInViewBag();

            var FormID = db.CounsellingForm.FirstOrDefault(x => x.CounsellingFormID == CounsellingFormID);

            var StudentUserID = FormID.StudentUserID;

            Student student = db.Students.Find(StudentUserID);

            if (student == null)
            {
                TempData["Error"] = "No record found!";
                return(RedirectToAction("Student", "CounsellingForms"));
            }

            var form = db.CounsellingForm.FirstOrDefault(x => x.StudentUserID == StudentUserID);

            if (form == null)
            {
                TempData["Error"] = "No record found!";
                return(RedirectToAction("Student", "CounsellingForms"));
            }

            StudentCounsellingViewModel vm = new StudentCounsellingViewModel();

            vm.StudentUserID     = student.UserID;
            vm.StudentID         = student.StudentID;
            vm.Program           = student.Program;
            vm.YearLevel         = student.YearLevel;
            vm.StudentFirstName  = student.StudentFirstName;
            vm.StudentMiddleName = student.StudentMiddleName;
            vm.StudentLastName   = student.StudentLastName;

            var        counsellorUserID = form.UserID;
            Counsellor counsellor       = db.Counsellor.Find(counsellorUserID);

            vm.CounsellorLastName   = counsellor.CounsellorLastName;
            vm.CounsellorFirstName  = counsellor.CounsellorFirstName;
            vm.CounsellorMiddleName = counsellor.CounsellorMiddleName;

            vm.CompletionDate = form.CompletionDate;

            vm.Session        = form.Session;
            vm.PctionPlan     = form.PctionPlan;
            vm.Recommendation = form.Recommendation;
            vm.Followup       = form.Followup;

            return(View(vm));
        }
        public ActionResult Add(string UserID)
        {
            GetCurrentUserInViewBag();
            var currentUserId = User.Identity.GetUserId();

            if (UserID == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Student student = db.Students.Find(UserID);

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

            AnecdotalRecord record     = new AnecdotalRecord();
            var             counsellor = db.Counsellor.FirstOrDefault(d => d.UserID == currentUserId);

            StudentCounsellingViewModel vm = new StudentCounsellingViewModel();

            vm.UserID            = student.UserID;
            vm.StudentID         = student.StudentID;
            vm.Program           = student.Program;
            vm.YearLevel         = student.YearLevel;
            vm.StudentFirstName  = student.StudentFirstName;
            vm.StudentMiddleName = student.StudentMiddleName;
            vm.StudentLastName   = student.StudentLastName;

            vm.CounsellorFirstName  = counsellor.CounsellorFirstName;
            vm.CounsellorMiddleName = counsellor.CounsellorMiddleName;
            vm.CounsellorLastName   = counsellor.CounsellorLastName;

            vm.CompletionDate   = record.CompletionDate;
            vm.DateTimeObserved = record.DateTimeObserved;
            vm.Place            = record.Place;
            vm.Observer         = record.Observer;
            vm.BehaviorObserved = record.BehaviorObserved;
            vm.Action           = record.Action;
            vm.Summary          = record.Summary;

            return(View(vm));
        }
Beispiel #7
0
        public ActionResult Details(string UserID)
        {
            GetCurrentUserInViewBag();

            CounsellingContract contract = db.CounsellingContract.FirstOrDefault(x => x.StudentUserID == UserID);

            if (contract == null)
            {
                TempData["Error"] = "This user has not agreed to the Counselling Terms!";
                return(RedirectToAction("Index", "CounsellingContracts"));
            }
            else if (contract.CompletionDate == null)
            {
                TempData["Error"] = "This user has not agreed to the Counselling Terms!";
                return(RedirectToAction("Index", "CounsellingContracts"));
            }

            Student student = db.Students.Find(UserID);

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

            StudentCounsellingViewModel vm = new StudentCounsellingViewModel();

            vm.StudentID         = student.StudentID;
            vm.Program           = student.Program;
            vm.StudentFirstName  = student.StudentFirstName;
            vm.StudentMiddleName = student.StudentMiddleName;
            vm.StudentLastName   = student.StudentLastName;
            vm.Program           = student.Program;
            vm.YearLevel         = student.YearLevel;

            if (contract.StudentAgrees != null)
            {
                vm.StudentAgrees = (bool)contract.StudentAgrees;
            }


            return(View(vm));
        }
        public ActionResult Add(StudentCounsellingViewModel vm, string UserID)
        {
            GetCurrentUserInViewBag();
            var currentUserId = User.Identity.GetUserId();

            AnecdotalRecord record = new AnecdotalRecord();

            var student    = db.Students.FirstOrDefault(X => X.UserID == UserID);
            var counsellor = db.Counsellor.FirstOrDefault(x => x.UserID == currentUserId);

            record.UserID        = counsellor.UserID;
            record.StudentUserID = student.UserID;

            record.CompletionDate   = DateTime.Now;
            record.DateTimeObserved = vm.DateTimeObserved;
            record.Place            = vm.Place;
            record.Observer         = vm.Observer;
            record.BehaviorObserved = vm.BehaviorObserved;
            record.Action           = vm.Action;
            record.Summary          = vm.Summary;

            db.AnecdotalRecord.Add(record);

            int result = db.SaveChanges();

            if (result > 0)
            {
                TempData["Message"] = "You have successfullly added an Anecdotal Record for student: " + student.StudentID + ":" + student.StudentFirstName + " " + student.StudentLastName + " !";
            }
            else
            {
                var errors = ModelState.Values.SelectMany(v => v.Errors);
                TempData["Error"] = errors;
            }

            return(RedirectToAction("Index", "Home"));
        }
Beispiel #9
0
        public ActionResult Student()
        {
            GetCurrentUserInViewBag();

            var currentUserId = User.Identity.GetUserId();

            var check = db.CounsellingContract
                        .Where(x => x.StudentUserID == currentUserId && x.CompletionDate != null && x.StudentAgrees == true)
                        .ToList();

            if (check.Count() != 0)
            {
                TempData["Message"] = "You have already completed the Counselling Contract!";
                return(RedirectToAction("Index", "Home"));
            }


            var newid = db.Students.FirstOrDefault(d => d.UserID == currentUserId);

            if (newid == null)
            {
                newid        = db.Students.Create();
                newid.UserID = currentUserId;
                db.Students.Add(newid);
            }

            Student student = db.Students.Find(newid.UserID);

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

            var contract = db.CounsellingContract.FirstOrDefault(d => d.StudentUserID == currentUserId);

            if (contract == null)
            {
                contract = db.CounsellingContract.Create();
                contract.StudentUserID = currentUserId;
                db.CounsellingContract.Add(contract);
                db.SaveChanges();
            }

            CounsellingContract Contract = db.CounsellingContract.FirstOrDefault(user => user.StudentUserID == currentUserId);

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

            StudentCounsellingViewModel vm = new StudentCounsellingViewModel();

            vm.StudentID         = student.StudentID;
            vm.Program           = student.Program;
            vm.StudentFirstName  = student.StudentFirstName;
            vm.StudentMiddleName = student.StudentMiddleName;
            vm.StudentLastName   = student.StudentLastName;
            vm.Program           = student.Program;
            vm.YearLevel         = student.YearLevel;

            if (contract.StudentAgrees != null)
            {
                vm.StudentAgrees = (bool)contract.StudentAgrees;
            }


            return(View(vm));
        }
        public ActionResult Counsellor(StudentCounsellingViewModel vm, string[] name, string StudentUserID)
        {
            GetCurrentUserInViewBag();
            var currentUserId = User.Identity.GetUserId();

            CounsellingForm form = new CounsellingForm();

            if (ModelState.IsValid)
            {
                if (StudentUserID == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                form.UserID         = currentUserId;
                form.StudentUserID  = StudentUserID;
                form.CompletionDate = DateTime.Now;

                form.Session        = vm.Session;
                form.PctionPlan     = vm.PctionPlan;
                form.Recommendation = vm.Recommendation;
                form.Followup       = vm.Followup;

                db.CounsellingForm.Add(form);

                var selectedTags = name.ToList();

                foreach (var item in selectedTags)
                {
                    var dlist =
                        (from ans in db.CounsellingFormCasesList
                         where ans.Type == item
                         select new { TypeID = ans.TypeID }).Single();


                    //check if may row na may laman ang CounsellingFormID, TypeID
                    var check = db.CounsellingFormCases
                                .Where(x => x.CounsellingFormID == form.CounsellingFormID && x.TypeID == dlist.TypeID)
                                .ToList();

                    if (check.Count() == 0)
                    {
                        //create ng bagong entry and lagyan ng laman the ff:
                        var newCaseId = db.CounsellingFormCases.Create();

                        newCaseId.CounsellingFormID = form.CounsellingFormID;
                        newCaseId.TypeID            = dlist.TypeID;


                        db.CounsellingFormCases.Add(newCaseId);
                    }
                }



                db.SaveChanges();

                TempData["Message"] = "Counselling form " + form.CounsellingFormID + " successfully added!";
            }
            else
            {
                TempData["Error"] = "Error: Counselling form not added!";
            }

            return(RedirectToAction("Index", "Home"));
        }