/// <summary>
        ///     Sets up the CreditCards and Countries properties of the <see cref="BillingInfoViewModel"/>
        /// </summary>
        /// <param name="db">
        ///     The <see cref="IVeilDataAccess"/> to fetch info from
        /// </param>
        /// <param name="memberId">
        ///     The Id of the Member to fetch info about
        /// </param>
        /// <returns>
        ///     A task to await
        /// </returns>
        public async Task SetupCreditCardsAndCountries(IVeilDataAccess db, Guid memberId)
        {
            const int CREDIT_CARD_NUMBER_LENGTH = 12;

            var memberCreditCards =
                await db.Members.
                    Where(m => m.UserId == memberId).
                    SelectMany(m => m.CreditCards).
                    Select(
                        cc =>
                            new
                            {
                                cc.Id,
                                cc.Last4Digits
                            }).
                    ToListAsync();

            memberCreditCards = memberCreditCards.
                Select(
                    cc =>
                        new
                        {
                            cc.Id,
                            Last4Digits = cc.Last4Digits.PadLeft(CREDIT_CARD_NUMBER_LENGTH, '*')
                        }).
                ToList();

            Countries = await db.Countries.Include(c => c.Provinces).ToListAsync();
            CreditCards = new SelectList(
                memberCreditCards, nameof(MemberCreditCard.Id), nameof(MemberCreditCard.Last4Digits));
        }
 protected ManageController CreateManageController(
     VeilUserManager userManager = null, VeilSignInManager signInManager = null,
     IVeilDataAccess veilDataAccess = null, IGuidUserIdGetter idGetter = null,
     IStripeService stripeService = null)
 {
     return new ManageController(userManager, signInManager, veilDataAccess, idGetter, stripeService);
 }
예제 #3
0
 /// <summary>
 ///     Instantiates a new instance of WebOrdersController with the specified arguments
 /// </summary>
 /// <param name="veilDataAccess">
 ///     The <see cref="IVeilDataAccess"/> to use for database access
 /// </param>
 /// <param name="idGetter">
 ///     The <see cref="IGuidUserIdGetter"/> to use for getting the current user's Id
 /// </param>
 /// <param name="stripeService">
 ///     The <see cref="IStripeService"/> to use for Stripe interaction
 /// </param>
 /// <param name="userManager">
 ///     The <see cref="VeilUserManager"/> to use for sending an order confirmation email
 /// </param>
 public WebOrdersController(
     IVeilDataAccess veilDataAccess, IGuidUserIdGetter idGetter,
     IStripeService stripeService, VeilUserManager userManager)
 {
     db = veilDataAccess;
     this.idGetter = idGetter;
     this.stripeService = stripeService;
     this.userManager = userManager;
 }
예제 #4
0
 /// <summary>
 ///     Instantiates a new instance of CheckoutController with the provided arguments
 /// </summary>
 /// <param name="veilDataAccess">
 ///     The <see cref="IVeilDataAccess"/> to use for database access
 /// </param>
 /// <param name="idGetter">
 ///     The <see cref="IGuidUserIdGetter"/> to use for getting the current user's Id
 /// </param>
 /// <param name="stripeService">
 ///     The <see cref="IStripeService"/> to use for Stripe interaction
 /// </param>
 /// <param name="shippingCostService">
 ///     The <see cref="IShippingCostService"/> to use for getting the shipping cost for
 ///     the items in the cart
 /// </param>
 /// <param name="userManager">
 ///     The <see cref="VeilUserManager"/> to use for sending an order confirmation email
 /// </param>
 public CheckoutController(IVeilDataAccess veilDataAccess, IGuidUserIdGetter idGetter,
     IStripeService stripeService, IShippingCostService shippingCostService,
     VeilUserManager userManager)
 {
     db = veilDataAccess;
     this.idGetter = idGetter;
     this.stripeService = stripeService;
     this.shippingCostService = shippingCostService;
     this.userManager = userManager;
 }
예제 #5
0
 /// <summary>
 ///     Instantiates a new instance of ManageController with the provided arguments
 /// </summary>
 /// <param name="userManager">
 ///     The <see cref="VeilUserManager"/> for the controller to use
 /// </param>
 /// <param name="signInManager">
 ///     The <see cref="VeilSignInManager"/> for the controller to use
 /// </param>
 /// <param name="veilDataAccess">
 ///     The <see cref="IVeilDataAccess"/> to use for database access
 /// </param>
 /// <param name="idGetter">
 ///     The <see cref="IGuidUserIdGetter"/> to use for getting the current user's Id
 /// </param>
 /// <param name="stripeService">
 ///     The <see cref="IStripeService"/> to use for Stripe interaction
 /// </param>
 public ManageController(
     VeilUserManager userManager, VeilSignInManager signInManager, IVeilDataAccess veilDataAccess,
     IGuidUserIdGetter idGetter, IStripeService stripeService)
 {
     this.userManager = userManager;
     this.signInManager = signInManager;
     db = veilDataAccess;
     this.idGetter = idGetter;
     this.stripeService = stripeService;
 }
예제 #6
0
 /// <summary>
 ///     Instantiates a new instance of CompaniesController with the provided arguments
 /// </summary>
 /// <param name="veilDataAccess">
 ///     The <see cref="IVeilDataAccess"/> to use for database access
 /// </param>
 public CompaniesController(IVeilDataAccess veilDataAccess)
 {
     db = veilDataAccess;
 }
