示例#1
0
        public void CreateApplication(BaseCardApplicationModel model)
        {
            switch (model.CardTypeId)
            {
            case 1001:
                using (var ts = new TransactionScope())
                {
                    model.CreditCardApplication.BaseApplicationId = cardsDAO.CreateBaseApplication(model);
                    cardsDAO.CreateCreditCardApplication(model.CreditCardApplication);
                    ts.Complete();
                }
                break;

            case 1002:
                using (var ts = new TransactionScope())
                {
                    model.DebitCardApplication.BaseApplicationId = cardsDAO.CreateBaseApplication(model);
                    cardsDAO.CreateDebitCardApplication(model.DebitCardApplication);
                    ts.Complete();
                }
                break;

            case 1003:
                using (var ts = new TransactionScope())
                {
                    model.ATMCardApplication.BaseApplicationId = cardsDAO.CreateBaseApplication(model);
                    cardsDAO.CreateATMCardApplication(model.ATMCardApplication);
                    ts.Complete();
                }
                break;

            default:
                throw new ApplicationException("Unexpected card type");
            }
        }
示例#2
0
        public ActionResult BaseCardApplication(BaseCardApplicationModel model)
        {
            model.CreationDate = DateTime.Now;
            model.UserId       = User.Identity.GetUserId();
            cardsFcd.CreateApplication(model);

            return(Redirect("~/PaymentCards/ApplicationList"));
        }
示例#3
0
        public int CreateBaseApplication(BaseCardApplicationModel model)
        {
            PaymentCardApplication application = new PaymentCardApplication()
            {
                UserId       = model.UserId,
                TypeId       = model.CardTypeId,
                CreationDate = model.CreationDate
            };

            context.Entry(application).State = System.Data.Entity.EntityState.Added;
            context.SaveChanges();
            return(application.Id);
        }
示例#4
0
        public ActionResult BaseCardApplication()
        {
            List <SelectListItem> items = new List <SelectListItem>();

            items.Add(new SelectListItem()
            {
                Text = "-- Wybierz typ karty płatniczej --", Value = "0"
            });
            items.Add(new SelectListItem()
            {
                Text = "Karta kredytowa", Value = "1001"
            });
            items.Add(new SelectListItem()
            {
                Text = "Karta debetowa", Value = "1002"
            });
            items.Add(new SelectListItem()
            {
                Text = "Karta bankomatowa", Value = "1003"
            });

            List <SelectListItem> accounts = new List <SelectListItem>();

            accounts = usersFcd.GetUserAccountsByUserId(User.Identity.GetUserId()).Select(
                x => new SelectListItem()
            {
                Text  = x.AccountNumber,
                Value = x.Id.ToString()
            }).ToList();

            BaseCardApplicationModel baseCardApplication = new BaseCardApplicationModel()
            {
                CardTypes             = items,
                CreditCardApplication = new CreditCardApplication(),
                DebitCardApplication  = new DebitCardApplication()
                {
                    Accounts = accounts
                },
                ATMCardApplication = new ATMCardApplication()
                {
                    Accounts = accounts
                },
                HasAnyAccount = accounts.Count > 0 ? true : false
            };

            return(View(baseCardApplication));
        }