public async Task <ActionResult <List <Contract_NationDTO> > > SingleListNation([FromBody] Contract_NationFilterDTO Contract_NationFilterDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            NationFilter NationFilter = new NationFilter();

            NationFilter.Skip      = 0;
            NationFilter.Take      = 20;
            NationFilter.OrderBy   = NationOrder.Id;
            NationFilter.OrderType = OrderType.ASC;
            NationFilter.Selects   = NationSelect.ALL;
            NationFilter.Id        = Contract_NationFilterDTO.Id;
            NationFilter.Code      = Contract_NationFilterDTO.Code;
            NationFilter.Name      = Contract_NationFilterDTO.Name;
            NationFilter.Priority  = Contract_NationFilterDTO.DisplayOrder;
            NationFilter.StatusId  = new IdFilter {
                Equal = StatusEnum.ACTIVE.Id
            };

            List <Nation> Nations = await NationService.List(NationFilter);

            List <Contract_NationDTO> Contract_NationDTOs = Nations
                                                            .Select(x => new Contract_NationDTO(x)).ToList();

            return(Contract_NationDTOs);
        }
Example #2
0
        public void ParseMunicipality(MunicipalityService ms, NationService ns)
        {
            // Clears the database of Nations/Munincipality
            var myNations = ns.Get();

            foreach (var i in myNations)
            {
                ns.Remove(i);
            }

            var myMunicipality = ms.Get();

            foreach (var i in myMunicipality)
            {
                ms.Remove(i);
            }

            var dk = new Nation()
            {
                NationName = "Danmark",
                NationID   = "1"
            };

            ns.Create(dk);

            string line   = "";
            var    reader = new StreamReader("./Municipality_test_pos.csv");

            reader.ReadLine(); // Skip first

            while ((line = reader.ReadLine()) != null)
            {
                var data       = line.Split(";");
                var population = float.Parse(data[4].Trim());

                var mun = new Municipality()
                {
                    MunicipalityID = int.Parse(data[0].Trim()),
                    Name           = data[1].Trim(),
                    Population     = population,
                    NationName     = "Danmark"
                };

                Municipalities.Add(int.Parse(data[0].Trim()));

                ms.Create(mun);
            }
            reader.Close();
        }
Example #3
0
        public ActionResult AddNew()
        {
            NationService ntnService = new NationService();
            IEnumerable <SchoolDTO.NationDTO> nations = ntnService.GetAll();

            //将民族包装为SelectList类型,传到View,提供给Html.DropDownList
            //SelectList slNation = new SelectList(nations, "Id", "Name");
            //使用nameof()函数获取变量名,可以避免打字错误,编译其更容易发现错误
            //第二个参数:下拉列表的value属性,第三个参数:下拉列表的显示属性
            SelectList slNation = new SelectList(nations, nameof(Nation.Id), nameof(Nation.Name));


            //因为传输的数据比较单一,所以不封装为ViewModel类了
            //todo:班级的DropDownlist
            return(View(slNation));
        }
Example #4
0
        static void Main(string[] args)
        {
            CitizenService              cs   = new CitizenService();
            LocationService             ls   = new LocationService();
            MunicipalityService         ms   = new MunicipalityService();
            NationService               ns   = new NationService();
            TestCenterService           tcs  = new TestCenterService();
            TestCenterManagementService tcms = new TestCenterManagementService();

            LocationCitizenService   lcs  = new LocationCitizenService();
            TestCenterCitizenService tccs = new TestCenterCitizenService();

            GenerateFunctions gf = new GenerateFunctions();
            CreateFunctions   cf = new CreateFunctions();

            int  choice;
            int  choice2;
            bool finished       = false;
            bool finishedSearch = false;


            // program start
            Console.WriteLine("Make a choice! \n" +
                              " 1: Add Denmark municipality and random dummy data\n" +
                              " 2: Empty database");
            choice = Convert.ToInt32(Console.ReadLine());
            switch (choice)
            {
            case 1:
                Console.Clear();
                gf.ParseMunicipality(ms, ns);
                gf.GenerateTestCenter(tcs, 100);
                gf.GenerateCitizens(cs, 100);
                gf.AddCitizenToTestCenter(cs, tcs, tccs);
                gf.GenerateLocation(ls, 100);
                gf.AddCitizenToLocation(cs, ls, lcs, 100);
                gf.GenerateTestCenterManagement(tcms, tcs, 100);
                break;

            case 2:
                Console.Clear();
                break;
            }

            choice = 0;
            do
            {
                Console.Clear();
                Console.WriteLine("Choose an option... \n" +
                                  " 1: Create Citizen\n" +
                                  " 2: Create Test Center\n" +
                                  " 3: Create Management\n" +
                                  " 4: Create Test Case\n" +
                                  " 5: Create Location\n" +
                                  " 6: Create LocationCitizen\n" +
                                  " 7: Search the database\n" +
                                  " 0: Exit");

                choice = Convert.ToInt32(Console.ReadLine());
                switch (choice)
                {
                case 1:
                    cf.createCitizen(cs);
                    break;

                case 2:
                    cf.createTestCenter(tcs);
                    break;

                case 3:
                    cf.createManagement(tcms, tcs);
                    break;

                case 4:
                    cf.createTestCase(cs, tcs, tccs, lcs);
                    break;

                case 5:
                    cf.createLocation(ls);
                    break;

                case 6:
                    cf.createLocationCitizen(lcs, cs, ls);
                    break;

                case 7:
                    Console.Clear();
                    do
                    {
                        Console.Clear();
                        Console.WriteLine("What do you want to search by? \n" +
                                          " 1: Search by name\n" +
                                          " 2: Search by age groups\n" +
                                          " 3: Search by gender\n" +
                                          " 4: Search by municipality\n" +
                                          " 0: Exit search");

                        choice2 = Convert.ToInt32(Console.ReadLine());
                        switch (choice2)
                        {
                        case 1:
                            cf.searchForCitizen(cs);
                            break;

                        case 2:
                            cf.searchforAge(tccs);
                            break;

                        case 3:
                            cf.searchforSex(tccs);
                            break;

                        case 4:
                            cf.SearchForMunincipality(tccs);
                            break;

                        case 0:
                            finishedSearch = true;
                            break;
                        }
                    } while (finishedSearch == false);
                    break;

                case 0:
                    finished = true;
                    break;
                }
            } while (finished == false);
        }