Esempio n. 1
0
        // 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));
        }
Esempio n. 3
0
        // 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?}");
            });
        }
Esempio n. 4
0
        public void EnsureContextIsNotNull()
        {
            CohortRepository repo = new CohortRepository();
            var context           = repo.CohortDatabase;

            Assert.IsNotNull(context);
        }
Esempio n. 5
0
        public void EnsureICanInjectContext()
        {
            //Arrange
            var context = new CohortContext();
            var repo    = new CohortRepository(context);

            //Assert
            Assert.IsNotNull(repo.Context);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        public void MakeCohortSelectList()
        {
            List <Cohort> cohorts = CohortRepository.GetAllCohorts();

            Cohorts = cohorts.Select(li => new SelectListItem
            {
                Text  = li.CohortName,
                Value = li.Id.ToString()
            }).ToList();
        }
Esempio n. 8
0
 public ActionResult Delete(int id, IFormCollection collection)
 {
     if (CohortRepository.DeleteCohort(id))
     {
         return(RedirectToAction(nameof(Index)));
     }
     else
     {
         return(RedirectToAction(nameof(Details), new { id = id }));
     }
 }
Esempio n. 9
0
        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);
        }
Esempio n. 12
0
 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);
        }
Esempio n. 14
0
 public ActionResult Edit(int id, Cohort cohort)
 {
     try
     {
         cohort.Id = id;
         CohortRepository.EditCohort(cohort);
         return(RedirectToAction(nameof(Index)));
     }
     catch (Exception)
     {
         return(View(cohort));
     }
 }
Esempio n. 15
0
        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);
        }
Esempio n. 16
0
        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"
            });
        }
Esempio n. 17
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",
            });
        }
Esempio n. 18
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));
        }
Esempio n. 20
0
        public ActionResult Create([FromForm] Cohort cohort)
        {
            Cohort newCohort = CohortRepository.CreateCohort(cohort);

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 21
0
        // GET: Students
        public ActionResult Index()
        {
            var cohorts = CohortRepository.GetCohorts();

            return(View(cohorts));
        }
Esempio n. 22
0
        // GET: Cohort
        public ActionResult Index(string _orderBy)
        {
            var cohorts = CohortRepository.GetAllCohorts();

            return(View(cohorts));
        }
Esempio n. 23
0
        public void EnureICanCreateInstance()
        {
            CohortRepository repo = new CohortRepository();

            Assert.IsNotNull(repo);
        }
Esempio n. 24
0
        public ActionResult Create([FromForm] Cohort model)
        {
            var cohort = CohortRepository.CreateCohort(model);

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 25
0
        // 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)));
 }