Пример #1
0
        public ActionResult Uploadassignments(int tid, int cid, int secid, UploadAssignment at, HttpPostedFileBase file)
        {
            DB35Entities db = new DB35Entities();
            Assignment   a  = new Assignment();

            a.Name = file.FileName;

            a.TotalMarks = at.TotalMarks;
            string path = Path.Combine(Server.MapPath("~/TFiles"), Path.GetFileName(file.FileName));

            file.SaveAs(path);
            a.Path        = path;
            at.filename   = file.FileName;
            a.TeacherId   = tid;
            a.SectionId   = secid;
            a.CourseId    = cid;
            a.Title       = at.Title;
            a.Description = at.Desription;
            a.DueDate     = at.Duedate;
            db.Assignments.Add(a);
            db.SaveChanges();

            a.Title       = "";
            a.Description = "";
            a.DueDate     = DateTime.Now;
            a.TotalMarks  = 0;

            return(RedirectToAction("ViewAll", "Teacher", new { id = tid }));
        }
Пример #2
0
        public ActionResult DeleteResult(int id, int Tid)
        {
            DB35Entities db = new DB35Entities();

            foreach (StudentResult sr in db.StudentResults)
            {
                if (sr.ResultId == id)
                {
                    db.StudentResults.Remove(sr);
                }
            }
            db.SaveChanges();

            db.Results.Remove(db.Results.Find(id));
            db.SaveChanges();
            return(RedirectToAction("UploadedRes", new { id = Tid }));
        }
Пример #3
0
        public ActionResult EditResult(int id, StudentResultVM obj, decimal OMarks)
        {
            DB35Entities db = new DB35Entities();

            db.StudentResults.Find(id).ObtainedMarks = OMarks;
            db.SaveChanges();
            return(RedirectToAction("ResultSection", new { id = db.StudentResults.Find(id).ResultId }));
        }
Пример #4
0
        public ActionResult UploadResult(int StuRegNo, decimal OMarks, int Id)
        {
            DB35Entities  db = new DB35Entities();
            StudentResult sr = new StudentResult();

            sr.StudentId     = StuRegNo;
            sr.ResultId      = Id;
            sr.ObtainedMarks = OMarks;
            db.StudentResults.Add(sr);
            db.SaveChanges();
            return(RedirectToAction("UploadResult", new { id = Id }));
        }
        public ActionResult SubmitFiles(HttpPostedFileBase Zip, SubmitFiles obj, string q, int id)
        {
            string       path = "";
            DB35Entities db   = new DB35Entities();
            bool         done = false;

            foreach (SubmittedAssign e in db.SubmittedAssigns)
            {
                if (e.SubmittedBy == Convert.ToInt32(q) && e.Assignemnt == id)
                {
                    path   = Path.Combine(Server.MapPath("~/Files"), Path.GetFileName(Zip.FileName));
                    e.Path = path;
                    Zip.SaveAs(path);
                    e.FileName    = Zip.FileName;
                    e.Submited_On = DateTime.Now;
                    done          = true;
                    break;
                }
            }
            if (done)
            {
                db.SaveChanges();
                return(RedirectToAction("UploadedAssign", new { id = Convert.ToInt32(q) }));
            }
            path = Path.Combine(Server.MapPath("~/Files"), Path.GetFileName(Zip.FileName));
            Zip.SaveAs(path);
            SubmittedAssign sf = new Models.SubmittedAssign();

            sf.FileName    = Zip.FileName;
            sf.Path        = path;
            sf.Assignemnt  = id;
            sf.Submited_On = DateTime.Now;
            sf.SubmittedBy = Convert.ToInt32(q);
            db.SubmittedAssigns.Add(sf);
            db.SaveChanges();
            return(RedirectToAction("UploadedAssign", new { id = Convert.ToInt32(q) }));
        }
