Beispiel #1
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));
        }
Beispiel #2
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);
            }
        }