void LoadEntities(string worldId) { IBiomeRepository biomeRepository = new BiomeRepository(Path.Combine(ApplicationPaths.WorldsDirectory, worldId, "biomes.xml")); IBorderRepository borderRepository = new BorderRepository(Path.Combine(ApplicationPaths.WorldsDirectory, worldId, "borders.xml")); ICultureRepository cultureRepository = new CultureRepository(Path.Combine(ApplicationPaths.WorldsDirectory, worldId, "cultures.xml")); IFactionRepository factionRepository = new FactionRepository(Path.Combine(ApplicationPaths.WorldsDirectory, worldId, "factions.xml")); IFlagRepository flagRepository = new FlagRepository(Path.Combine(ApplicationPaths.WorldsDirectory, worldId, "flags.xml")); IHoldingRepository holdingRepository = new HoldingRepository(Path.Combine(ApplicationPaths.WorldsDirectory, worldId, "holdings.xml")); IProvinceRepository provinceRepository = new ProvinceRepository(Path.Combine(ApplicationPaths.WorldsDirectory, worldId, "provinces.xml")); IResourceRepository resourceRepository = new ResourceRepository(Path.Combine(ApplicationPaths.WorldsDirectory, worldId, "resources.xml")); IUnitRepository unitRepository = new UnitRepository(Path.Combine(ApplicationPaths.WorldsDirectory, worldId, "units.xml")); IWorldRepository worldRepository = new WorldRepository(ApplicationPaths.WorldsDirectory); IEnumerable <Biome> biomeList = biomeRepository.GetAll().ToDomainModels(); IEnumerable <Border> borderList = borderRepository.GetAll().ToDomainModels(); IEnumerable <Culture> cultureList = cultureRepository.GetAll().ToDomainModels(); IEnumerable <Faction> factionList = factionRepository.GetAll().ToDomainModels(); IEnumerable <Flag> flagList = flagRepository.GetAll().ToDomainModels(); IEnumerable <Province> provinceList = provinceRepository.GetAll().ToDomainModels(); IEnumerable <Resource> resourceList = resourceRepository.GetAll().ToDomainModels(); IEnumerable <Unit> unitList = unitRepository.GetAll().ToDomainModels(); armies = new ConcurrentDictionary <Tuple <string, string>, Army>(); biomes = new ConcurrentDictionary <string, Biome>(biomeList.ToDictionary(biome => biome.Id, biome => biome)); borders = new ConcurrentDictionary <Tuple <string, string>, Border>(borderList.ToDictionary(border => new Tuple <string, string>(border.SourceProvinceId, border.TargetProvinceId), border => border)); cultures = new ConcurrentDictionary <string, Culture>(cultureList.ToDictionary(culture => culture.Id, culture => culture)); factions = new ConcurrentDictionary <string, Faction>(factionList.ToDictionary(faction => faction.Id, faction => faction)); flags = new ConcurrentDictionary <string, Flag>(flagList.ToDictionary(flag => flag.Id, flag => flag)); holdings = new ConcurrentDictionary <string, Holding>(); provinces = new ConcurrentDictionary <string, Province>(provinceList.ToDictionary(province => province.Id, province => province)); relations = new ConcurrentDictionary <Tuple <string, string>, Relation>(); resources = new ConcurrentDictionary <string, Resource>(resourceList.ToDictionary(resource => resource.Id, resource => resource)); units = new ConcurrentDictionary <string, Unit>(unitList.ToDictionary(unit => unit.Id, unit => unit)); world = worldRepository.Get(worldId).ToDomainModel(); }
public ActionResult <ProvinceResponseModel> GetProvince() { ProvinceResponseModel res = new ProvinceResponseModel(); try { ProvinceRepository repo = new ProvinceRepository(db); var query = repo.GetAll(); var res2 = (from y in query select new ProviceOutputModel { ProvinceID = y.ID, Kode = y.Kode, Provinsi = y.Provinsi }).OrderBy(x => x.Provinsi).ToList(); res.data = res2; res.Message = "Success get data"; res.Response = true; return(res); } catch (Exception ex) { res.Message = ex.Message; res.Response = false; return(res); } }
public ActionResult <ProvinceDetailResponseModel> GetProvinceDetail(Guid provinceID) { ProvinceDetailResponseModel res = new ProvinceDetailResponseModel(); try { ProvinceRepository repo = new ProvinceRepository(db); var query = repo.GetAll(); var res2 = (from y in query where y.ID == provinceID select new ProviceOutputModel { ProvinceID = y.ID, Kode = y.Kode, Provinsi = y.Provinsi }).FirstOrDefault(); res.data = res2; res.Message = "Success get data"; res.Response = true; return(res); } catch (Exception ex) { res.Message = ex.Message; res.Response = false; return(res); } }
// GET: Province public ActionResult Index() { if (Session["username"] == null) { return(RedirectToAction("Login", "Home")); } return(View(IPV.GetAll())); }
/// <summary> /// /// </summary> /// <param name="request"></param> /// <returns></returns> public List <ProvinceModel> GetProvinces() { var items = ProvinceRepository.GetAll(); if (items != null) { return(items.Select(p => p.ToModel()).ToList()); } return(new List <ProvinceModel>()); }
public Province GetByName(string provinceName) { return(_provinceRepository.GetAll().FirstOrDefault(p => p.Name == provinceName)); }