public object AddBookmark(IDbConnection connection, BookmarkOut bm, int currentUserId, bool hasPremium, IMapInfoService mapInfoService, IGGeometryPlanetService geometryPlanetService, ISystemService systemService, IGSectorsService gSectorsService) { _saveNewBookmark(connection, bm, currentUserId, hasPremium, geometryPlanetService, systemService, gSectorsService); if (bm.IsFull) { return(GetPlanshetViewData(connection, mapInfoService, currentUserId)); } if (string.Equals(BookmarkOut.Planet, bm.TypeName, StringComparison.CurrentCultureIgnoreCase)) { var item = GetUserBookmark(connection, currentUserId, bm.TypeId, bm.ObjectId); var outData = mapInfoService.GetPlanetOutData(connection, item, currentUserId); if (outData == null) { throw new Exception(Error.NoData); } return(outData); } if (string.Equals(BookmarkOut.Star, bm.TypeName, StringComparison.CurrentCultureIgnoreCase)) { var item = GetUserBookmark(connection, currentUserId, bm.TypeId, bm.ObjectId); var outData = mapInfoService.GetSystemOutData(connection, item); if (outData == null) { throw new Exception(Error.InputDataIncorrect); } return(outData); } if (string.Equals(BookmarkOut.Sector, bm.TypeName, StringComparison.CurrentCultureIgnoreCase)) { var item = GetUserBookmark(connection, currentUserId, bm.TypeId, bm.ObjectId); var outData = mapInfoService.GetSectorOutData(connection, item); if (outData == null) { throw new Exception(Error.NoData); } return(outData); } throw new NotImplementedException(); }
public IPlanshetViewData GetPlanshetViewData(IDbConnection connection, IMapInfoService mapInfoService, int currentUserId) { var bookmarks = GetUserBookmarks(connection, currentUserId); bookmarks = bookmarks.OrderByDescending(i => i.Id).ToList(); var planets = new List <PlanetInfoOut>(); var stars = new List <StarInfoOut>(); var sectors = new List <SectorInfoOut>(); #region For var types = _gameTypeService.GetAllGGameTypes(connection); foreach (var item in bookmarks) { var type = types.Single(i => i.Id == item.TypeId); var typeName = type.Type; #region Planet Type if (typeName == BookmarkOut.Planet) { var planetOutData = mapInfoService.GetPlanetOutData(connection, item, currentUserId); if (planetOutData == null) { continue; } planets.Add(planetOutData); } #endregion #region StarType if (typeName == BookmarkOut.Star) { var outSystemData = mapInfoService.GetSystemOutData(connection, item); if (outSystemData == null) { continue; } stars.Add(outSystemData); } #endregion #region SectorType if (typeName != BookmarkOut.Sector) { continue; } var sectorOutData = mapInfoService.GetSectorOutData(connection, item); if (sectorOutData == null) { continue; } sectors.Add(sectorOutData); #endregion } #endregion var tabs = mapInfoService.InitialTabs(planets, stars, sectors); return(tabs); }