private Result GetCourses() { var CourseProvider = new CourseProvider(); var courses = CourseProvider.GetAll(); return(new Result() { Courses = courses }); }
public void GetAll_Should_Return5Rows() { var courses = new CourseProvider().GetAll(); courses.Should() .NotBeNull() .And .NotBeEmpty() .And .HaveCount(5); }
public void CanAddPreference() { Professor p = new ProfessorProvider(session).GetProfessorByID(19); Course c = new CourseProvider(session).GetCourseByID(6); var prefID = new PreferencesId(p, c); var pref = new Preference(prefID) { Weight = 3 }; provider.AddPreference(pref); Preference testPref = provider.GetPreferenceByProfIdAndCourseId(19, 6); Assert.AreEqual(c, testPref.Id.Course); Assert.AreEqual(p, testPref.Id.Professor); //Assert.IsNotNull(testPref); //provider.AddPreference(pref); }
/// <summary> /// Die Suche nach den Kursen wird hier angestoßen, und das Ergebnis angezeigt /// </summary> private void Bw_DoWork(object sender, DoWorkEventArgs e) { Task <IDS> taskIDS = Task <IDS> .Factory.StartNew(() => new IDS()); Task <Integrata> taskIntegrata = Task <Integrata> .Factory.StartNew(() => new Integrata()); Task <Techdata> taskTechData = Task <Techdata> .Factory.StartNew(d => new Techdata((List <string>)d), Program.listExcludeForTechData); Task.WaitAll(new Task[] { taskIDS, taskIntegrata, taskTechData }); List <Kurse> idsAll = taskIDS.Result.GetCourse; List <Kurse> idsIntegrata = taskIDS.Result.GetCourseIntegrata; List <Kurse> idsTechData = taskIDS.Result.GetCourseTechData; List <Kurse> techdata = taskTechData.Result.GetCourse; List <Kurse> integrata = taskIntegrata.Result.GetCourse; CourseProvider.RemoveMatches(integrata, idsIntegrata); CourseProvider.RemoveMatches(techdata, idsTechData); lstViewIntegrata.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate() { lstViewIntegrata.ItemsSource = integrata; lstViewIDSIntegrata.ItemsSource = idsIntegrata; lstViewTechData.ItemsSource = techdata; lstViewIDSTechData.ItemsSource = idsTechData; lstViewIntegrata.Visibility = Visibility.Visible; lstViewIDSIntegrata.Visibility = Visibility.Visible; lstViewTechData.Visibility = Visibility.Visible; lstViewIDSTechData.Visibility = Visibility.Visible; if (integrata.Count < 1) { lstViewIntegrata.Visibility = Visibility.Collapsed; } if (idsIntegrata.Count < 1) { lstViewIDSIntegrata.Visibility = Visibility.Collapsed; } if (techdata.Count < 1) { lstViewTechData.Visibility = Visibility.Collapsed; } if (idsTechData.Count < 1) { lstViewIDSTechData.Visibility = Visibility.Collapsed; } }); }
public void CanAssCourse() { provider = new CourseProvider(); // DaysOfWeek = "MWF" var course = new Course { CourseName = "CSTest", Monday = true, Friday = true, StartHour = 13, StartMinute = 0, EndHour = 14, EndMinute = 15, AssignedProfessor = null }; var newIdentity = provider.AddCourse(course); var testCourse = provider.GetCourseByID(newIdentity); Assert.Equal(testCourse.EndHour, 14); }
public Loader() { stats = CitizensApi.GetStats(); local_course = CourseProvider.GetLocalCourse(); crypto_course = CourseProvider.GetCryptoCourse(); }
public object Edit([Bind(Prefix = "")] Course course, string id, string ProfessorList) { ViewData["Title"] = "Edit Course"; ViewData["Message"] = "Edit Course Details!"; var cp = new CourseProvider(); int courseId; try { courseId = Convert.ToInt32(id); } catch (Exception) //not an integer { return RedirectToAction("Index", "Course"); } course = cp.GetCourseByID(courseId); // redisplay form immediately if there are input format errors if (!ModelState.IsValid) { ModelState.CopyValidationExceptions(); PrepareProfessorList(course); return View("Edit", course); } try { UpdateModel(course, new[] { "CourseName", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "StartHour", "StartMinute", "EndHour", "EndMinute"}); if (!ProfessorList.Equals("0")) { Professor prof = new ProfessorProvider().GetProfessorByID(Convert.ToInt32(ProfessorList)); course.AssignedProfessor = prof; } else { course.AssignedProfessor = null; } cp.UpdateCourse(course); return View("Saved"); } catch (RuleViolationException vex) { ViewData.ModelState.CopyValidationExceptions(vex); PrepareProfessorList(course); return View(course); } catch (Exception err) { ViewData.ModelState.CopyValidationExceptions(err, "course"); PrepareProfessorList(course); return View(course); } }
public ActionResult Delete(string id) { var cp = new CourseProvider(); if (!string.IsNullOrEmpty(id)) { int courseId; try { courseId = Convert.ToInt32(id); } catch (Exception) //not an integer { return RedirectToAction("Index", "Course"); } try { Course course = cp.GetCourseByID(courseId); if (course != null) { cp.DeleteCourse(course); return View("Deleted"); } return RedirectToAction("Index"); } catch (Exception err) { if (err.InnerException != null && err.InnerException.Message.Contains("The DELETE statement conflicted with the REFERENCE constraint")) { ViewData["ErrorMessage"] = "Course could not be deleted.. there are assoiciated data.. cannot delete"; } else { ViewData["ErrorMessage"] = "Course Could not be deleted.. there is a problem"; } return View("NotDeleted"); } } return RedirectToAction("Index"); }
public void TestMethod1() { var s = new CourseProvider(); s.GetAllCourses(); }
public void Setup() { DatabaseSetUp(); session = sessionManager.GetSession(); provider = new CourseProvider(session); }