public bool DoesMeetRankRequirement(UserDataViewModel userData) { UserCurrencyViewModel currency = this.GetCurrency(); if (currency == null) { return(false); } UserRankViewModel rank = this.RequiredRank; if (rank == null) { return(false); } UserCurrencyDataViewModel userCurrencyData = userData.GetCurrency(currency); if (userCurrencyData.Amount < rank.MinimumPoints) { return(false); } if (this.MustEqual && userCurrencyData.GetRank() != rank) { return(false); } return(true); }
public UserRankViewModel GetRankForPoints(int points) { UserRankViewModel rank = UserCurrencyViewModel.NoRank; if (this.Ranks.Count > 0) { rank = this.Ranks.Where(r => r.MinimumPoints <= points).OrderByDescending(r => r.MinimumPoints).FirstOrDefault(); } return(rank); }
public UserRankViewModel GetNextRankForPoints(int points) { UserRankViewModel rank = UserCurrencyViewModel.NoRank; if (this.Ranks.Count > 0) { rank = this.Ranks.Where(r => r.MinimumPoints > points).OrderBy(r => r.MinimumPoints).FirstOrDefault(); if (rank == null) { rank = UserCurrencyViewModel.NoRank; } } return rank; }
public override string ToString() { UserRankViewModel rank = this.Currency.GetRankForPoints(this.Amount); return(string.Format("{0} - {1}", rank.Name, this.Amount)); }
public UserCurrencyRequirementViewModel(UserCurrencyViewModel currency, UserRankViewModel rank, bool mustEqual = false) { this.CurrencyID = currency.ID; this.RankName = rank.Name; this.MustEqual = mustEqual; }