Exemple #1
0
 public static CardModel GetCardModel(Card card, Set cardSet, Rarity cardRarity, CardType cardType, CardDetail cardDetail,
                                      Language language, LessonType lessonType, LessonType providesLesson,
                                      CardProvidesLesson cardProvidesLesson)
 {
     return(new CardModel()
     {
         CardId = card.CardId,
         CardSet = SetService.GetSetModel(cardSet),
         CardType = TypeService.GetCardTypeModel(cardType),
         Rarity = RarityService.GetRarityModel(cardRarity),
         Detail = CardDetailService.GetCardDetailModel(cardDetail, language),
         LessonType = lessonType == null ? null : LessonService.GetLessonTypeModel(lessonType),
         LessonCost = card.LessonCost,
         ActionCost = card.ActionCost,
         CardNumber = card.CardNumber,
         Orientation = card.Orientation,
         ProvidesLesson = providesLesson == null && cardProvidesLesson == null ? null :
                          CardProvidesLessonService.GetCardProvidesLessonModel(cardProvidesLesson, providesLesson),
         CardPageUrl = $"/Card/{cardSet.ShortName}/{card.CardNumber}/{cardDetail.Name.Replace(" ", "-")}",
         CreatedById = card.CreatedById,
         CreatedDate = card.CreatedDate,
         UpdatedById = card.UpdatedById,
         UpdatedDate = card.UpdatedDate,
         Deleted = card.Deleted,
     });
 }
Exemple #2
0
        public static CardModel GetCardModel(Card card, Set cardSet, Rarity cardRarity, CardType cardType, CardDetail cardDetail,
                                             Language language, LessonType lessonType, LessonType providesLesson,
                                             CardProvidesLesson cardProvidesLesson)
        {
            var cardName = GetCardDetailNameWithoutIllegalChars(cardDetail.Name);

            return(new CardModel()
            {
                CardId = card.CardId,
                CardSet = SetService.GetSetModel(cardSet),
                CardType = TypeService.GetCardTypeModel(cardType),
                Rarity = RarityService.GetRarityModel(cardRarity),
                Detail = CardDetailService.GetCardDetailModel(cardDetail, language),
                LessonType = lessonType == null ? null : LessonService.GetLessonTypeModel(lessonType),
                LessonCost = card.LessonCost,
                ActionCost = card.ActionCost,
                CardNumber = card.CardNumber,
                Orientation = card.Orientation,
                ProvidesLesson = providesLesson == null && cardProvidesLesson == null ? null :
                                 CardProvidesLessonService.GetCardProvidesLessonModel(cardProvidesLesson, providesLesson),
                CardPageUrl = $"/card/{cardSet.ShortName.ToLower()}/{card.CardNumber.ToLower()}/{language.Code.ToLower()}/{cardName}",
                Damage = card.Damage,
                Health = card.Health,
                CreatedById = card.CreatedById,
                CreatedDate = card.CreatedDate,
                UpdatedById = card.UpdatedById,
                UpdatedDate = card.UpdatedDate,
                Deleted = card.Deleted,
            });

            //The name is unimportant when forming the URL. We need to remove illegal characters so the URL
            //doesn't blow up. So it doens't really matter what we replace them with.
            string GetCardDetailNameWithoutIllegalChars(string name)
            {
                name = name.Replace(" ", "-");
                name = name.Replace("/", "-");
                return(name.ToLower());
            }
        }