// Fills the array of cards with the retrieved data public void fillObservableCardArray(System.Collections.Generic.List <Business.Network.Cards.Models.Card> cardsList) { CardMapper cardMapper = new CardMapper(); Cards = new ObservableCollection <DataModels.Card>(); foreach (Business.Network.Cards.Models.Card item in cardsList) { DataModels.Card card = cardMapper.MapFrom(item); // For UI Update if (!AppServiceParameters.IsWithdrawalMBWayFunctionalityActive && card.CardInhibitionParameters != null) { card.CardInhibitionParameters.IsAllowedToWithdrawalMBWAY = false; } Cards.Add(card); } if (SelectedIndexCard >= Cards.Count) { SelectedIndexCard = 0; } SelectedCard = Cards[SelectedIndexCard]; checkAndSetAvailableSelectedCard(); }
public static void InsertCard(CardApiDm cardApi, string setId) { using (var db = new MtgEntities()) { try { cardApi.Editions = cardApi.Editions.Where(e => e.Set_Id == setId).ToList(); var em = CardMapper.Map(cardApi); if (db.Cards.Any(c => c.CardId == em.CardId)) { foreach (var cardSet in em.CardSets.Where(s => !db.CardSets.Any(dbSet => dbSet.CardId == s.CardId && dbSet.SetId == s.SetId))) { db.CardSets.Add(cardSet); } } else { db.Cards.Add(em); } db.SaveChanges(); } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"Unable to save the card '{cardApi.Name}' Excpetion:"); Console.WriteLine(e); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; } } }
public static IEnumerable <CardDm> QueryCards(string tribal, string name, bool?commader, List <string> colors, string type, string tag, int numberToReturn = -1) { using (var db = new MtgEntities()) { var invalidColors = GetInvalidColors(colors); var white = ""; var blue = ""; var black = ""; var red = ""; var green = ""; foreach (var color in invalidColors) { switch (color) { case "{W}": white = color; break; case "{U}": blue = color; break; case "{B}": black = color; break; case "{R}": red = color; break; case "{G}": green = color; break; } } var takeNumber = numberToReturn > 0 ? numberToReturn : int.MaxValue; var cards = db.Cards.Where(c => (tag == null || c.CardTags.Any(ct => ct.Tag.TagName == tag)) && (tribal == null || c.SubTypes.ToLower().Contains(tribal) || c.RulesText.ToLower().Contains(tribal)) && (commader == null || c.Types.Contains("Legendary")) && (name == null || c.CardName.ToLower() == name.ToLower()) && (white == "" || (!c.Cost.Contains(white) && !c.RulesText.Contains(white))) && (blue == "" || (!c.Cost.Contains(blue) && !c.RulesText.Contains(blue))) && (black == "" || (!c.Cost.Contains(black) && !c.RulesText.Contains(black))) && (red == "" || (!c.Cost.Contains(red) && !c.RulesText.Contains(red))) && (green == "" || (!c.Cost.Contains(green) && !c.RulesText.Contains(green))) && //(colors == null || invalidColors.All(i => !c.Cost.Contains(i) && !c.RulesText.Contains(i))) && //Super Wish this wouldn't blow up. (type == null || c.Types.Contains(type)) ).Take(takeNumber); foreach (var card in cards) { yield return(CardMapper.Map(card)); } } }
public void CardMapperMapsNullCardToEmptyCardDto() { var mapper = new CardMapper(); var card = mapper.Map((Card)null); card.Should().NotBeNull(); card.Should().BeEquivalentTo(CardDto.Empty); }
public DeckManager(IDeckRepository deckRepository, ICardRepository cardRepository, DeckMapper deckMapper, CardMapper cardMapper, Random rng) { this.deckRepository = deckRepository; this.cardRepository = cardRepository; this.deckMapper = deckMapper; this.cardMapper = cardMapper; this.rng = rng; }
public static IEnumerable <CardDm> GetAllCards() { using (var db = new MtgEntities()) { foreach (var dbCard in db.Cards) { yield return(CardMapper.Map(dbCard)); } } }
public void Mapper_ShouldReturnValidCard() { var card = CardMapper.Map("ad"); Assert.Multiple(() => { Assert.IsTrue(card.Rank == Rank.Ace); Assert.IsTrue(card.Suit == Suit.Diamond); }); }
/// <summary> /// get list of cards associated with a customer /// </summary> /// <param name="dto"></param> /// <returns></returns> public async Task <List <CardDto> > ListAllCard(ListAllCardsDto dto) { var service = new CardService(); var options = new CardListOptions { Limit = dto.CardsLimit }; var cards = await service.ListAsync(dto.CustomerId, options); return(CardMapper.MapCardListToCardDtoList(cards.Data)); }
public void CardMapper_GetCardType_ShouldReturnEmv_IfApplicationTypeIsContactlessEmv() { // Arrange this.GcrResponse.GCR_CARDTYPE.Value = ApplicationType.ContactlessEmv; // Act CardType cardType = CardMapper.GetCardType(this.GcrResponse.GCR_CARDTYPE.Value); // Assert Assert.AreEqual(CardType.Emv, cardType); }
/// <summary> /// discarded, this method is not required because as of now we are using vue stripe component /// it will be updated if required for other project in future /// </summary> /// <param name="dto"></param> /// <returns></returns> public async Task <CardDto> CreateCard(CreateCardDto dto) { var cardOptions = new CardCreateOptions() { SourceToken = dto.SourceToken }; var cardService = new CardService(); return(CardMapper.MapCardToCardDto(await cardService.CreateAsync(dto.CustomerId, cardOptions))); }
public void CardMapper_GetCardType_ShouldReturnMagneticStripe_IfApplicationTypeIsMagneticStripe() { // Arrange this.GcrResponse.GCR_CARDTYPE.Value = ApplicationType.MagneticStripe; // Act CardType cardType = CardMapper.GetCardType( this.GcrResponse.GCR_CARDTYPE.Value); // Assert Assert.AreEqual(CardType.MagneticStripe, cardType); }
public async Task <Card> Update(CardModel cardModel) { var cardToUpdate = await _cardRepository.CardById(cardModel.Id); if (cardToUpdate != null) { CardMapper.UpdateTrapCardWith(cardToUpdate, cardModel); return(await _cardRepository.Update(cardToUpdate)); } return(null); }
public static IEnumerable <CardVm> GetDeckLands(string deckName) { Console.WriteLine("Getting Deck"); var deck = DeckRepository.GetDeck(deckName); Console.WriteLine("Looking for legal cards"); var legalCards = CardRepository.GetAllCommanderLegalCardInGivenColors(CardBLL.GetCardColors(CardMapper.Map(deck.Commander))); Console.WriteLine($"Attempting to find lands in {legalCards.Count()} cards."); return(CardMapper.Map(legalCards.Where(c => c.Types.Contains("land")))); }
public static IEnumerable <CardDm> GetAllCardsByGivenSubtype(string subtype) { using (var db = new MtgEntities()) { var legalCards = db.Cards .Where(c => c.SubTypes.Contains(subtype)); foreach (var card in legalCards) { yield return(CardMapper.Map(card)); } } }
public void CardMapper_MapCardFromTracks_ShouldNotReturnNull() { // Arrange this.GcrResponse.GCR_CARDTYPE.Value = ApplicationType.ContactlessEmv; // Act CardEntry mappedCard = CardMapper.MapCardFromTracks( this.GcrResponse, CardBrandMocker.Mock()); // Assert Assert.IsNotNull(mappedCard); }
public Mapper() { _accountMapper = new AccountMapper(); _bazaarItemMapper = new BazaarItemMapper(); _bCardMapper = new BCardMapper(); _boxItemMapper = new ItemInstanceMapper(); _cardMapper = new CardMapper(); _cellonOptionMapper = new CellonOptionMapper(); _characterMapper = new CharacterMapper(); _characterRelationMapper = new CharacterRelationMapper(); _characterSkillMapper = new CharacterSkillMapper(); _comboMapper = new ComboMapper(); _dropMapper = new DropMapper(); _familyCharacterMapper = new FamilyCharacterMapper(); _familyLogMapper = new FamilyLogMapper(); _familyMapper = new FamilyMapper(); _generalLogMapper = new GeneralLogMapper(); _itemInstanceMapper = new ItemInstanceMapper(); _itemMapper = new ItemMapper(); _mailMapper = new MailMapper(); _maintenanceLogMapper = new MaintenanceLogMapper(); _mapMapper = new MapMapper(); _mapMonsterMapper = new MapMonsterMapper(); _mapNPCMapper = new MapNPCMapper(); _mapTypeMapMapper = new MapTypeMapMapper(); _mapTypeMapper = new MapTypeMapper(); _mateMapper = new MateMapper(); _minilandObjectMapper = new MinilandObjectMapper(); _npcMonsterMapper = new NpcMonsterMapper(); _npcMonsterSkillMapper = new NpcMonsterSkillMapper(); _penaltyLogMapper = new PenaltyLogMapper(); _portalMapper = new PortalMapper(); _questMapper = new QuestMapper(); _questProgressMapper = new QuestProgressMapper(); _quicklistEntryMapper = new QuicklistEntryMapper(); _recipeItemMapper = new RecipeItemMapper(); _recipeListMapper = new RecipeListMapper(); _recipeMapper = new RecipeMapper(); _respawnMapper = new RespawnMapper(); _respawnMapTypeMapper = new RespawnMapTypeMapper(); _rollGeneratedItemMapper = new RollGeneratedItemMapper(); _scriptedInstanceMapper = new ScriptedInstanceMapper(); _shellEffectMapper = new ShellEffectMapper(); _shopItemMapper = new ShopItemMapper(); _shopMapper = new ShopMapper(); _shopSkillMapper = new ShopSkillMapper(); _skillMapper = new SkillMapper(); _staticBonusMapper = new StaticBonusMapper(); _staticBuffMapper = new StaticBuffMapper(); _teleporterMapper = new TeleporterMapper(); }
public void CardMapper_MapCardFromTracks_ShouldThrowException_IfApplicationTypeIsEasyEntryOverTIBCv1() { // Assert Assert.Throws <NotImplementedException>(() => { // Arrange this.GcrResponse.GCR_CARDTYPE.Value = ApplicationType.EasyEntryOverTIBCv1; // Act CardEntry mappedCard = CardMapper.MapCardFromTracks( this.GcrResponse, CardBrandMocker.Mock()); }); }
public static IEnumerable <CardDm> GetCommandersByPartialName(string cardName) { using (var db = new MtgEntities()) { cardName = cardName.ToLower(); var commanders = db.Cards .Where(c => c.Types.Contains("Legendary") && c.CardName.ToLower().Contains(cardName)); foreach (var card in commanders) { yield return(CardMapper.Map(card)); } } }
public static IEnumerable <CardDm> FindTribalCommandersForType(string tribalType) { using (var db = new MtgEntities()) { tribalType = tribalType.ToLower(); var commanders = db.Cards .Where(c => c.Types.Contains("Legendary") && (c.SubTypes.ToLower().Contains(tribalType) || c.RulesText.ToLower().Contains(tribalType))); foreach (var card in commanders) { yield return(CardMapper.Map(card)); } } }
public static CardDm GetCardByName(string cardName) { using (var db = new MtgEntities()) { try { return(CardMapper.Map(db.Cards.Single(c => c.CardName == cardName))); } catch (Exception) { Console.WriteLine(); Console.WriteLine($"Unable to find the card {cardName}."); return(null); } } }
static public void MakeActOfWorkInExcel(string idRepair, string unloadPath) { rowStartForDelete = 0; try { xlApp = new Excel.Application(); xlWorkBook = xlApp.Workbooks.Open(ConfigurationManager.AppSettings.Get("PathForOpenAct")); xlSheet = xlWorkBook.Sheets[1]; SystemOwner systemOwner = new OwnerMapper().Get(); CardOfRepair card = new CardMapper().Get(idRepair.ToString()); FileOperator fileOperator = new FileOperator(); xlSheet.Cells[1, "A"] = systemOwner.ToString(); xlSheet.Cells[59, "F"] = systemOwner.Director.GetShortName(); xlSheet.Cells[3, "G"] = card.IdRepair; xlSheet.Cells[3, "J"] = ((DateTime)card.TimeOfFinish).ToString("dd/MM/yyyy"); if (card.Car.Owner != null) { xlSheet.Cells[4, "D"] = $"{card.Car.Owner.Name}, ИНН {card.Car.Owner.INN}"; } xlSheet.Cells[5, "E"] = $"{card.Car.Mark} {card.Car.Number}"; List <Malfunctions> MalfList = card.ListOfMalf.Select(n => n).Where(n => n.MalfOrSpare == 0).ToList <Malfunctions>(); List <Malfunctions> SpareList = card.ListOfMalf.Select(n => n).Where(n => n.MalfOrSpare == 1).ToList <Malfunctions>(); FillRowsWithMalf(xlSheet, rowStartAct1, rowFinishAct1, MalfList); FillRowsWithSpares(xlSheet, rowStartAct2, rowFinishAct2, SpareList); xlSheet.Cells[34, "Q"] = Malfunctions.GetTotalPriceFromList(MalfList); xlSheet.Cells[54, "Q"] = Malfunctions.GetTotalPriceFromList(SpareList); xlSheet.Cells[55, "Q"] = card.TotalPrice; xlWorkBook.SaveAs(fileOperator.MakeActPath(card, mainPath)); xlWorkBook.Close(); xlApp.Quit(); while (System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp) > 0) { } //MessageBox.Show($"Акт № {idRepair} выгружен в формате Excel!"); } catch (Exception ex) { MessageBox.Show($"Не удалось сделать акт выполненных работ № {idRepair}\n" + $"{ex.Message}"); xlWorkBook.Close(false); xlApp.Quit(); while (System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp) > 0) { } } }
public static IEnumerable <CardDm> GetAllCommanderLegalCardInGivenColors(List <string> desiredColors) { Console.WriteLine("Attempting to pull from DBs"); using (var db = new MtgEntities()) { var invalidColors = GetInvalidColors(desiredColors); var legalCards = db.Cards .Where(c => c.Commander == "legal") .Where(c => invalidColors.All(i => !c.Cost.Contains(i) && !c.RulesText.Contains(i))); foreach (var card in legalCards) { yield return(CardMapper.Map(card)); } } Console.WriteLine("finished db"); }
public void SetUp() { var cardNumber = "1234123412341234"; var expiryDate = "1220"; var cvv = "123"; var name = "Mr J Bloggs"; _cardRequest = new CardRequest { CardNumber = cardNumber, ExpiryDate = expiryDate, Cvv = cvv, Name = name }; _sut = new CardMapper(); }
public void Given_A_CardModel_When_Mapped_To_Card_Then_CardSubCategory_Should_Have_A_Count_Of_2() { // Arrange var cardModel = new CardModel { SubCategoryIds = new List <int> { 4, 23 }, TypeIds = new List <int>(), LinkArrowIds = new List <int>() }; // Act var result = CardMapper.MapToSpellOrTrapCard(cardModel); // Assert result.CardSubCategory.Should().HaveCount(2); }
static public void MakeOrderInExcel(string idRepair, string unloadPath) { rowStartForDelete = 0; try { xlApp = new Excel.Application(); xlWorkBook = xlApp.Workbooks.Open(ConfigurationManager.AppSettings.Get("PathForOpenOrder")); xlSheet = xlWorkBook.Sheets[1]; CardOfRepair card = new CardMapper().Get(idRepair.ToString()); SystemOwner systemOwner = new OwnerMapper().Get(); FileOperator fileOperator = new FileOperator(); xlSheet.Cells[3, "G"] = card.IdRepair; xlSheet.Cells[5, "O"] = card.TimeOfStart.ToString("dd/MM/yyyy"); xlSheet.Cells[7, "O"] = ((DateTime)card.TimeOfFinish).ToString("dd/MM/yyyy"); xlSheet.Cells[9, "A"] = $"Заказчик: {card.Car.Owner.Name}"; xlSheet.Cells[1, "J"] = $"Исполнитель: {systemOwner.Name} {systemOwner.Address} {systemOwner.PhoneNumber}"; xlSheet.Cells[64, "I"] = systemOwner.Director.GetShortName(); xlSheet.Cells[10, "D"] = card.Car.Mark; xlSheet.Cells[11, "G"] = card.Car.Number; List <Malfunctions> MalfList = card.ListOfMalf.Select(n => n).Where(n => n.MalfOrSpare == 0).ToList <Malfunctions>(); List <Malfunctions> SpareList = card.ListOfMalf.Select(n => n).Where(n => n.MalfOrSpare == 1).ToList <Malfunctions>(); FillRowsWithMalf(xlSheet, rowStartOrder1, rowFinishOrder1, MalfList); FillRowsWithSpares(xlSheet, rowStartOrder2, rowFinishOrder2, SpareList); xlSheet.Cells[41, "Q"] = Malfunctions.GetTotalPriceFromList(MalfList); xlSheet.Cells[61, "Q"] = Malfunctions.GetTotalPriceFromList(SpareList); xlSheet.Cells[62, "Q"] = card.TotalPrice; xlWorkBook.SaveAs(fileOperator.MakeOrderPath(card, mainPath)); xlWorkBook.Close(); xlApp.Quit(); while (System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp) > 0) { } } catch (Exception ex) { MessageBox.Show($"Не удалось сделать акт выполненных работ № {idRepair}\n" + $"{ex.Message}"); xlWorkBook.Close(false); xlApp.Quit(); while (System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp) > 0) { } } }
public void MakeBillInExcel(string idRepair) { try { xlApp = new Excel.Application(); xlWorkBook = xlApp.Workbooks.Open(ConfigurationManager.AppSettings.Get("PathForOpenBill")); xlSheet = xlWorkBook.Sheets[1]; SystemOwner systemOwner = new OwnerMapper().Get(); CardOfRepair card = new CardMapper().Get(idRepair.ToString()); FileOperator fileOperator = new FileOperator(); xlSheet.Cells[5, "B"] = systemOwner.Bank.Name; xlSheet.Cells[5, "X"] = systemOwner.Bank.BIK; xlSheet.Cells[6, "X"] = systemOwner.Bank.KorBill; xlSheet.Cells[9, "B"] = systemOwner.Name; xlSheet.Cells[8, "D"] = systemOwner.INN; xlSheet.Cells[8, "X"] = systemOwner.Bill; xlSheet.Cells[17, "F"] = systemOwner.ToString(); xlSheet.Cells[30, "H"] = systemOwner.Director.GetFullName(); xlSheet.Cells[13, "K"] = card.IdRepair; xlSheet.Cells[13, "Q"] = ((DateTime)card.TimeOfFinish).ToString("dd/MM/yyyy"); xlSheet.Cells[19, "F"] = $"{card.Car.Owner.Name}, ИНН {card.Car.Owner.INN}, {card.Car.Owner.Address}"; xlSheet.Cells[22, "D"] = $"Ремонт автомобиля: {card.Car.ToString()} по заявке № {idRepair}" + $" от {((DateTime)card.TimeOfFinish).ToString("dd/MM/yyyy")}"; xlSheet.Cells[22, "AB"] = card.TotalPrice; xlSheet.Cells[28, "B"] = RuDateAndMoneyConverter.CurrencyToTxt(card.TotalPrice, true); xlWorkBook.SaveAs(fileOperator.MakeBillPath(card, mainPath)); xlWorkBook.Close(); xlApp.Quit(); while (System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp) > 0) { } } catch (Exception ex) { MessageBox.Show($"Не удалось сделать счет на оплату № {idRepair}\n" + $"{ex.Message}"); xlWorkBook.Close(false); xlApp.Quit(); while (System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp) > 0) { } } }
public void CardMapperMapsFilledCardToCardDto() { var card = new Card { CardNumber = "1234123412341234", Cvv = 123, ExpiryMonth = 12, ExpiryYear = 20 }; var mapper = new CardMapper(); var cardDto = mapper.Map(card); cardDto.Should().NotBeNull(); cardDto.Cvv.Should().Be(123); cardDto.CardNumber.Should().Be("1234123412341234"); cardDto.ExpiryMonth.Should().Be(12); cardDto.ExpiryYear.Should().Be(20); }
public void Given_A_CardModel_When_Mapped_To_Card_Then_CardSubCategory_Should_Contain_All_SubCategory_Ids() { // Arrange var expected = new[] { 4, 23 }; var cardModel = new CardModel { SubCategoryIds = new List <int> { 4, 23 }, TypeIds = new List <int>(), LinkArrowIds = new List <int>() }; // Act var result = CardMapper.MapToSpellOrTrapCard(cardModel); // Assert result.CardSubCategory.Select(cs => cs.SubCategoryId).Should().ContainInOrder(expected); }
public void Given_A_MonsterCard_When_Updated_With_CardModel_Then_CardType_Should_Have_A_Count_Of_2() { // Arrange var monsterCard = new Card(); var cardModel = new CardModel { SubCategoryIds = new List <int>(), TypeIds = new List <int> { 4, 23 }, LinkArrowIds = new List <int>() }; // Act CardMapper.UpdateMonsterCardWith(monsterCard, cardModel); // Assert monsterCard.CardType.Should().HaveCount(2); }
public void Given_A_MonsterCard_When_Updated_With_CardModel_Then_CardType_Should_Contain_All_SubCategory_Ids() { // Arrange var expected = new[] { 4, 23 }; var monsterCard = new Card(); var cardModel = new CardModel { SubCategoryIds = new List <int>(), TypeIds = new List <int> { 4, 23 }, LinkArrowIds = new List <int>() }; // Act CardMapper.UpdateMonsterCardWith(monsterCard, cardModel); // Assert monsterCard.CardType.Select(cs => cs.TypeId).Should().ContainInOrder(expected); }