// GET: CounsellingForms/Student/5 public ActionResult Student(string UserID) { GetCurrentUserInViewBag(); List <CounsellingForm> StudentInventorylist = new List <CounsellingForm>(); var datalist = db.CounsellingForm.Where(x => x.StudentUserID == UserID).ToList(); if (datalist.Count() != 0) { foreach (var item in datalist) { CounsellingForm pvm = new CounsellingForm(); pvm.CounsellingFormID = item.CounsellingFormID; pvm.CompletionDate = item.CompletionDate; StudentInventorylist.Add(pvm); } return(View(StudentInventorylist.ToList())); } else { TempData["Error"] = "This user has no existing counselling records!"; return(RedirectToAction("Index")); } }
public ActionResult Print(int CounsellingFormID) { CounsellingForm check = db.CounsellingForm.FirstOrDefault(x => x.CounsellingFormID == CounsellingFormID); var student = db.Students.FirstOrDefault(x => x.UserID == check.StudentUserID); var name = student.StudentLastName + ", " + student.StudentFirstName + " "; if (check == null) { TempData["Error"] = "No record found!"; return(RedirectToAction("Student", "CounsellingForms")); } else if (check.CompletionDate == null) { TempData["Error"] = "No record found!"; return(RedirectToAction("Student", "CounsellingForms")); } return(new ActionAsPdf( "Details", new { CounsellingFormID = CounsellingFormID }) { FileName = string.Format("Counselling_Form_{0}.pdf", name + check.CompletionDate) }); }
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 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 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")); }