Esempio n. 1
0
        public CitizenTravelViewModel(Entities.Citizen citizen, IList <MovingTicket> availableTickets, IFriendService friendService)
        {
            Info = new CitizenInfoViewModel(citizen, friendService);

            IEnumerable <Entities.Country> countries = Persistent.Countries.GetAll();

            Countries.Add(new SelectListItem()
            {
                Text  = "-- Select country --",
                Value = "null"
            });

            foreach (var country in countries)
            {
                Countries.Add(new SelectListItem()
                {
                    Text  = country.Entity.Name,
                    Value = country.ID.ToString()
                });
            }

            foreach (var ticket in availableTickets.OrderBy(t => t.Quality))
            {
                AvailableMovingTicketQualities.Add(new SelectListItem()
                {
                    Text  = ticket.Quality.ToString(),
                    Value = ticket.Quality.ToString()
                });
            }
        }
Esempio n. 2
0
        public ViewCitizenViewModel(Entities.Citizen citizen, IList <Citizen> friends, ICitizenService citizenService, IFriendService friendService)
        {
            var entity = citizen.Entity;

            Info        = new CitizenInfoViewModel(citizen, friendService);
            Avatar      = new ImageViewModel(entity.ImgUrl);
            Name        = entity.Name;
            RegionName  = citizen.Region.Name;
            CountryName = citizen.Region.Country.Entity.Name;

            HitPoints           = citizen.HitPoints;
            Experience          = citizen.Experience;
            Level               = citizen.ExperienceLevel;
            NextLevelExperience = citizenService.CalculateExperienceForNextLevel(citizen.ExperienceLevel);

            Manufacturing = (double)citizen.Manufacturing;
            Raw           = (double)citizen.Raw;
            Selling       = (double)citizen.Selling;
            Construction  = (double)citizen.Construction;

            ExperienceProgress = (int)(Experience / (double)NextLevelExperience * 100.0);

            int militaryRank     = (int)citizen.MilitaryRank;
            int nextMilitaryRank = (MilitaryRankEnumExtensions.CalculateNextMilitaryRankNeeded(militaryRank) ?? militaryRank);

            MilitaryRank             = militaryRank.ConvertToBasicUnits();
            NextMilitaryRank         = nextMilitaryRank.ConvertToBasicUnits();
            NextMilitaryRankProgress = (int)(militaryRank / (double)nextMilitaryRank * 100.0);
            MilitaryRankIconCss      = MilitaryRankEnumExtensions.GetRankCss(MilitaryRankEnumExtensions.GetRankForMilitaryRank(militaryRank));

            Strength = string.Format("{0:0.##}", citizen.Strength);

            Medals = new MedalViewModel(citizen);

            var company = citizen.GetCurrentJob();

            if (company != null)
            {
                Job = new CitizenJobShortViewModel(company);
            }

            Friends = friends
                      .TakeRandom(4)
                      .Select(cit => new ViewCitizenFriendModel(cit))
                      .ToList();

            FriendCount = friends.Count();
        }
 public CitizenWalletViewModel(Citizen citizen, List <WalletMoney> money, IFriendService friendService) : base(money)
 {
     Info = new CitizenInfoViewModel(citizen, friendService);
 }