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, }); }
public static CardProvidesLessonModel GetCardProvidesLessonModel(CardProvidesLesson cardProvidesLesson, LessonType lessonType) { return(new CardProvidesLessonModel() { CardProvidesLessonId = cardProvidesLesson.CardProvidesLessonId, CardId = cardProvidesLesson.CardId, Lesson = LessonService.GetLessonTypeModel(lessonType), ProvidesCount = cardProvidesLesson.Provides, CreatedById = cardProvidesLesson.CreatedById, CreatedDate = cardProvidesLesson.CreatedDate, UpdatedById = cardProvidesLesson.UpdatedById, UpdatedDate = cardProvidesLesson.UpdatedDate, Deleted = cardProvidesLesson.Deleted, }); }
public void PersistCardProvidesLesson(Guid cardId, Guid lessonId, int provides) { var now = DateTime.UtcNow; var cardProvidesLesson = new CardProvidesLesson() { CardProvidesLessonId = Guid.NewGuid(), CardId = cardId, Provides = provides, LessonId = lessonId, CreatedById = Guid.Empty, CreatedDate = now, UpdatedById = Guid.Empty, UpdatedDate = now, Deleted = false, }; _context.CardProvidesLessons.Add(cardProvidesLesson); _context.SaveChanges(); }
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()); } }