Пример #1
0
        public GalaxyInfoOut GetGalaxyInfo(IDbConnection connection, byte galaxyId)
        {
            var galaxy = _galaxyService.GetGalaxyById(connection, galaxyId, i => i);

            if (galaxy == null)
            {
                throw new ArgumentNullException(nameof(galaxy), Error.NoData);
            }

            var galaxyType   = _gameTypeService.GetGGameType(connection, galaxy.TypeId);
            var sectorsIds   = _gSectorsService.GetSectorsByGalaxy(connection, galaxyId, i => i.Id);
            var sectorsCount = sectorsIds.Count;

            var galaxyName = L10N.ExecuteTranslateNameOrDescr(galaxy.Translate, true, L10N.GetCurrentCulture());

            var galaxyInfo = new GalaxyInfoOut
            {
                Id                   = galaxy.Id,
                GalaxyId             = galaxy.Id,
                NativeName           = galaxy.NativeName,
                GalaxyName           = galaxyName,
                TranslateName        = galaxyName,
                TextureTypeId        = galaxy.TextureTypeId,
                TypeNativeName       = galaxyType.Type,
                TypeTranslateName    = galaxyName,
                SubtypeNativeName    = galaxyType.SubType,
                SubtypeTranslateName = "Spirale",
                SpriteImages         = new SpriteImages().GalaxyImages(galaxy.TextureTypeId),
                Description          = L10N.ExecuteTranslateNameOrDescr(galaxy.Translate, false),
                ChildCount           = (short)sectorsCount
            };


            //todo  сделать перевод
            galaxyInfo.SetComplexButtonView();
            return(galaxyInfo);
        }
Пример #2
0
        public IActionResult UpdateDescription(AdminSpaceModel spaceItem)
        {
            _dbProvider.ContextAction(connection =>
            {
                if (spaceItem.MapType == MapTypes.Galaxy)
                {
                    var galaxy       = _galaxyService.GetGalaxyById(connection, (byte)spaceItem.Id, i => i);
                    galaxy.Translate = spaceItem.Translate;
                    _galaxyService.AddOrUpdate(connection, galaxy);
                }
                else if (spaceItem.MapType == MapTypes.Sector)
                {
                    var sector       = _sectorsService.GetById(connection, (short)spaceItem.Id, i => i);
                    sector.Translate = spaceItem.Translate;
                    _sectorsService.AddOrUpdate(connection, sector);
                }
                else if (spaceItem.MapType == MapTypes.Star)
                {
                    var star         = _systemService.GetDetailSystemBySystemId(connection, spaceItem.Id, i => i);
                    star.Description = spaceItem.Translate;
                    _systemService.AddOrUpdateDetailSystem(connection, star);
                }

                else if (spaceItem.MapType == MapTypes.Planet)
                {
                    var planet         = _detailPlanetService.GetPlanet(connection, spaceItem.Id, i => i);
                    planet.Description = spaceItem.Translate;
                    _detailPlanetService.AddOrUpdate(connection, planet);
                }
                else if (spaceItem.MapType == MapTypes.Satellite)
                {
                    var moon         = _moonService.GetDetailMoon(connection, spaceItem.Id);
                    moon.Description = spaceItem.Translate;
                    _moonService.AddOrUpdateDetailMoon(connection, moon);
                }
                return(true);
            });


            return(Json(true));
        }