public async Task Can_Cleare_Content() { var options = new DbContextOptionsBuilder <SportStoreDbContext>() .UseInMemoryDatabase(databaseName: "Can_Cleare_Content") .Options; var cardItem1 = new CardItem() { Product = new Product() { Id = 1, Price = 5.0M, Name = "P1" }, Quantity = 1, IsDeleted = false }; var cardItem2 = new CardItem() { Product = new Product() { Id = 2, Price = 5.0M, Name = "P2" }, Quantity = 2, IsDeleted = false }; var cardItem3 = new CardItem() { Product = new Product() { Id = 3, Price = 5.0M, Name = "P2" }, Quantity = 2, IsDeleted = false }; using (var context = new SportStoreDbContext(options)) { await context.CardItems.AddAsync(cardItem1); await context.CardItems.AddAsync(cardItem2); await context.CardItems.AddAsync(cardItem3); await context.SaveChangesAsync(); var service = new CardService(context); await service.Clear(); var cleared = await context .CardItems .ToListAsync(); var clearedCount = cleared.Where(c => c.IsDeleted).Count(); Assert.Equal(3, clearedCount); } }
public async Task Get_All_Card_Items() { var options = new DbContextOptionsBuilder <SportStoreDbContext>() .UseInMemoryDatabase(databaseName: "Get_All_Card_Items") .Options; var cardItem1 = new CardItem() { Product = new Product() { Id = 1, Price = 5.0M, Name = "P1" }, Quantity = 1, IsDeleted = false }; var cardItem2 = new CardItem() { Product = new Product() { Id = 2, Price = 5.0M, Name = "P2" }, Quantity = 2, IsDeleted = false }; var cardItem3 = new CardItem() { Product = new Product() { Id = 3, Price = 5.0M, Name = "P2" }, Quantity = 2, IsDeleted = false }; using (var context = new SportStoreDbContext(options)) { await context.CardItems.AddAsync(cardItem1); await context.CardItems.AddAsync(cardItem2); await context.CardItems.AddAsync(cardItem3); await context.SaveChangesAsync(); var service = new CardService(context); var result = await service.GetAll(); var resultCount = result.ToList().Count; var savedItems = await context .CardItems .ToListAsync(); Assert.Equal(savedItems.Count, resultCount); } }
private Game GenerateGame() { CardService cardService = new CardService(); List <Card> deckOfCards = cardService.GenerateShuffledCards(); Table table = new Table(deckOfCards); return(new Game(table)); }
// GET: Card public ActionResult Index() { //var search = new CardSearchParams(); var service = new CardService(); var model = service.GetCards(); return(View(model)); }
// GET: Collection public ActionResult Index() { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new CardService(userId); var model = service.GetCollection(); return(View(model)); }
public int Update(CardViewModel data) { var map = mapper.CreateMapper(); CardDTO card = map.Map <CardDTO>(data); int i = card.Id = CardService.Update(card); return(i); }
public int Delete(int cardId) { var map = mapper.CreateMapper(); CardDTO card = CardService.Get(cardId); int i = CardService.Delete(card); return(i); }
public void RemoveCard(string customerId, string cardId) { StripeConfiguration.ApiKey = secretkey; var service = new CardService(); var card = service.Delete(customerId, cardId); Console.WriteLine($"Card: {JsonConvert.SerializeObject(card)}"); }
public ActionResult Details(int id) { var userId = User.Identity.GetUserId(); var svc = new CardService(userId); var model = svc.GetCardById(id); return(View(model)); }
public bool AddCard(Guid cardId) { var cardService = new CardService(); var card = cardService.GetCard(cardId); Cards.Add(card); return(true); }
public void CalculateOrders_EnumerableNull_ThrowsNullArgumentException() { var service = new CardService(); void action() => service.CalculateOrders(null); Assert.Throws <ArgumentNullException>(action); }
public BoardsController(BoardService boardService, LaneService laneService, CardService cardService, UserService userService, IHubContext <BroadcastHub> hubContext, IHttpContextAccessor httpContextAccessor) { this.boardService = boardService; this.laneService = laneService; this.cardService = cardService; this.userService = userService; this.hubContext = hubContext; this.httpContextAccessor = httpContextAccessor; }
public void InitializeServices() { this.hubService = new Mock <ISignalRHubService>(); this.userService = new UserService(this.users); this.roomService = new RoomService(this.hubService.Object, this.rooms, this.users); this.roundService = new RoundService(this.hubService.Object, new TimerService(), this.rooms, this.rounds, this.users, this.decks); this.deckService = new DeckService(this.decks); this.cardService = new CardService(this.cards); }
public void CardServiceWorksWithoutGAME() { var cards = new CardService(null).GetAllCards(); Assert.IsNotNull(cards); Assert.AreEqual(181, cards.Count); Assert.IsFalse(cards.Any(c => string.IsNullOrEmpty(c.Name))); }
public DeckApi() { ICardService cardService = new CardService(); _cardController = new CardController(cardService); IUserService userService = new UserService(); _userController = new UserController(userService); }
public BaseCard(Name holderName, CardService service, string pin) { CardNumber = GenerateCardNumber(); CVV = GenerateCVV(); ExpirationDate = GenerateExpirationDate(); HolderName = holderName; Service = service; PIN = pin; }
public async Task Get_AllCard() { var service = new CardService(_httpClient); var result = await service.GetAllCards(requestUri); // Assert Assert.False(result.Status == HttpStatusCode.BadRequest, "ERROR"); Assert.True(result.Status == HttpStatusCode.OK, "OK"); }
/// <inheritdoc /> /// <exception cref="UserNotFoundException">Thrown when the user is not found</exception> public async Task <PaymentMethodViewModel> AddPaymentMethod(AddPaymentMethodBody addPaymentMethodBody) { var user = await ApplicationContext.Users.Include(x => x.PaymentMethods) .FirstOrDefaultAsync(x => x.Id == addPaymentMethodBody.UserId); if (user == null) { throw new UserNotFoundException(); } // if the user doesn't have a stripe customer create one if (user.StripeCustomerId == null) { var customer = CreateCustomer(user); user.StripeCustomerId = customer.Id; await ApplicationContext.SaveChangesAsync(); } var options = new CardCreateOptions() { Source = addPaymentMethodBody.CardToken }; var service = new CardService(); try { // request create card to Stripe api var card = service.Create(user.StripeCustomerId, options); // create payment method using Stripe response data var paymentMethod = new PaymentMethod() { StripeCardId = card.Id, Brand = card.Brand, Country = card.Country, Funding = card.Funding, Name = card.Name, ExpiryMonth = card.ExpMonth, ExpiryYear = card.ExpYear, LastFour = card.Last4, NickName = addPaymentMethodBody.NickName, IsDefault = !user.PaymentMethods.Any() }; user.PaymentMethods.Add(paymentMethod); await ApplicationContext.SaveChangesAsync(); return(Mapper.Map <PaymentMethodViewModel>(paymentMethod)); } catch (Exception e) { Logger.LogInformation(e.Message); throw; } }
public void When_ValidAccountIdAndPinEntered_ReturnTrue() { CardService cardService = new CardService(_mockCustomerAccountRepository.Object); cardService.Initialize(); bool isValid = cardService.VerifyAccount(120001, 1121); Assert.AreEqual(isValid, true); }
//Get: AddCardToCollection public ActionResult AddCard(string cardId) { var cardService = new CardService(); var cardModel = cardService.GetCardById(cardId); var collectionService = new CollectionService(); ViewBag.CollectionId = new SelectList(collectionService.GetAllCollections().ToList(), "CollectionId", "Name"); return(View(cardModel)); }
//Get: AddAttackToCard public ActionResult AddAttack(string cardId) { var cardService = new CardService(); var cardModel = cardService.GetCardById(cardId); var attackService = new AttackService(); ViewBag.AttackId = new SelectList(attackService.GetAllAttacks().ToList(), "AttackId", "Name"); return(View(cardModel)); }
public JsonResult AddCardAsync([FromBody] Card card) { if (card != null) { card = new CardService(context).Create(card); return(Json(card)); } return(Json(false)); }
public JsonResult UpdateCardTitleAsync([FromBody] Card card) { if (card != null) { var success = new CardService(context).UpdateTitle(card); return(Json(success)); } return(Json(false)); }
public static Card RemoveCard(string cusId, string cardId) { // Set your secret key: remember to change this to your live secret key in production // See your keys here: https://dashboard.stripe.com/Card/apikeys StripeConfiguration.SetApiKey(SecretKey); var service = new CardService(); var cardDelete = service.Delete(cusId, cardId); return(cardDelete); }
public static void GetAllCards() { var service = new CardService(); var cards = service.GetFromDatabase(); foreach (var card in cards) { System.Console.WriteLine($"{card.Name} ({card.Cmc})"); } }
public async Task <StripeList <Card> > GetCardListAsync(string customerId) { var service = new CardService(); var options = new CardListOptions { Limit = 3, }; return(await service.ListAsync(customerId, options)); }
public ActionResult DeletePost(int id) { var service = new CardService(); service.DeleteCard(id); TempData["SaveResult"] = "Card Deleted"; return(RedirectToAction("Index")); }
public JsonResult DeleteCardAsync([FromBody] Card card) { if (card != null) { var success = new CardService(context).Delete(card); return(Json(success)); } return(Json(false)); }
public async Task <StripePaymentCardResult> InsertStripeCardToStripeUser(PaymentCard paymentCard, string stripeuserId) { try { //Insertar tarjeta a un customer StripeConfiguration.ApiKey = this._configuration.GetSection("Stripe")["SecretKey"]; //Obtenemos los valores de la tarjeta var tokenoptions = new TokenCreateOptions() { Card = new CreditCardOptions() { Number = paymentCard.CardNumber, ExpYear = long.Parse(paymentCard.Year), ExpMonth = long.Parse(paymentCard.Month), Cvc = paymentCard.Cvc, Name = paymentCard.HolderName, }, }; //Creamos el token de la tarjeta var tokenService = new TokenService(); var stripeToken = await tokenService.CreateAsync(tokenoptions); //El token pasara la informacion necesaria de la tarjeta var CardCreateoptions = new CardCreateOptions { Source = stripeToken.Id, }; //Comenzamos a usar el servicio de la tarjeta. var cardservice = new CardService(); //Creamos la tarjeta para un el customer de stripe var cardserviceToken = await cardservice.CreateAsync(stripeuserId, CardCreateoptions); //Verificamos los valores si son correctos. if (!string.IsNullOrEmpty(cardserviceToken.Id)) { var result = new StripePaymentCardResult(cardserviceToken.Id); return(result); } else { return(new StripePaymentCardResult(true, "Token could not be creted try again.")); } } catch (Exception e) { return(new StripePaymentCardResult(true, e.Message)); } }
private void BuyCharacter() { var characterId = characterData.Id; var characterTier = characterData.Tier; InGameManager.instance.combinationSystem.AddCharacter(characterId); InGameManager.instance.playerState.UseCoin(CardService.GetPriceByTier(characterTier)); isBoughtCard = true; OnHide(); }
static void Main(string[] args) { service = new CardService(); Console.WriteLine("Starting Analysis"); //AnalyzeCardRelationships(); AnalyzeSphereBreakdowns(); Console.WriteLine("Analysis Complete. Press ENTER to close."); Console.ReadLine(); }
public OpenpayAPI( string api_key, string merchant_id,bool production = false) { this.httpClient = new OpenpayHttpClient(api_key, merchant_id, production); CustomerService = new CustomerService(this.httpClient); CardService = new CardService(this.httpClient); BankAccountService = new BankAccountService(this.httpClient); ChargeService = new ChargeService(this.httpClient); PayoutService = new PayoutService(this.httpClient); TransferService = new TransferService(this.httpClient); FeeService = new FeeService(this.httpClient); PlanService = new PlanService(this.httpClient); SubscriptionService = new SubscriptionService(this.httpClient); OpenpayFeesService = new OpenpayFeesService(this.httpClient); WebhooksService = new WebhookService (this.httpClient); }
public ExportController() { _cardService = new CardService(); }