123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- using Microsoft.EntityFrameworkCore;
- using Ropin.Inspection.Model;
- using Ropin.Inspection.Model.Entities;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Ropin.Inspection.Repository
- {
- public class TbdmProvRepository : RepositoryBase<TBDM_Prov, Guid>, ITbdmProvRepository
- {
- public TbdmProvRepository(InspectionDbContext DbContext) : base(DbContext)
- {
- }
- public async Task<List<TbdmProvViewModel>> GetProvListTreeAsync()
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var Prov = DbContext.TBDM_Prov.ToList();
- var City = DbContext.TBDM_City.ToList();
- var Area = DbContext.TBDM_Area.ToList();
- var treeList = new List<TbdmProvViewModel>();
- foreach (var itemProv in Prov.Where(p => p.C_Status == "1"))
- {
- TbdmProvViewModel provModel = new TbdmProvViewModel()
- {
- C_Code = itemProv.C_Code,
- C_Name = itemProv.C_Name,
- I_Sort = itemProv.I_Sort,
- C_Status = itemProv.C_Status
- };
- provModel.Children = new List<TbdmCity>();
- foreach (var itemCity in City.Where(c => c.C_Status == "1" && c.C_ProvCode == itemProv.C_Code))
- {
- TbdmCity cityModel
- = new TbdmCity()
- {
- C_Code = itemCity.C_Code,
- C_ProvCode = itemProv.C_Code,
- C_Name = itemCity.C_Name,
- I_Sort = itemCity.I_Sort,
- C_Status = itemCity.C_Status
- };
- provModel.Children.Add(cityModel);
- cityModel.Children = await RecursionArea(Area, itemCity.C_Code);
-
-
-
-
-
-
-
-
-
-
-
-
- }
- treeList.Add(provModel);
- }
- return await Task.Run(() => treeList);
- }
- async Task<List<TbdmArea>> RecursionArea(List<TBDM_Area> Area, string cityCode)
- {
- var areaList = new List<TbdmArea>();
- foreach (var itemArea in Area.Where(a => a.C_Status == "1" && a.C_CityCode == cityCode))
- {
- TbdmArea areaModel = new TbdmArea()
- {
- C_Code = itemArea.C_Code,
- C_CityCode = cityCode,
- C_Name = itemArea.C_Name,
- I_Sort = itemArea.I_Sort,
- C_Status = itemArea.C_Status
- };
- areaList.Add(areaModel);
- }
- return await Task.Run(() => areaList);
- }
- }
- }
|