Exemple #1
0
        public void GetAllApplicationsShouldNotWork()
        {
            var options = new DbContextOptionsBuilder <development_pathways_dbContext>()
                          .UseInMemoryDatabase(databaseName: "getallpeople_2")
                          .Options;

            // Use a clean instance of the context to run the test
            using (var context = new development_pathways_dbContext(options))
            {
                ApplicationBusinessLogic  applicationController = new ApplicationBusinessLogic(context);
                IEnumerable <Application> applications          = applicationController.GetAllApplications();
                Assert.NotNull(applications);
                Assert.Empty(applications);
            }
        }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("ApplicationId,FullName,DateOfBirth,MaritalStatus,IdNumber,County,SubCounty,Location,SubLocation,Village,PostalAddress,PhysicalAddress,PoorElderlyPersons,OrphanAndVulnerableChildren,PersonsWithDisability,PersonsInExtremePoverty,AnyOther,InfoCollectedBy,DesignationOfCollector,DateOfCollection,CreatedAt")] Application application)
        {
            if (ModelState.IsValid)
            {
                var business = new ApplicationBusinessLogic(_context);
                await business.SaveApplication(application);

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["County"]      = new SelectList(_context.Counties, "CountyId", "CountyName", application.County);
            ViewData["Location"]    = new SelectList(_context.Locations, "LocationId", "LocationName", application.Location);
            ViewData["SubCounty"]   = new SelectList(_context.SubCounties, "SubCountyId", "SubCountyName", application.SubCounty);
            ViewData["SubLocation"] = new SelectList(_context.SubLocations, "SubLocationId", "SubLocationName", application.SubLocation);
            ViewData["Village"]     = new SelectList(_context.Villages, "VillageId", "VillageName", application.Village);
            return(View(application));
        }
Exemple #3
0
        public ActionResult Index()
        {
            ApplicationViewModel mymodel = new ApplicationViewModel();

            var business = new ApplicationBusinessLogic(_context);
            var model    = business.GetAllApplications();

            mymodel.Applications           = model.ToList();
            mymodel.ApplicationSearchModel = new ApplicationSearchModel();

            ViewData["County"]      = new SelectList(_context.Counties, "CountyId", "CountyName");
            ViewData["Location"]    = new SelectList(_context.Locations, "LocationId", "LocationName");
            ViewData["SubCounty"]   = new SelectList(_context.SubCounties, "SubCountyId", "SubCountyName");
            ViewData["SubLocation"] = new SelectList(_context.SubLocations, "SubLocationId", "SubLocationName");
            ViewData["Village"]     = new SelectList(_context.Villages, "VillageId", "VillageName");

            return(View(mymodel));
        }
Exemple #4
0
        public async Task SaveApplicationShouldWorkAsync()
        {
            var options = new DbContextOptionsBuilder <development_pathways_dbContext>()
                          .UseInMemoryDatabase(databaseName: "saveapplication_1")
                          .Options;

            // Use a clean instance of the context to run the test
            using (var context = new development_pathways_dbContext(options))
            {
                Application person = new Application {
                    ApplicationId = 1, FullName = "Test Name", IdNumber = "XXXC", SubCounty = 1
                };
                ApplicationBusinessLogic personController = new ApplicationBusinessLogic(context);
                int rows = await personController.SaveApplication(person);

                Assert.Equal(1, rows);
            }
        }