public ActionResult Print(int AnecdotalRecordID)
        {
            AnecdotalRecord check   = db.AnecdotalRecord.FirstOrDefault(x => x.AnecdotalRecordID == AnecdotalRecordID);
            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", "AnecdotalRecords"));
            }
            else if (check.CompletionDate == null)
            {
                TempData["Error"] = "No record found!";
                return(RedirectToAction("Student", "AnecdotalRecords"));
            }


            return(new ActionAsPdf(
                       "Report",
                       new { AnecdotalRecordID = AnecdotalRecordID })
            {
                FileName = string.Format("Anecdotal_Record_{0}.pdf", name + check.CompletionDate)
            });
        }
        public ActionResult Student(string UserID)
        {
            GetCurrentUserInViewBag();

            List <AnecdotalRecord> StudentInventorylist = new List <AnecdotalRecord>();
            var datalist = db.AnecdotalRecord.Where(x => x.StudentUserID == UserID).ToList();
            var student  = db.Students.FirstOrDefault(x => x.UserID == UserID);

            if (datalist.Count() != 0)
            {
                foreach (var item in datalist)
                {
                    AnecdotalRecord pvm = new AnecdotalRecord();
                    pvm.Place             = item.Place;
                    pvm.AnecdotalRecordID = item.AnecdotalRecordID;
                    pvm.CompletionDate    = item.CompletionDate;

                    StudentInventorylist.Add(pvm);
                }
                return(View(StudentInventorylist.ToList()));
            }
            else
            {
                TempData["Error"] = "No Anecdotal Reports under student: " + student.StudentLastName + ", " + student.StudentFirstName + "(" + student.StudentID + ")";
                return(RedirectToAction("Index"));
            }
        }
        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 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));
        }
        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"));
        }