Пример #1
0
        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 void Test2()
        {
            Settings.DbContextConnectionString = "Server=.;Database=loc-admin-ui;Trusted_Connection=False;MultipleActiveResultSets=true;User ID=sample-user;Password=P@ssword$$";
            var repo = new ResourceRepository();

            var resource = repo.GetAll();
        }
Пример #3
0
 public ActionResult Resources()
 {
     using (var context = new AppSecurityContext())
     {
         var repository = new ResourceRepository(context);
         var resources  = repository.GetAll();
         var model      = mapper.Map <IEnumerable <AppResourceViewModel> >(resources);
         return(View(model));
     }
 }
Пример #4
0
 public SelectList PopulateResources(object selectedItem = null)
 {
     using (var context = new AppSecurityContext())
     {
         var repository = new ResourceRepository(context);
         var resources  = repository.GetAll().OrderBy(x => x.Name).ToList();
         resources.Insert(0, new AppResource {
             Key = null, Name = "Seleccione"
         });
         return(new SelectList(resources, "Key", "Name", selectedItem));
     }
 }
Пример #5
0
        public IEnumerable <Resource> ReturnAllResources()
        {
            IEnumerable <Resource> resources;

            try {
                ResourceRepository resourceRepo = new ResourceRepository();

                resources = resourceRepo.GetAll();
            }catch (Exception ex)
            {
                throw ex;
            }

            return(resources);
        }
Пример #6
0
        public SelectList PopulateResourceFromNewUserPermission(string userId, object selectedItem = null)
        {
            using (var context = new AppSecurityContext())
            {
                var resourcesRepository    = new ResourceRepository(context);
                var userPermissionRository = new UserPermissionRepository(context);

                var permissionSelect = userPermissionRository.GetPermissionByUserId(userId).Select(p => p.ResourceKey).Distinct();
                var resourcesQuery   = resourcesRepository.GetAll();
                var resources        = resourcesQuery.Where(x => !permissionSelect.Contains(x.Key)).ToList();
                resources.Insert(0, new AppResource {
                    Key = null, Name = "Seleccione"
                });
                return(new SelectList(resources, "Key", "Name", selectedItem));
            }
        }
Пример #7
0
        internal ICollection <LocalizationResource> Export(MigrationToolOptions settings)
        {
            ICollection <LocalizationResource> resources = new List <LocalizationResource>();

            if (settings.ExportFromXmlOnly)
            {
                resources = GetXmlResources(settings);
            }
            if (settings.ExportFromDatabase)
            {
                var repo = new ResourceRepository();
                resources = repo.GetAll().ToList();

                InitializeDb(settings);
            }

            return(resources);
        }
Пример #8
0
        public void CreateResource(Resource resource)
        {
            ResourceRepository resourceRepo = new ResourceRepository();

            try
            {
                var             max = -1;
                List <Resource> rl  = resourceRepo.GetAll().ToList();



                rl.ForEach(r =>
                {
                    var number  = Regex.Replace(r.UserName, "[^0-9]", "");;
                    var usrName = Regex.Replace(r.UserName, "[^a-zA-Z]", "");

                    if (resource.UserName == usrName)
                    {
                        var intUsername = Int32.Parse(number);
                        if (max < intUsername)
                        {
                            max = intUsername;
                        }
                    }
                });


                resource.UserName  += max + 1;
                resource.ResourceID = resourceRepo.GetMaxId() + 1;

                resourceRepo.Add(resource);
                GlobalUnitOfWork.Commit();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public IEnumerable <V_Resource> GetResources(bool?inUse) => _ResourceRepository.GetAll <V_Resource>(DataContext, inUse);
 public void GetAllTest()
 {
     Assert.AreNotEqual(0, testObj.GetAll().Count());
     Assert.AreNotEqual(0, testObj.GetAll().First().value.Length);
 }
Пример #11
0
 internal List <Resource> GetAll()
 => _resourceRepository.GetAll();