public IHttpActionResult Convert(string name) { var alliance = new AllianceRatingOut { AllianceDescription = "descr", ComplexButtonView = new ComplexButtonView(), Id = 1, Name = "allianceName", Label = Label.DefaultUrls(), HasButtons = true, Buttons = new List <ButtonsView> { ButtonsView.HangarToggle() }, PvpPoint = 1000, LeaderImg = Avatar.DefaultUrls(), ControlledPlanet = 10, Pilots = 5, LeaderName = "LeaderName" }; var myAlliance = new TabMyAllianceOut(); alliance.ShallowConvert(myAlliance); var result = new { parent = alliance, result = myAlliance }; return(Json(result)); }
public Dictionary <string, object> InitUser(IDbConnection connection, ClaimsPrincipal pricipalUser, IServiceProvider resolver) { if (pricipalUser == null) { throw new NullReferenceException(nameof(pricipalUser)); } var allianceService = resolver.GetService <IAllianceService>(); var sectorService = resolver.GetService <IGSectorsService>(); var estateListService = resolver.GetService <IEstateListService>(); var systemService = resolver.GetService <ISystemService>(); var localizer = resolver.GetService <ILocalizerService>(); var tmpUser = _gameUserService.GetCurrentGameUser(connection, pricipalUser); if (tmpUser == null) { throw new NullReferenceException(nameof(tmpUser)); } var gameUser = _gameUserService.UpdateUserOnlineStatus(connection, tmpUser, true); var userChest = _storeService.GetChestUser(connection, gameUser.Id); var balanceData = (UchBalanceCcData)userChest.ActivatedItemsView[ProductTypeIds.Cc].Data; var up = (UchPremiumData)userChest.ActivatedItemsView[ProductTypeIds.Premium].Data; var userPremiumWm = new UserPremiumWorkModel(up.Premium); var motherData = _mothershipService.GetMother(connection, gameUser.Id); var mother = _synchronizer.UserMothership(connection, motherData, userPremiumWm, _mothershipService, _motherJumpService); var planetsData = _detailPlanetService.GetUserPlanets(connection, gameUser.Id); if (planetsData != null && planetsData.Any()) { planetsData = _synchronizer.UserPlanets(connection, planetsData, userPremiumWm, _detailPlanetService); } _synchronizer.RunUserTasks(connection, gameUser.Id); var sectors = sectorService.GetInitSectors(connection); var allianceUser = allianceService.GetAllianceUserByUserId(connection, gameUser.Id); var alliance = allianceService.Initial(connection, allianceUser, _gameUserService); var personalInfo = _gameUserService.GetUserPlanshetProfile(connection, allianceUser.UserId, allianceUser.AllianceId, alliance, true); // обновляет пользователя в дб обект юзер обновляет по ссылке var myAlliance = (TabMyAllianceOut)alliance.Bodys[1].TemplateData; var connectionUser = _gameUserService.SetConnectionUser(connection, gameUser, allianceUser, myAlliance.Name); //btns var units = HangarUnitsOut.EmptyHangar(); var keys = units.Keys.ToList(); var systemGeometry = systemService.GetSystemGeometryViewData(connection, mother.StartSystemId); var motherEstates = GetMotherEstate(connection, gameUser, userPremiumWm, mother, false); var toggleBtns = new List <IButtonsView> { ButtonsView.HangarToggle() }; var leftNavBtns = new List <IButtonsView> { ButtonsView.LefMenuNavAlliance(), ButtonsView.LefMenuNavConfederation(), ButtonsView.LefMenuNavJournal(), ButtonsView.LefMenuNavChannels() }; var mapControllBtns = MapInfoService.MapControllButtons(_localizer); var hangarBtns = keys.Select(key => units[key]).Select(ButtonsView.HangarListBtns).ToList(); //var storageModel = new StorageResources(); //storageModel.InitializeField(); var btns = new Dictionary <string, IReadOnlyList <IButtonsView> > { { "toggleBtns", toggleBtns }, { "leftNavBtns", leftNavBtns }, { "mapControllBtns", mapControllBtns }, { "hangarBtns", hangarBtns } }; var alianceNames = allianceService.GetAllianceNames(connection, false); var result = new Dictionary <string, object> { { localizer.TranslationKey, localizer.GetGameTranslate() }, { ResourcesView.ViewKey, ResourcesView.GetInitList(balanceData.BalanceCc.Quantity) }, { MapTypes.Sector.ToString(), sectors }, { ButtonsView.BaseBtnsKey, btns }, //todo data incorrect { UchView.ViewKey, userChest }, { EstateItemOut.ViewKey, estateListService.GetList(connection, gameUser.Id) }, { ConnectionUser.ViewKey, connectionUser }, { alliance.UniqueId, alliance }, { UserProfileInfo.AvatarViewKey, personalInfo }, { EstateViewKey, motherEstates }, { AllianceOut.AllianceNamesKey, alianceNames }, { Planetoids.ViewKey, systemGeometry } }; return(result); }