// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } // I still don't understand what this does StudentRepository.SetConfig(Configuration); CohortRepository.SetConfig(Configuration); ExerciseRepository.SetConfig(Configuration); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
// GET: Cohorts/Details/5 public ActionResult Details(int id) { //encapsulation StudentRepository.GetStudent var cohort = CohortRepository.GetCohort(id); return(View(cohort)); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } StudentRepository.SetConfig(Configuration); CohortRepository.SetConfig(Configuration); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
public void EnsureContextIsNotNull() { CohortRepository repo = new CohortRepository(); var context = repo.CohortDatabase; Assert.IsNotNull(context); }
public void EnsureICanInjectContext() { //Arrange var context = new CohortContext(); var repo = new CohortRepository(context); //Assert Assert.IsNotNull(repo.Context); }
public void Setup() { fake_cohort_table = new List <Cohort>(); fake_instructor_table = new List <Instructor>(); fake_student_table = new List <Student>(); mock_context = new Mock <CohortContext>(); mock_cohort_set = new Mock <DbSet <Cohort> >(); repo = new CohortRepository(mock_context.Object); }
public void MakeCohortSelectList() { List <Cohort> cohorts = CohortRepository.GetAllCohorts(); Cohorts = cohorts.Select(li => new SelectListItem { Text = li.CohortName, Value = li.Id.ToString() }).ToList(); }
public ActionResult Delete(int id, IFormCollection collection) { if (CohortRepository.DeleteCohort(id)) { return(RedirectToAction(nameof(Index))); } else { return(RedirectToAction(nameof(Details), new { id = id })); } }
public void EnsureICanCreateAnInstance() { //Arrange var repo = new CohortRepository(); //Act var context = repo.Context; //Assert Assert.IsNotNull(context); }
public void EnsureCohortExist_Should_Return_Instance_Of_Type_Long() { // Arrange var context = new CompetentieAppFrontendContext(_options); var repository = new CohortRepository(context); // Act var result = repository.EnsureCohortExist("2030/2031"); // Assert Assert.IsInstanceOfType(result, typeof(long)); }
public void EnsureCohortExist_Should_Not_Duplicate_Entry() { // Arrange var context = new CompetentieAppFrontendContext(_options); var repository = new CohortRepository(context); // Act var result = repository.EnsureCohortExist("2018-2019"); // Assert Assert.AreEqual(1, result); }
public ActionResult DeleteConfirmed(int id) { try { CohortRepository.DeleteCohort(id); return(RedirectToAction(nameof(Index))); } catch { return(RedirectToAction(nameof(Details))); } }
public void EnsureCohortExist_Should_Save_New_Cohorts() { // Arrange var context = new CompetentieAppFrontendContext(_options); var repository = new CohortRepository(context); // Act var result = repository.EnsureCohortExist("2030/2031"); // Assert Assert.AreEqual(2, result); }
public ActionResult Edit(int id, Cohort cohort) { try { cohort.Id = id; CohortRepository.EditCohort(cohort); return(RedirectToAction(nameof(Index))); } catch (Exception) { return(View(cohort)); } }
public void Setup() { mockContext = new Mock <CohortContext>(); mockCohortList = new List <Cohort>(); mockStudentList = new List <Student>(); mockInstructorList = new List <Instructor>(); mockCohortSet = new Mock <DbSet <Cohort> >(); mockStudentSet = new Mock <DbSet <Student> >(); mockInstructorSet = new Mock <DbSet <Instructor> >(); repo = new CohortRepository(mockContext.Object); }
public void BuildCohortOptions() { Cohorts = CohortRepository.GetAllCohorts() .Select(li => new SelectListItem { Text = li.Designation, Value = li.Id.ToString() }).ToList(); Cohorts.Insert(0, new SelectListItem { Text = "Choose cohort...", Value = "0" }); }
public void CohortSelectFactory() { var cohorts = CohortRepository.GetCohorts(); Cohorts = cohorts.Select(li => new SelectListItem { Text = li.Name, Value = li.Id.ToString() }).ToList(); Cohorts.Insert(0, new SelectListItem { Text = "Choose cohort ...", Value = "0", }); }
// GET: Students/Details/5 public ActionResult Details(int id) { var cohort = CohortRepository.GetCohort(id); return(View(cohort)); }
// GET: Cohorts/Delete/5 public ActionResult DeleteConfirm(int id) { var cohort = CohortRepository.GetCohort(id); return(View(cohort)); }
public ActionResult Create([FromForm] Cohort cohort) { Cohort newCohort = CohortRepository.CreateCohort(cohort); return(RedirectToAction(nameof(Index))); }
// GET: Students public ActionResult Index() { var cohorts = CohortRepository.GetCohorts(); return(View(cohorts)); }
// GET: Cohort public ActionResult Index(string _orderBy) { var cohorts = CohortRepository.GetAllCohorts(); return(View(cohorts)); }
public void EnureICanCreateInstance() { CohortRepository repo = new CohortRepository(); Assert.IsNotNull(repo); }
public ActionResult Create([FromForm] Cohort model) { var cohort = CohortRepository.CreateCohort(model); return(RedirectToAction(nameof(Index))); }
// GET: Cohort/Edit/5 public ActionResult Edit(int id) { var model = CohortRepository.GetCohort(id); return(View(model)); }
// GET: Cohort/Create public ActionResult CreateFrom() { CohortRepository.GetCohorts(); return(View()); }
public ActionResult Create(Cohort cohort) { CohortRepository.CreateCohort(cohort); return(View(cohort)); }
public ActionResult Create(Cohort cohort, IFormCollection collection) { CohortRepository.CreateCohort(cohort); return(RedirectToAction(nameof(Index))); }