Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            CurriculumPackage curriculumPackage = Db.CurriculumPackages.Find(id);

            Db.CurriculumPackages.Remove(curriculumPackage);
            Db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "Id,Name")] CurriculumPackage curriculumPackage)
 {
     if (ModelState.IsValid)
     {
         Db.Entry(curriculumPackage).State = EntityState.Modified;
         Db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(curriculumPackage));
 }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Include = "Id,Name")] CurriculumPackage curriculumPackage)
        {
            if (ModelState.IsValid)
            {
                curriculumPackage.Id = Guid.NewGuid();
                Db.CurriculumPackages.Add(curriculumPackage);
                Db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(curriculumPackage));
        }
Ejemplo n.º 4
0
        // GET: CurriculumPackage/Delete/5
        public ActionResult Delete(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CurriculumPackage curriculumPackage = Db.CurriculumPackages.Find(id);

            if (curriculumPackage == null)
            {
                return(HttpNotFound());
            }
            return(View(curriculumPackage));
        }
Ejemplo n.º 5
0
        private CurriculumRequirement GetModule(TimeTableDbContext db, TimeTable.Data.Curriculum curriculum, CieCourse scheduleCourse)
        {
            var pck = curriculum.Packages.FirstOrDefault();

            if (curriculum.ShortName.Equals("WI") && pck != null)
            {
                pck = curriculum.Packages.SingleOrDefault(x => x.Name.Equals("Wahlpflicht"));
            }

            if (pck == null)
            {
                pck      = new CurriculumPackage();
                pck.Name = "Studium";
                curriculum.Packages.Add(pck);
                db.CurriculumPackages.Add(pck);
            }

            var option = pck.Options.FirstOrDefault();

            if (option == null)
            {
                option         = new PackageOption();
                option.Name    = "Gesamt";
                option.Package = pck;
                db.PackageOptions.Add(option);
            }

            var module =
                option.Requirements.FirstOrDefault(x => x.Name.ToLower().Equals(scheduleCourse.name.ToLower()));

            if (module == null)
            {
                module           = new CurriculumRequirement();
                module.Name      = scheduleCourse.name;
                module.ECTS      = scheduleCourse.ects;
                module.USCredits = scheduleCourse.usCredits;
                module.SWS       = scheduleCourse.semesterWeekHours;

                option.Requirements.Add(module);
            }

            db.SaveChanges();

            return(module);
        }
Ejemplo n.º 6
0
        public ActionResult CreateFromCourse(ModuleCreateViewModel model)
        {
            var course = Db.Activities.OfType <Course>().SingleOrDefault(x => x.Id == model.Course.Id);
            var curr   = Db.Curricula.SingleOrDefault(x => x.Id == model.Curriculum.Id);

            var pck = curr.Packages.SingleOrDefault(x => x.Name.Equals("Gesamt"));

            if (pck == null)
            {
                pck = new CurriculumPackage
                {
                    Curriculum = curr,
                    Name       = "Gesamt",
                };

                Db.CurriculumPackages.Add(pck);
                Db.SaveChanges();
            }

            var option = pck.Options.SingleOrDefault(x => x.Name.Equals("Standard"));

            if (option == null)
            {
                option = new PackageOption
                {
                    Package = pck,
                    Name    = "Standard"
                };

                Db.PackageOptions.Add(option);
                Db.SaveChanges();
            }


            // Doppelte ausschließen
            var isExisting = option.Requirements.Any(x =>
                                                     x.Name.Equals(model.Name) || x.ShortName.Equals(model.ShortName) ||
                                                     x.CatalogId.Equals(model.CatalogId));

            if (isExisting)
            {
                ModelState.AddModelError("", "Modul existiert bereits");

                // Modell wieder vervollständigen
                model.Course     = course;
                model.Curriculum = curr;
                model.MV         = GetMyMembership();

                return(View(model));
            }


            var module = new CurriculumRequirement
            {
                Name             = model.Name,
                ShortName        = model.ShortName,
                CatalogId        = model.CatalogId,
                ECTS             = model.Ects,
                SWS              = model.Sws,
                USCredits        = model.UsCredits,
                LecturerInCharge = GetMyMembership(),
                Option           = option,
            };

            Db.Requirements.Add(module);

            var nexus = new CourseModuleNexus
            {
                Course      = course,
                Requirement = module
            };

            Db.CourseNexus.Add(nexus);

            Db.SaveChanges();


            return(RedirectToAction("Admin", "Course", new { id = course.Id }));
        }