コード例 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            ResultPublication resultPublication = db.ResultPublications.Find(id);

            db.ResultPublications.Remove(resultPublication);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
 public ActionResult Edit([Bind(Include = "ID,DepartmentID,Semester,CalenderYear,PublicationDate")] ResultPublication resultPublication)
 {
     if (ModelState.IsValid)
     {
         db.Entry(resultPublication).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "Name", resultPublication.DepartmentID);
     return(View(resultPublication));
 }
コード例 #3
0
        // GET: ResultPublications/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ResultPublication resultPublication = db.ResultPublications.Find(id);

            if (resultPublication == null)
            {
                return(HttpNotFound());
            }
            return(View(resultPublication));
        }
コード例 #4
0
        // GET: ResultPublications/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ResultPublication resultPublication = db.ResultPublications.Find(id);

            if (resultPublication == null)
            {
                return(HttpNotFound());
            }
            ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "Name", resultPublication.DepartmentID);
            return(View(resultPublication));
        }
コード例 #5
0
        public ActionResult Create([Bind(Include = "ID,DepartmentID,Semester,CalenderYear,PublicationDate")] ResultPublication resultPublication)
        {
            ViewBag.DepartmentID = new SelectList(db.Departments, "DepartmentID", "Name", resultPublication.DepartmentID);

            if (ModelState.IsValid)
            {
                var assignments = db.Assignments
                                  .Where(e => e.DepartmentID == resultPublication.DepartmentID &&
                                         e.Semester == resultPublication.Semester &&
                                         e.CalenderYear == resultPublication.CalenderYear).ToList();
                if (!assignments.Any())
                {
                    ModelState.AddModelError("", "Can not calculate the result. No enrollments found");
                    return(View(resultPublication));
                }


                HashSet <string> CENotSubmittedCourses = new HashSet <string>();
                HashSet <string> FinalSubmittedCourses = new HashSet <string>();
                foreach (var assignment in assignments)
                {
                    if (!assignment.CESubmitted)
                    {
                        CENotSubmittedCourses.Add(assignment.Course.Title);
                        //ModelState.AddModelError("", "Marks of " + enrollment.Course.Title + " is not submitted yet");
                    }
                    if (!assignment.FinalSubmitted)
                    {
                        FinalSubmittedCourses.Add(assignment.Course.Title);
                        //ModelState.AddModelError("", "Marks of " + enrollment.Course.Title + " is not submitted yet");
                    }
                }

                if (CENotSubmittedCourses.Count != 0)
                {
                    ModelState.AddModelError("", "The following courses' continuos evalution marks are not submitted yet:\n");
                    foreach (var course in CENotSubmittedCourses)
                    {
                        ModelState.AddModelError("", course + "\n");
                    }
                }
                if (FinalSubmittedCourses.Count != 0)
                {
                    ModelState.AddModelError("", "The following courses' final marks are not submitted yet:\n");
                    foreach (var course in FinalSubmittedCourses)
                    {
                        ModelState.AddModelError("", course + "\n");
                    }
                }
                if (CENotSubmittedCourses.Count != 0 || FinalSubmittedCourses.Count != 0)
                {
                    return(View(resultPublication));
                }


                db.ResultPublications.Add(resultPublication);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(resultPublication));
        }