Пример #1
0
        public CompanyManagersViewModel(Company company, CompanyRights currentEntityRights)
        {
            Info = new CompanyInfoViewModel(company);
            NewManagersSelector = Select2AjaxViewModel.Create <CompanyController>(c => c.GetAppropriateManagers(null), "entityID", null, "");

            initManagers(company, currentEntityRights);
        }
Пример #2
0
        public OfferMPPViewModel(Entities.Country country, IMPPService mppService, IWalletService walletService)
        {
            Info          = new CountryInfoViewModel(country);
            CountrySelect = Select2AjaxViewModel.Create <CountryController>(c => c.GetMPPAvailableCountries(null, 0), "OtherCountryID", null, "");
            CountrySelect.AddAdditionalData("countryID", country.ID);

            MinimumLength = ConfigurationHelper.Configuration.MinimumMPPLength;
            MaximumLength = ConfigurationHelper.Configuration.MaximumMPPLength;

            CountryGold = walletService.GetWalletMoney(country.Entity.WalletID, GameHelper.Gold.ID).Amount;
            GoldImage   = Images.GetCountryCurrency(GameHelper.Gold).VM;
        }
Пример #3
0
        public GiftViewModel(List <WalletMoney> walletMoneys, List <EquipmentItem> equipmentItems, int?currentDestinationID, string currentDestinationName)
        {
            MoneyGifts   = walletMoneys.Select(wm => new MoneyGiftViewModel(wm)).ToList();
            ProductGifts = equipmentItems.Select(ei => new ProductGiftViewModel(ei)).ToList();

            DestinationSelector          = Select2AjaxViewModel.Create <GiftController>(c => c.GetPossibleDestinations(null), "DestinationID", currentDestinationID, currentDestinationName);
            DestinationSelector.OnChange = "Sociatis.Gifts.OnDestinationChange";
            DestinationSelector.ID       = "DestinationID";

            if (SessionHelper.CurrentEntity.Is(EntityTypeEnum.Citizen, EntityTypeEnum.Company))
            {
                CanSendProducts = true;
            }
        }
Пример #4
0
        void loadSelectLists(int countryID)
        {
            var entityRepository = DependencyResolver.Current.GetService <IEntityRepository>();
            var currencyIDs      = entityRepository.Where(entity => entity.EntityID == countryID)
                                   .Select(e => e.Wallet)
                                   .SelectMany(w => w.WalletMoneys)
                                   .Select(money => money.CurrencyID)
                                   .ToList();
            var currencies = Persistent.Currencies.Where(currency => currencyIDs.Contains(currency.ID)).ToList();


            Currencies     = CreateSelectList(currencies, c => c.Symbol, c => c.ID);
            Companies      = Select2AjaxViewModel.Create <CongressController>(x => x.GetTransferMoneyToCompanies(null, 0), nameof(CompanyID), null, "");
            Companies.ID   = "CompanyID";
            Companies.Data = "formatTransferData";
        }
Пример #5
0
        public HotelManagersViewModel(HotelInfo info, IEnumerable <HotelManagerModel> managers)
        {
            Info = new HotelInfoViewModel(info);

            Managers.Add(new HotelManagerViewModel()
            {
                Avatar    = new SmallEntityAvatarViewModel(info.OwnerID, info.OwnerName, info.OwnerImgUrl),
                CitizenID = info.OwnerID,
                ReadOnly  = true,
                Rights    = HotelRights.FullRights,
                Title     = "Owner",
                HotelID   = info.HotelID
            });
            Managers.AddRange(managers.Select(m => new HotelManagerViewModel(info.HotelID, m, Rights)).OrderByDescending(m => m.Rights.Priority).ToList());
            ManagerSelector = Select2AjaxViewModel.Create <CitizenController>(x => x.GetCitizens(null),
                                                                              "citizenID", null, "");
        }
 private void loadSelectLists()
 {
     loadCompanies();
     Citizens    = Select2AjaxViewModel.Create <CitizenController>(c => c.GetCitizens(null), nameof(CitizenID), null, "");
     Citizens.ID = nameof(CitizenID);
 }
Пример #7
0
 public ViewThreadViewModel()
 {
     AddRecipientSelector = Select2AjaxViewModel.Create <MessageController>(c => c.GetEligibleRecipients(null), "RecipientID", null, string.Empty);
 }
Пример #8
0
 public ManageJournalistsViewModel()
 {
     CitizenSelector = Select2AjaxViewModel.Create <CitizenController>(c => c.GetCitizens(null), "citizenID", null, "");
 }
Пример #9
0
 public StartTradeViewModel()
 {
     EntitySelector = Select2AjaxViewModel.Create <TradeController>(c => c.GetEntitiesToTrade(null), "EntityID", null, "");
 }
