Exemplo n.º 1
0
        public ActionResult GeneratePDF(int reportID)
        {
            StudentHomeworkServices hServicies = new StudentHomeworkServices();
            int id = Int32.Parse(Request.Cookies["UserSettings"].Values["UserId"]);

            List <StudentHomeworkViewModel> List = hServicies.GetStudentHomeWorks(id);

            switch (reportID)
            {
            case 1:
                //  information = "best";
                List <StudentHomeworkViewModel> bestHM = List.Where(a => a.StatusID == "Accepted").OrderByDescending(a => a.Grade).Take(10).ToList();
                return(new Rotativa.ViewAsPdf("_Homeworks", bestHM));

            case 2:
                //  information = "Uploaded";
                return(new Rotativa.ViewAsPdf("_Homeworks", List.Where(a => a.StatusID == "Uploaded")));

            case 3:
                //   information = "Pending";
                return(new Rotativa.ViewAsPdf("_Homeworks", List.Where(a => a.StatusID == "Pending")));

            case 4:
                //    information = "Accepted";
                return(new Rotativa.ViewAsPdf("_Homeworks", List.Where(a => a.StatusID == "Accepted")));

            case 5:
                //  information = "Rejected";
                return(new Rotativa.ViewAsPdf("_Homeworks", List.Where(a => a.StatusID == "Rejected")));

            default:
                /// information = "all";
                return(new Rotativa.ViewAsPdf("_Homeworks", List));
            }
        }
        public ActionResult ViewDetails(int studentId, int sHId)
        {
            StudentHomeworkServices  service  = new StudentHomeworkServices();
            StudentHomeworkViewModel homework = service.GetHomeworkDetails(studentId, sHId);

            return(View(homework));
        }
        public ActionResult UploadHomeworkFiles(StudentHomeworkViewModel sh)
        {
            if (sh.files.ElementAt(0) == null)
            {
                return(RedirectToAction("Homeworks", "Student"));
            }
            string username = Request.Cookies["UserSettings"].Values["UserName"];

            string dir = "~/Homeworks/" + username + "/" + sh.SHomeID;

            bool   exists = System.IO.Directory.Exists(Server.MapPath(dir.ToString()));
            string myPath = sh.Path;

            foreach (var file in sh.files)
            {
                if (file != null)
                {
                    if (!exists)
                    {
                        System.IO.Directory.CreateDirectory(Server.MapPath(dir.ToString()));
                    }

                    var fileName = Path.GetFileName(file.FileName);
                    var path     = Path.Combine(Server.MapPath(dir.ToString()), fileName);
                    file.SaveAs(path);
                    myPath = fileName + " " + myPath;
                }
            }
            StudentHomeworkServices HService = new StudentHomeworkServices();

            HService.UpdateStudentHomework(sh.SHomeID, 0, "Uploaded", myPath);

            return(RedirectToAction("Homeworks", "Student"));
        }
Exemplo n.º 4
0
        public ActionResult StudentHomeworks(int studentId)
        {
            StudentHomeworkServices         service = new StudentHomeworkServices();
            List <StudentHomeworkViewModel> list    = service.GetStudentHomeWorks(studentId);

            return(View(list));
        }
Exemplo n.º 5
0
        public ActionResult Rejected(Rejected item)
        {
            string comments  = item.Comments;
            int    sHid      = item.SHomeID;
            int    studentId = item.StudentID;

            if (comments != "")
            {
                StudentHomeworkServices service = new StudentHomeworkServices();
                service.Rejected(sHid, comments, studentId);
                return(RedirectToAction("MyStudents", "Teacher"));
            }
            else
            {
                ModelState.AddModelError("", "Please add a comment to the reject homework!");
            }
            return(View());
        }
Exemplo n.º 6
0
        public ActionResult AddGrade(AddGrade item)
        {
            int grade     = item.Grade;
            int sHid      = item.SHomeID;
            int studentId = item.StudentID;

            if ((grade >= 1) && (grade <= 10))
            {
                StudentHomeworkServices service = new StudentHomeworkServices();
                service.AddGrade(sHid, grade, studentId);
                return(RedirectToAction("MyStudents", "Teacher"));
            }
            else
            {
                ModelState.AddModelError("", "Unable to add a grade.The grade must bee between 1 and 10");
            }
            return(View());
        }