Inheritance: PaymentCard
        public void DebitCardAuthorizeSuccessfulTest()
        {
            var client = new NaturalPerson("Jan Kowalski", "11312737254");
            var card   = new DebitCard("1234567890", client, true, 1250.12m);

            Assert.AreEqual(card.Authorize(1500), BankActionResult.SUCCESS);
        }
        public void DebitCardAuthorizeRejectedTest()
        {
            var client = new NaturalPerson("Jan Kowalski", "11312737254");
            var card   = new DebitCard("1234567890", client, true, 1250.12m);

            Assert.AreEqual(card.Authorize(-3500), BankActionResult.REJECTED_INSUFFICIENT_ACCOUNT_BALANCE);
        }
Ejemplo n.º 3
0
        public ActionResult AtiveConfirmed(int id)
        {
            DebitCard debitCard = db.DebitCard.Find(id);

            using (var trans = db.Database.BeginTransaction())
            {
                int idUser = (int)Session["idUser"]; //who is login
                try
                {
                    debitCard.ReactivateDebitCard();
                    db.SaveChanges();

                    Log log = new Log
                    {
                        Who         = idUser,
                        DebitCardId = id,
                        CompanyId   = debitCard.CompanyId,
                        New         = "ACTIVATED",
                        Old         = "DISABLED"
                    };
                    db.Log.Add(log);
                    db.SaveChanges();

                    trans.Commit();
                    TempData["confirm"] = "SUCCESSFUL REACTIVATION";
                }
                catch
                {
                    trans.Rollback();
                    TempData["error"] = "ERROR 500, TRAY AGAIN, IF THE ERROR PERSIST CONTACT THE SYSTEM SUPPLIER";
                }
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 4
0
 public SetCardLimitDialog(int cardId, CardLimitType limitType)
 {
     _cardId          = cardId;
     _limitType       = limitType;
     _selectedCard    = DAL.GetDebitCard(_cardId);
     _cardCurrencyIso = DAL.GetIsoCurrency(_cardId);
 }
Ejemplo n.º 5
0
        public async Task <DebitCard> AddAsync(DebitCard debitCard)
        {
            await _dbContext.DebitCards.AddAsync(debitCard);

            await SaveAsync();

            return(debitCard);
        }
Ejemplo n.º 6
0
        public void DebitCardsAreNotEqualDifferentNumbersTest()
        {
            var client = new NaturalPerson("Jan Kowalski", "11312737254");
            var card   = new DebitCard("1233567890", client, true, 1250.12m);
            var card2  = new DebitCard("1234567890", client, true, 1250.12m);

            Assert.AreNotEqual(card, card2);
        }
        public void DebitCardSuccessfulTransactionTest()
        {
            var client = new NaturalPerson("Jan Kowalski", "11312737254");
            var card   = new DebitCard("1234567890", client, true, 1250.12m);

            card.MakeTransaction(1200);
            Assert.AreEqual(card.Balance, 2450.12m);
        }
        public ActionResult DeleteConfirmed(long id)
        {
            DebitCard debitcard = db.DebitCards.Find(id);

            db.DebitCards.Remove(debitcard);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 9
0
        private static void debitCard()
        {
            DebitCard d = new DebitCard();

            d.Connect();
            int dcid = d.BeginTransaction(price);

            d.EndTransaction(dcid);
        }
 public static DebitCardDto ToDebitCardDTOMap(DebitCard d)
 {
     return(new DebitCardDto()
     {
         CardNumber = d.Id,
         CardName = d.CardName,
         BankAccount = BankAccountMapper.ToBankAccountDTOMap(d.BankAccount)
     });
 }
Ejemplo n.º 11
0
        [TestMethod] public void CreateDebitCardViewTest()
        {
            var data = GetRandom.Object <DebitCardData>();

            data.CurrencyID = data.Currency.ID;
            var card = new DebitCard(data);
            var view = PaymentMethodViewFactory.Create(card) as DebitCardView;

            Assert.IsInstanceOfType(view, typeof(DebitCardView));
            validateDebitCard(view, card);
        }
Ejemplo n.º 12
0
        public void GetHashCodeTest()
        {
            var client = new NaturalPerson("Jan Kowalski", "11312737254");
            var card1  = new ATMCard("1234567890", client, true, 1250.12m);
            var card2  = new CreditCard("1254367890", client, true, 1250.12m);
            var card3  = new DebitCard("1234587690", client, true, 1250.12m);

            Assert.AreEqual(1234567890, card1.GetHashCode());
            Assert.AreEqual(1254367890, card2.GetHashCode());
            Assert.AreEqual(1234587690, card3.GetHashCode());
        }
Ejemplo n.º 13
0
 public DebitCardCollection(DebitCardModel mortrageModel, DebitCard debitCard)
 {
     CreditCardModel = mortrageModel;
     CreditCard      = debitCard;
     Id            = debitCard.Id;
     Name          = mortrageModel.Name;
     MoneyCount    = Convert.ToDecimal(debitCard.MoneyCount.ToString("N1"));
     ValidityStart = debitCard.ValidityStart;
     ValidityEnd   = debitCard.ValidityEnd;
     AnnualFee     = Convert.ToDecimal(mortrageModel.AnnualFee.ToString("N1"));
 }
        public IActionResult CheckCard(DebitCard card)
        {
            var result = _debitCardService.CheckCard(card);

            if (result.Success)
            {
                return(Ok(result));
            }

            return(BadRequest(result));
        }
Ejemplo n.º 15
0
        internal static void AccountChargeTests()
        {
            // Create new debit card proxy instance.
            var debitCard = new DebitCard();

            // Attempt two successful charges.
            debitCard.ChargeAccount(125.50M);
            debitCard.ChargeAccount(500);
            // Attempt overcharge.
            debitCard.ChargeAccount(432.10M);
        }
        public IActionResult Update(DebitCard debitCard)
        {
            var result = _debitCardService.Update(debitCard);

            if (result.Success)
            {
                return(Ok(result));
            }

            return(BadRequest(result));
        }
Ejemplo n.º 17
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Error500", "Error"));
            }

            try
            {
                int    idUser     = Session["idUser"] != null ? (int)Session["idUser"] : 0;
                int    permission = Session["permission"] != null ? (int)Session["permission"] : 0;
                int    idCompany  = Session["permission"] != null ? (int)Session["idCompany"] : 0;
                string userName   = Session["permission"] != null ? (string)Session["username"] : null;

                if (Check.IsLogOn(idUser, permission, idCompany, userName))
                {
                    DebitCard debitCard = db.DebitCard.Find(id);
                    if (debitCard == null)
                    {
                        return(RedirectToAction("Error404", "Error"));
                    }


                    if (Check.IsSuperAdmin(permission))
                    {
                        ViewBag.CompanyId = new SelectList(db.Company, "IdCompany", "NameCompany");
                    }
                    else if (Check.IsSupervisor(permission) && Check.IsSameCompany(idCompany, debitCard.CompanyId))
                    {
                        Company        company   = db.Company.Where(c => c.IdCompany == idCompany).FirstOrDefault();
                        List <Company> companies = new List <Company>();
                        companies.Add(company);
                        ViewBag.CompanyId = new SelectList(companies, "IdCompany", "NameCompany", idCompany);
                    }
                    else
                    {
                        TempData["error"] = "YOU DO NOT HAVE PERMISSION";
                        return(RedirectToAction("Home", "Employees"));
                    }

                    return(View(debitCard));
                }
                else
                {
                    TempData["error"] = "YOU ARE NOT LOGGED IN";
                    return(RedirectToAction("LogIn", "Employees"));
                }
            }
            catch
            {
                return(RedirectToAction("Error500", "Error"));
            }
        }
        static void Main(string[] args)
        {
            var debitcard = new DebitCard();

            debitcard.SetCustomerName("Mohiuddin");
            debitcard.SetInstrumentType(InstrumentType.Card);
            debitcard.SetFinancialOrganizationName("EBL");

            var paymentProcessor = new PaymentProcessor.Processor.PaymentProcessor();

            paymentProcessor.Process(debitcard, 100);
        }
Ejemplo n.º 19
0
        public void DebitCard_ShouldConvertValuesToCieloFormat()
        {
            var creditCard = new DebitCard("4556-2299-4919-5288", "John Doe", new CardExpiration(2020, 08), "123", CardBrand.Visa);

            creditCard.Should().NotBeNull();


            creditCard.CardNumber.Should().BeOfType(typeof(string)).And.Equals("4556229949195288");
            creditCard.Holder.Should().BeOfType(typeof(string)).And.Equals("John Doe");
            creditCard.ExpirationDate.Should().BeOfType(typeof(string)).And.Equals("08/2020");
            creditCard.SecurityCode.Should().BeOfType(typeof(string)).And.Equals("123");
            creditCard.Brand.Should().BeOfType(typeof(string)).And.Equals(CardBrand.Visa.ToDescription());
        }
Ejemplo n.º 20
0
 private void OpenCard_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         DebitCard debitCard = new DebitCard(passwordBox.Password, _person, _debitCardModel);
         debitCard.Open();
         MessageBox.Show("Карта оформлена");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString());
     }
 }