Пример #10
0
        public ViewPartyViewModel(Entities.Party party)
        {
            InviteSelector          = Select2AjaxViewModel.Create <CitizenController>(c => c.GetCitizens(null), "citizenID", null, "");
            InviteSelector.OnChange = "inviteCitizen";

            OverallInfo = new PartyInfoViewModel(party);
            JoinMethod  = (JoinMethodEnum)party.JoinMethodID;
            PartyRole   = OverallInfo.PartyRole;
            PartyID     = party.ID;

            var members = party.PartyMembers
                          .ToList();

            var president = members
                            .FirstOrDefault(m => m.PartyRoleID == (int)PartyRoleEnum.President);

            if (president != null)
            {
                President = new ShortEntityInfoViewModel(president.Citizen.Entity);
            }

            Managers = members
                       .Where(m => m.PartyRoleID == (int)PartyRoleEnum.Manager)
                       .Take(3)
                       .Select(m => new ShortEntityInfoViewModel(m.Citizen.Entity))
                       .ToList();

            if (Managers.Count < 3)
            {
                Members = members
                          .Where(m => m.PartyRoleID == (int)PartyRoleEnum.Member)
                          .Take(3 - Managers.Count)
                          .Select(m => new ShortEntityInfoViewModel(m.Citizen.Entity))
                          .ToList();
            }

            OtherMemberCount = members.Count() - Managers.Count - Members.Count - (president == null ? 0 : 1);

            var partyVoting = party.PartyPresidentVotings.Last();
            var entity      = SessionHelper.CurrentEntity;

            if (entity.EntityTypeID == (int)EntityTypeEnum.Citizen)
            {
                if (partyVoting.PartyPresidentCandidates.Any(c => c.CitizenID == entity.EntityID))
                {
                    CanStartAsCandidate = false;
                }
            }

            VotingDay = partyVoting.VotingDay;
            DaysLeft  = Math.Abs(GameHelper.CurrentDay - VotingDay);
            var candidatesID = partyVoting.PartyPresidentCandidates
                               .Select(c => c.CitizenID);

            VotingStatus = (VotingStatusEnum)partyVoting.VotingStatusID;
            IsCandidate  = candidatesID.Contains(entity.EntityID);
            if (VotingStatus == VotingStatusEnum.NotStarted && entity.EntityTypeID == (int)EntityTypeEnum.Citizen &&
                IsCandidate == false
                )
            {
                CanCandidate = true;
            }

            if (VotingStatus == VotingStatusEnum.Ongoing)
            {
                if (partyVoting.PartyPresidentVotes.Any(v => v.CitizenID == entity.EntityID) == true)
                {
                    Voted = true;
                }
            }

            var country        = party.Country;
            var congressVoting = country.GetLastCongressCandidateVoting();

            CongressCandidateVotingViewModel = new CongressCandidateVotingShortViewModel(congressVoting);

            InviteSelector.AddAdditionalData("partyid", PartyID);

            if (JoinMethod == JoinMethodEnum.Invite && PartyRole != PartyRoleEnum.NotAMember)
            {
                PendingInvites = party.PartyInvites.Count();
            }
        }
Пример #11
0
 public SendMessageViewModel()
 {
     RecipientSelector    = Select2AjaxViewModel.Create <MessageController>(c => c.GetEligibleRecipients(null), "RecipientID", RecipientID, RecipientName);
     RecipientSelector.ID = "RecipientID";
 }
 private void initSelect2()
 {
     OwnerSelect = Select2AjaxViewModel.Create <NewspaperController>(c => c.GetEligibleEntitiesForOwnershipChange(null), "NewOwnerID", null, "");
 }
Пример #13
0
        public static MvcHtmlString Render(this System.Web.Mvc.HtmlHelper helper, Select2AjaxViewModel select2, string prefix = "", params string[] classes)
        {
            var urlHelper = helper.GetUrlHelper();

            TagBuilder select = new TagBuilder("select");

            select.AddCssClass("customSelect");
            foreach (var @class in classes)
            {
                select.AddCssClass(@class);
            }

            select.Attributes["data-Select2AjaxViewModel"] = "true";
            select.Attributes["name"]                            = prefix + select2.Name;
            select.Attributes["data-select2-url"]                = urlHelper.Action(select2.ControllerName, select2.ActionName);
            select.Attributes["data-select2-delay"]              = select2.Delay.ToString();
            select.Attributes["data-select2-quietMillis"]        = select2.QuietMillis.ToString();
            select.Attributes["data-select2-cache"]              = select2.Cache.ToString();
            select.Attributes["data-select2-pageSize"]           = select2.PageSize.ToString();
            select.Attributes["data-select2-minimumInputLength"] = select2.MinimumInputLength.ToString();
            select.Attributes["data-select2-templateResult"]     = select2.TemplateResult;
            select.Attributes["data-select2-templateSelection"]  = select2.TemplateSelection;
            select.Attributes["data-select2-data"]               = select2.Data;
            select.Attributes["data-select2-onchange"]           = select2.OnChange;

            foreach (var data in select2.AdditionalData)
            {
                var key = $"data-select2-add-{data.Key}";
                select.Attributes[key] = data.Value;
            }

            if (string.IsNullOrWhiteSpace(select2.ID) == false)
            {
                select.Attributes["id"] = select2.ID;
            }
            if (string.IsNullOrWhiteSpace(select2.ContainerCssClass))
            {
                select.Attributes["data-select2-containercssclass"] = select2.ContainerCssClass;
            }
            if (string.IsNullOrWhiteSpace(select2.DropdownCssClass))
            {
                select.Attributes["data-select2-dropdowncssclass"] = select2.DropdownCssClass;
            }


            TagBuilder option = new TagBuilder("option");

            option.Attributes["value"]    = select2.SelectedValue.ToString();
            option.Attributes["selected"] = "selected";
            option.InnerHtml = select2.SelectedValueName;
            select.InnerHtml = option.ToString(TagRenderMode.Normal);

            if (string.IsNullOrWhiteSpace(Select2AjaxDefaultProvider.Current?.JavascriptFile) == false)
            {
                ScriptInjector.AddScript(Select2AjaxDefaultProvider.Current.JavascriptFile);
            }
            if (string.IsNullOrWhiteSpace(Select2AjaxDefaultProvider.Current?.StyleFile) == false)
            {
                StyleInjector.AddStyle(Select2AjaxDefaultProvider.Current.StyleFile);
            }

            return(new MvcHtmlString(select.ToString(TagRenderMode.Normal)));
        }