Exemplo n.º 1
0
        public SectorInfoOut GetSectorInfo(IDbConnection connection, short sectorId)
        {
            var sector = _gSectorsService.GetById(connection, sectorId, i => i);

            if (sector == null)
            {
                return(null);
            }

            var sectorType = _gameTypeService.GetGGameType(connection, sector.TypeId);

            if (sectorType == null)
            {
                return(null);
            }

            var galaxyName = _galaxyService.GetGalaxyById(connection, sector.GalaxyId, i => i);

            if (galaxyName == null)
            {
                return(null);
            }


            var topAllianceName = _allianceService.GetTopAllianceInSector(connection, sectorId);
            var systemIds       = _systemService.GetSystemIds(connection, sectorId);

            var sectorInfo = new SectorInfoOut
            {
                GalaxyId          = sector.GalaxyId,
                GalaxyName        = galaxyName.NativeName,
                SectorId          = sector.Id,
                SectorName        = sector.NativeName,
                Id                = sector.Id,
                NativeName        = sector.NativeName,
                TextureTypeId     = sector.TextureTypeId,
                TypeNativeName    = sectorType.Type,
                TypeTranslateName =
                    L10N.ExecuteTranslateNameOrDescr(sectorType.Description, true, L10N.GetCurrentCulture()),
                SubtypeNativeName = sectorType.SubType,
                Description       = L10N.ExecuteTranslateNameOrDescr(sector.Translate, false, L10N.GetCurrentCulture()),
                AllianceName      = topAllianceName,
                ChildCount        = (short)systemIds.Count,
                SpriteImages      = new SpriteImages().SectorImages(sector.TextureTypeId),
                GameTypeId        = sectorType.Id
            };

            sectorInfo.SetComplexButtonView();
            return(sectorInfo);
        }
Exemplo n.º 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));
        }
        public void CreateAll(IDbConnection connection)
        {
            //init stores


            _gGalaxyService.GetGalaxyIds(connection);
            _gSectorsService.GetById(connection, 1, i => i);
            _systemService.GetSystem(connection, 1, i => i);
            _systemService.GetGeometryStarById(connection, 1, i => i);
            _systemService.GetDetailSystemBySystemId(connection, 1, i => i);
            _gGeometryPlanetService.GetGeometryPlanetById(connection, 1);
            _gDetailPlanetService.GetPlanet(connection, 1, false);
            _moonService.GetGeometryMoon(connection, 1);
            _moonService.GetDetailMoon(connection, 1);

            var act = new List <Func <IDbConnection, bool> >()
            {
                CreateGalaxies,
                CreateSectors,
                CreateSystems,
                CreateStars,
                CreatePlanets,
                CreatePlanetDetails,
                CreateMoons,
                CreateSystemGeometries,
                UpdateStarEnergyBonuses,
                UpdateSectorsToArchForm
            };

            var len = act.Count;

            for (int i = 0; i < len; i++)
            {
                var suc = act[i](connection);
                if (!suc)
                {
                    throw new NotImplementedException("CreateAll failed, last metod:" + act[i].Method.Name);
                }
            }
        }
        private void _saveNewBookmark(IDbConnection connection, BookmarkOut bm, int currentUserId, bool hasPremium, IGGeometryPlanetService geometryPlanetService, ISystemService systemService, IGSectorsService gSectorsService)
        {
            var hasData = false;

            if (_isFull(connection, currentUserId, hasPremium))
            {
                throw new Exception(Error.BookMarkLimitDone);
            }

            if (string.Equals(BookmarkOut.Planet, bm.TypeName, StringComparison.CurrentCultureIgnoreCase))
            {
                var planetTypeId = geometryPlanetService.GetPlanetType(connection, bm.ObjectId);
                if (planetTypeId == 0)
                {
                    throw new Exception(Error.InputDataIncorrect);
                }
                hasData =
                    (GetUserBookmark(connection, currentUserId, planetTypeId, bm.ObjectId) !=
                     null);
                bm.TypeId = planetTypeId;
            }

            else if (string.Equals(BookmarkOut.Star, bm.TypeName, StringComparison.CurrentCultureIgnoreCase))
            {
                var starTypeId = systemService.GetDetailSystemBySystemId(connection, bm.ObjectId, i => i.TypeId);

                if (starTypeId == 0)
                {
                    throw new Exception(Error.InputDataIncorrect);
                }
                hasData   = (GetUserBookmark(connection, currentUserId, starTypeId, bm.ObjectId) != null);
                bm.TypeId = starTypeId;
            }

            else if (string.Equals(BookmarkOut.Sector, bm.TypeName, StringComparison.CurrentCultureIgnoreCase))
            {
                var sectorTypeId = gSectorsService.GetById(connection, (short)bm.ObjectId, i => i.TypeId);
                if (sectorTypeId == 0)
                {
                    throw new Exception(Error.InputDataIncorrect);
                }

                hasData   = (GetUserBookmark(connection, currentUserId, sectorTypeId, bm.ObjectId) != null);
                bm.TypeId = sectorTypeId;
            }
            else
            {
                throw new NotImplementedException();
            }

            if (hasData)
            {
                throw new Exception(Error.BookmarkIsExist);
            }
            AddOrUpdate(connection, new UserBookmarkDataModel
            {
                UserId   = currentUserId,
                TypeId   = bm.TypeId,
                ObjectId = bm.ObjectId
            });
        }