Ejemplo n.º 21
0
 private void validateDebitCard(DebitCardView view, DebitCard card)
 {
     Assert.AreEqual(view.CardNumber, card.Data.Number);
     Assert.AreEqual(view.DailyLimit, card.DailyLimit.Amount);
     Assert.AreEqual(view.CurrencyID, card.DailyLimit.Currency.ID);
     Assert.AreEqual(view.BillingAddress, card.Data.Address);
     Assert.AreEqual(view.CardName, card.Data.Organization);
     Assert.AreEqual(view.NameOnCard, card.Data.Name);
     Assert.AreEqual(view.VerificationCode, card.Data.Code);
     Assert.AreEqual(view.IssueNumber, card.Data.Issue);
     Assert.AreEqual(view.ID, card.Data.ID);
     Assert.AreEqual(view.ValidFrom, card.Data.ValidFrom);
     Assert.AreEqual(view.ValidTo, card.Data.ValidTo);
 }
Ejemplo n.º 22
0
        public int CreateDebitCard(DebitCardApplication model, int baseId)
        {
            DebitCard card = new DebitCard()
            {
                BaseCardId    = baseId,
                MonthlyLimit  = 300,
                AccountId     = model.AccountId,
                IsContactless = model.IsContactless
            };

            context.Entry(card).State = System.Data.Entity.EntityState.Added;
            context.SaveChanges();
            return(card.Id);
        }
