public ActionResult DeleteConfirmed(Guid id) { ModuleAccreditation moduleAccreditation = Db.Accreditations.Find(id); Db.Accreditations.Remove(moduleAccreditation); Db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,IsMandatory")] ModuleAccreditation moduleAccreditation) { if (ModelState.IsValid) { Db.Entry(moduleAccreditation).State = EntityState.Modified; Db.SaveChanges(); return(RedirectToAction("Index")); } return(View(moduleAccreditation)); }
public ActionResult Create([Bind(Include = "Id,IsMandatory")] ModuleAccreditation moduleAccreditation) { if (ModelState.IsValid) { moduleAccreditation.Id = Guid.NewGuid(); Db.Accreditations.Add(moduleAccreditation); Db.SaveChanges(); return(RedirectToAction("Index")); } return(View(moduleAccreditation)); }
// GET: ModuleAccreditation/Delete/5 public ActionResult Delete(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ModuleAccreditation moduleAccreditation = Db.Accreditations.Find(id); if (moduleAccreditation == null) { return(HttpNotFound()); } return(View(moduleAccreditation)); }
/// <summary> /// /// </summary> /// <param name="moduleId"></param> /// <param name="critId"></param> /// <returns></returns> public ActionResult AccreditateModule(Guid moduleId, Guid critId) { var crit = Db.Criterias.SingleOrDefault(x => x.Id == critId); var module = Db.CurriculumModules.SingleOrDefault(x => x.Id == moduleId); var accr = new ModuleAccreditation { Criteria = crit, Module = module }; Db.Accreditations.Add(accr); Db.SaveChanges(); return(RedirectToAction("Details", new { id = crit.Id })); }
public ActionResult Import(CurriculumImportModel model, string orgName, string currName) { string tempFile = Path.GetTempFileName(); // Speichern der Config-Dateien model.AttachmentStructure?.SaveAs(tempFile); var org = Db.Organisers.SingleOrDefault(x => x.ShortName.Equals(orgName)); var curr = org.Curricula.SingleOrDefault(x => x.ShortName.Equals(currName)); var lines = System.IO.File.ReadAllLines(tempFile, Encoding.Default); var i = 0; foreach (var line in lines) { if (i > 0) { var words = line.Split(';'); var moduleName = words[0].Trim(); var weight = double.TryParse(words[1], out var result) ? result : 1; var subjectName = words[2].Trim(); var subjectTerm = int.TryParse(words[3], out var result2) ? result2 : 0; var subjectEcts = double.TryParse(words[4], out var result3) ? result3 : 0; var optionNumber = words[5].Trim(); var optionTags = words[6].Trim(); var module = curr.Modules.SingleOrDefault(x => x.Name.Equals(moduleName)); if (module == null) { module = new CertificateModule { Name = moduleName, Weight = weight }; curr.Modules.Add(module); } var subject = module.Subjects.FirstOrDefault(x => x.Name.Equals(subjectName)); if (subject == null) { subject = new CertificateSubject { Name = subjectName, Term = subjectTerm, Ects = subjectEcts }; module.Subjects.Add(subject); } var option = subject.ContentModules.SingleOrDefault(x => x.Number.Equals(optionNumber)); if (option == null) { option = new ModuleAccreditation { Number = optionNumber, IsMandatory = true, }; subject.ContentModules.Add(option); } } i++; } Db.SaveChanges(); return(RedirectToAction("Index", new { id = model.Curriculum.Id })); }