예제 #1
0
        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);
            }
        }
예제 #3
0
        private Game GenerateGame()
        {
            CardService cardService = new CardService();
            List <Card> deckOfCards = cardService.GenerateShuffledCards();
            Table       table       = new Table(deckOfCards);

            return(new Game(table));
        }
예제 #4
0
        // 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));
        }
예제 #6
0
        public int Update(CardViewModel data)
        {
            var     map  = mapper.CreateMapper();
            CardDTO card = map.Map <CardDTO>(data);
            int     i    = card.Id = CardService.Update(card);

            return(i);
        }
예제 #7
0
        public int Delete(int cardId)
        {
            var     map  = mapper.CreateMapper();
            CardDTO card = CardService.Get(cardId);
            int     i    = CardService.Delete(card);

            return(i);
        }
예제 #8
0
        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)}");
        }
예제 #9
0
        public ActionResult Details(int id)
        {
            var userId = User.Identity.GetUserId();
            var svc    = new CardService(userId);
            var model  = svc.GetCardById(id);

            return(View(model));
        }
예제 #10
0
        public bool AddCard(Guid cardId)
        {
            var cardService = new CardService();
            var card        = cardService.GetCard(cardId);

            Cards.Add(card);
            return(true);
        }
예제 #11
0
        public void CalculateOrders_EnumerableNull_ThrowsNullArgumentException()
        {
            var service = new CardService();

            void action() => service.CalculateOrders(null);

            Assert.Throws <ArgumentNullException>(action);
        }
예제 #12
0
 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;
 }
예제 #13
0
 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);
 }
예제 #14
0
        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)));
        }
예제 #15
0
        public DeckApi()
        {
            ICardService cardService = new CardService();

            _cardController = new CardController(cardService);
            IUserService userService = new UserService();

            _userController = new UserController(userService);
        }
예제 #16
0
 public BaseCard(Name holderName, CardService service, string pin)
 {
     CardNumber     = GenerateCardNumber();
     CVV            = GenerateCVV();
     ExpirationDate = GenerateExpirationDate();
     HolderName     = holderName;
     Service        = service;
     PIN            = pin;
 }
예제 #17
0
        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");
        }
예제 #18
0
        /// <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;
            }
        }
예제 #19
0
        public void When_ValidAccountIdAndPinEntered_ReturnTrue()
        {
            CardService cardService = new CardService(_mockCustomerAccountRepository.Object);

            cardService.Initialize();

            bool isValid = cardService.VerifyAccount(120001, 1121);

            Assert.AreEqual(isValid, true);
        }
예제 #20
0
        //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));
        }
예제 #21
0
        //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));
        }
예제 #22
0
        public JsonResult AddCardAsync([FromBody] Card card)
        {
            if (card != null)
            {
                card = new CardService(context).Create(card);
                return(Json(card));
            }

            return(Json(false));
        }
예제 #23
0
        public JsonResult UpdateCardTitleAsync([FromBody] Card card)
        {
            if (card != null)
            {
                var success = new CardService(context).UpdateTitle(card);
                return(Json(success));
            }

            return(Json(false));
        }
예제 #24
0
        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);
        }
예제 #25
0
        public static void GetAllCards()
        {
            var service = new CardService();
            var cards   = service.GetFromDatabase();

            foreach (var card in cards)
            {
                System.Console.WriteLine($"{card.Name} ({card.Cmc})");
            }
        }
예제 #26
0
        public async Task <StripeList <Card> > GetCardListAsync(string customerId)
        {
            var service = new CardService();
            var options = new CardListOptions
            {
                Limit = 3,
            };

            return(await service.ListAsync(customerId, options));
        }
예제 #27
0
        public ActionResult DeletePost(int id)
        {
            var service = new CardService();

            service.DeleteCard(id);

            TempData["SaveResult"] = "Card Deleted";

            return(RedirectToAction("Index"));
        }
예제 #28
0
        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));
            }
        }
예제 #30
0
    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();
    }
예제 #31
0
        static void Main(string[] args)
        {
            service = new CardService();

            Console.WriteLine("Starting Analysis");

            //AnalyzeCardRelationships();
            AnalyzeSphereBreakdowns();

            Console.WriteLine("Analysis Complete. Press ENTER to close.");
            Console.ReadLine();
        }
예제 #32
0
        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);
        }
예제 #33
0
 public ExportController()
 {
     _cardService = new CardService();
 }