Ejemplo n.º 23
0
        static void Main(string[] args)
        {
            //LSP - Principio da substituição de LISKOV
            //Prega que uma classe derivada "pensando em heração"...
            //Pode ser substituivel por sua classe base sem quebrar o nosso codigo.

            //CreditCard card = new CreditCard();
            DebitCard card = new DebitCard();

            card.Validate();
            card.CollectPayment();

            Console.ReadLine();
        }
        public ActionResult Edit([Bind(Include = "ID,BankAccountID,Pin,State,ActivationDate")] DebitCard debitcard)
        {
            if (ModelState.IsValid)
            {
                db.Entry(debitcard).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BankAccountID = new SelectList(db.BankAccounts, "ID", "Name", debitcard.BankAccountID);
            ViewBag.State         = new SelectList(Eh_Stat.GetEnumValues(), "Value", "Text", Eh_Stat.GetIDByName(debitcard.State.ToString()));

            return(View(debitcard));
        }
        // GET: /DebitCards/Details/5
        public ActionResult Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DebitCard debitcard = db.DebitCards.Find(id);

            if (debitcard == null)
            {
                return(HttpNotFound());
            }
            return(View(debitcard));
        }
Ejemplo n.º 26
0
        public IDataResult <DebitCard> CheckCard(DebitCard card)
        {
            var checkByNumber        = _debitCardDal.Get(dc => dc.CardNumber == card.CardNumber);
            var checkByExprationDate = _debitCardDal.Get(dc => dc.ExpirationDate == card.ExpirationDate);
            var checkByCvv           = _debitCardDal.Get(dc => dc.CVV == card.CVV);
            var checkByFirstName     = _debitCardDal.Get(dc => dc.CardholderName == card.CardholderName);
            var checkByLastName      = _debitCardDal.Get(dc => dc.CardholderLastName == card.CardholderLastName);

            if (checkByNumber == null || checkByExprationDate == null || checkByCvv == null || checkByFirstName == null || checkByLastName == null)
            {
                return(new ErrorDataResult <DebitCard>(checkByNumber, Messages.CardInfoError));
            }
            return(new SuccessDataResult <DebitCard>(checkByNumber, Messages.CardInfoSuccess));
        }