예제 #7
0
 /// <summary>
 ///     Instantiates a new instance of GamesController with the provided argument
 /// </summary>
 /// <param name="veilDataAccess">
 ///     The <see cref="IVeilDataAccess"/> to use for database access
 /// </param>
 /// <param name="idGetter">
 ///     The <see cref="IGuidUserIdGetter"/> to use for getting the current user's Id
 /// </param>
 public GamesController(IVeilDataAccess veilDataAccess, IGuidUserIdGetter idGetter)
 {
     db = veilDataAccess;
     this.idGetter = idGetter;
 }
예제 #8
0
 /// <summary>
 ///     Instantiates a new instance of HomeController with the provided arguments
 /// </summary>
 /// <param name="veilDataAccess">
 ///     The <see cref="IVeilDataAccess"/> to use for database access
 /// </param>
 public HomeController(IVeilDataAccess veilDataAccess)
 {
     db = veilDataAccess;
 }
예제 #9
0
 /// <summary>
 ///     Instantiates a new instance of TagsController with the provided arguments
 /// </summary>
 /// <param name="veilDataAccess">
 ///     The <see cref="IVeilDataAccess"/> to use for database access
 /// </param>
 public TagsController(IVeilDataAccess veilDataAccess)
 {
     db = veilDataAccess;
 }
 /// <summary>
 ///     Instantiates a new instance of ESRBDescriptionController with the provided arguments
 /// </summary>
 /// <param name="veilDataAccess">
 ///     The <see cref="IVeilDataAccess"/> to use for database access
 /// </param>
 public ESRBDescriptionController(IVeilDataAccess veilDataAccess)
 {
     db = veilDataAccess;
 }
        protected CheckoutController CreateCheckoutController(
            IVeilDataAccess veilDataAccess = null, IGuidUserIdGetter idGetter = null,
            IStripeService stripeService = null, IShippingCostService shippingCostService = null,
            VeilUserManager userManager = null, ControllerContext context = null)
        {

            idGetter = idGetter ?? TestHelpers.GetSetupIUserIdGetterFake(memberId).Object;
            context = context ?? TestHelpers.GetSetupControllerContextFakeWithUserIdentitySetup().Object;

            var controller = new CheckoutController(
                veilDataAccess, idGetter, stripeService, shippingCostService, userManager)
            {
                ControllerContext = context
            };

            return controller;
        }
예제 #12
0
 /// <summary>
 ///     Instantiates a new instance of ReportsController with the provided arguments
 /// </summary>
 /// <param name="veilDataAccess">
 ///     The <see cref="IVeilDataAccess"/> to use for database access
 /// </param>
 public ReportsController(IVeilDataAccess veilDataAccess)
 {
     db = veilDataAccess;
 }
예제 #13
0
 /// <summary>
 ///     Instantiates a new instance of PlatformsController with the provided arguments
 /// </summary>
 /// <param name="veilDataAccess">
 ///     The <see cref="IVeilDataAccess"/> to use for database access
 /// </param>
 public PlatformsController(IVeilDataAccess veilDataAccess)
 {
     db = veilDataAccess;
 }
예제 #14
0
 /// <summary>
 ///     Instantiates a new instance of FriendListController with the provided arguments
 /// </summary>
 /// <param name="veilDataAccess">
 ///     The <see cref="IVeilDataAccess"/> to use for database access
 /// </param>
 /// <param name="idGetter">
 ///     The <see cref="IGuidUserIdGetter"/> to use for getting the current user's Id
 /// </param>
 public FriendListController(IVeilDataAccess veilDataAccess, IGuidUserIdGetter idGetter)
 {
     db = veilDataAccess;
     this.idGetter = idGetter;
 }
예제 #15
0
 /// <summary>
 ///     Sets up the Countries properties of the <see cref="AddressViewModel"/>
 /// </summary>
 /// <param name="db">
 ///     The <see cref="IVeilDataAccess"/> to fetch info from
 /// </param>
 /// <returns>
 ///     A task to await
 /// </returns>
 public async Task SetupCountries(IVeilDataAccess db)
 {
     Countries = await db.Countries.Include(c => c.Provinces).ToListAsync();
 }
예제 #16
0
        /// <summary>
        ///     Sets up the Addresses and Countries properties of the <see cref="AddressViewModel"/>
        /// </summary>
        /// <param name="db">
        ///     The <see cref="IVeilDataAccess"/> to fetch info from
        /// </param>
        /// <param name="memberId">
        ///     The Id of the Member to fetch info about
        /// </param>
        /// <returns>
        ///     A task to await
        /// </returns>
        public async Task SetupAddressesAndCountries(IVeilDataAccess db, Guid memberId)
        {
            var memberAddresses = await db.MemberAddresses.
                Where(ma => ma.MemberId == memberId).
                Select(
                    ma =>
                        new
                        {
                            ma.Id,
                            StreetAddress = ma.Address.StreetAddress + " (" + ma.Address.PostalCode + ")"
                        }).
                ToListAsync();
            
            await SetupCountries(db);

            Addresses = new SelectList(
                memberAddresses, nameof(MemberAddress.Id), nameof(Address.StreetAddress));
        }