Пример #6
0
        public ActionResult TeacherRequestSubmit(/* int id,*/ SuggestionsVM svm)
        {
            DB35Entities db  = new DB35Entities();
            Person       p   = new Person();
            Teacher      st  = new Teacher();
            Suggestion   s   = new Suggestion();
            int          var = AdminController.var2;

            s.PersonId    = var;
            s.Subject     = svm.Subject;
            s.Description = svm.Description;
            s.Status      = db.LookUps.First(l => l.Value == "Pending").Id;

            db.Suggestions.Add(s);

            db.SaveChanges();

            return(RedirectToAction("LoggedInView", "Teacher", new { id = s.PersonId }));
        }
Пример #7
0
        public ActionResult Result(ResultVM r, int Course, int Section)
        {
            bool         find  = true;
            DB35Entities db    = new DB35Entities();
            int          check = 0;
            int          t     = db.Courses.First(c => c.CourseId == Course && c.SectionId == Section).TeacherId;
            Regex        T     = new Regex("[0-9a-zA-Z_]{1,20} | [0-9]{2,4}-[0-9]{2}");

            foreach (Result R in db.Results)
            {
                if (R.Title == r.Title && R.SectionId == Section)
                {
                    check = 1;
                    find  = false;
                    break;
                }
            }
            if (!T.IsMatch(r.Title))
            {
                find  = false;
                check = 2;
            }
            if (find)
            {
                Result re = new Models.Result();
                re.CourseId   = Course;
                re.SectionId  = Section;
                re.Title      = r.Title;
                re.TotalMarks = r.TotalMarks;
                db.Results.Add(re);
                db.SaveChanges();
                int Rid = db.Results.Max(e => e.ResultId);
                return(RedirectToAction("UploadResult", new { id = Rid }));
            }
            else
            {
                return(RedirectToAction("Result", new { id = Section, Tid = t, check = check, text = r.Title }));
            }
        }
Пример #8
0
        public ActionResult MarkAttendance(int id, FormCollection C)
        {
            DB35Entities db = new DB35Entities();

            List <int> Indexes = new List <int>();

            for (int i = 0; i < C.Count; i++)
            {
                if (C.Keys[i].StartsWith("Check_"))
                {
                    var s = C.Keys[i].Split('_');
                    Indexes.Add(Convert.ToInt32(s[1]));
                }
            }

            var  cid   = C["ClassId"];
            var  sid   = C["SectionId"];
            var  date  = C["date"];
            bool check = true;

            foreach (Attendance a in db.Attendances)
            {
                if (Convert.ToDateTime(date) == a.AttendanceDate)
                {
                    ViewBag.color   = "red";
                    ViewBag.Message = "Attandance has already been marked for " + date + " ";
                    ViewBag.Check   = false;
                    check           = false;
                    break;
                }
                else
                {
                    ViewBag.color   = "green";
                    ViewBag.Message = "Marked Successfully";
                    ViewBag.Check   = true;
                }
            }
            int d = 0;

            if (check == true)
            {
                Attendance at = new Attendance();
                at.AttendanceDate = Convert.ToDateTime(date);
                at.TeacherId      = id;
                at.ClassId        = Convert.ToInt32(cid);
                at.SectionId      = Convert.ToInt32(sid);

                db.Attendances.Add(at);
                d = at.AttendanceId;
                db.SaveChanges();


                int u = Convert.ToInt32(sid);

                foreach (Student s in db.Students.Where(x => x.SectionId == u).ToList())

                {
                    for (int i = 0; i < Indexes.Count; i++)
                    {
                        StudentAttendance st = new StudentAttendance();
                        if (Indexes[i] == s.Id)
                        {
                            st.Status       = db.LookUps.Where(x => x.Value == "Present").Single().Id;
                            st.AttendanceId = db.Attendances.Max(x => x.AttendanceId);
                            st.StudentId    = s.Id;
                            db.StudentAttendances.Add(st);
                            db.SaveChanges();
                        }
                        else
                        {
                            st.Status       = db.LookUps.Where(x => x.Value == "Absent").Single().Id;
                            st.AttendanceId = db.Attendances.Max(x => x.AttendanceId);
                            st.StudentId    = s.Id;
                            db.StudentAttendances.Add(st);
                            db.SaveChanges();
                        }
                    }
                }
            }
            return(View());
        }