Ejemplo n.º 27
0
        private async Task PostLimitInformationAsync(IDialogContext context, int cardId)
        {
            DebitCard card          = _clientDebitCards.Single(x => x.DebitCardId == cardId);
            string    cardTypeName  = card.DebitCardType.Type;
            int       withdrawLimit = card.DailyCashWithdrawalLimit ?? 0;
            int       purchaseLimit = card.DailyPaymentLimit ?? 0;
            string    currency      = card.Account.Currency;

            await context.PostAsync(TextProvider.Provide(TextCategory.GETCARDLIMIT_WithdrawalLimit) + withdrawLimit +
                                    " " + currency);

            await context.PostAsync(TextProvider.Provide(TextCategory.GETCARDLIMIT_PurchaseLimit) + purchaseLimit +
                                    " " + currency);
        }
        public ActionResult Create(CreateDebitCardViewModel viewModel)
        {
            string userId = User.Identity.GetUserId();

            if (userId is null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    // Success
                    DebitCard card = new DebitCard
                    {
                        CardHolderName = viewModel.CardHolderName,
                        CardNumber     = viewModel.CardNumber,
                        CVV2           = viewModel.CVV2,
                        CustomerId     = userId
                    };

                    if (card is null)
                    {
                        this.AddNotification("Error: card is null", NotificationType.ERROR);
                        return(RedirectToAction("ViewAllCustomersCards", new { id = userId }));
                    }

                    string fourDigitYear = "20" + viewModel.ExpiryDate.Substring(3, 2);

                    int      year  = int.Parse(fourDigitYear);
                    int      month = int.Parse(viewModel.ExpiryDate.Substring(0, 2));
                    DateTime date  = new DateTime(year, month, 1);
                    card.ExpiryDate = date;

                    context.DebitCards.Add(card);
                    context.SaveChanges();
                    this.AddNotification("Card Added", NotificationType.SUCCESS);
                    return(RedirectToAction("ViewAllCustomersCards", new { id = userId }));
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error: " + ex.Message);
                    this.AddNotification("Error: could not add card", NotificationType.ERROR);
                    return(RedirectToAction("ViewAllCustomersCards", new { id = userId }));
                }
            }
            return(RedirectToAction("ViewAllCustomersCards", new { id = userId }));
        }
        public ActionResult Create([Bind(Include = "BankAccountID,Pin,State,ActivationDate")] DebitCard debitcard)
        {
            if (ModelState.IsValid)
            {
                debitcard.ID = Ch_DC.GetNumberForDebitCard();
                db.DebitCards.Add(debitcard);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BankAccountID = new SelectList(db.BankAccounts, "ID", "Name", debitcard.BankAccountID);
            ViewBag.State         = new SelectList(Eh_Stat.GetEnumValues(), "Value", "Text");

            return(View(debitcard));
        }
Ejemplo n.º 30
0
        public async Task <DebitCard> UpdateAsync(DebitCard debitCard)
        {
            var existingDebitCard = await _dbContext.DebitCards.Where(c => c.Id == debitCard.Id && c.Disabled == false)
                                    .FirstOrDefaultAsync();

            if (existingDebitCard != null)
            {
                _dbContext.Entry(existingDebitCard).State = EntityState.Detached;
            }

            _dbContext.Entry(debitCard).State = EntityState.Modified;
            await SaveAsync();

            return(debitCard);
        }