public CreditCardsController(GroupProjectContext context, ICryptoService cryptoService, ICreditCardService creditCardService, UserManager <ApplicationUser> userManager)
 {
     _context           = context;
     _cryptoService     = cryptoService;
     _creditCardService = creditCardService;
     _userManager       = userManager;
 }
        /// <summary>
        /// Adds default data to he Accounts table when no data is present
        /// </summary>
        /// <param name="serviceProvider">Used to provide custom support to objects</param>
        public static void InitializeAccounts(IServiceProvider serviceProvider)
        {
            using var context = new GroupProjectContext(
                      serviceProvider.GetRequiredService <
                          DbContextOptions <GroupProjectContext> >());

            // Checks if any Byte Jam events are in the DB
            if (context.Accounts.Any())
            {
                return; // means that the DB has been seeded
            }

            context.Accounts.AddRange(
                new Accounts
            {
                Username = "******",
                Email    = "*****@*****.**",
                Password = "******"
            },
                new Accounts
            {
                Username = "******",
                Email    = "*****@*****.**",
                Password = "******"
            }
                );
        }
        /// <summary>
        /// Adds default data to the Courses table when no data is present
        /// </summary>
        /// <param name="serviceProvider">Used to provide custom support to objects</param>
        public static void InitializeCourses(IServiceProvider serviceProvider)
        {
            using var context = new GroupProjectContext(
                      serviceProvider.GetRequiredService <
                          DbContextOptions <GroupProjectContext> >());

            // Checks if any courses are in the DB
            if (context.Courses.Any())
            {
                return; // means that the DB has been seeded
            }

            context.Courses.AddRange(
                new Courses
            {
                CourseID   = "CIS001",
                CourseName = "Intro to Logic",
                Credits    = 3,
                Online     = false
            },
                new Courses
            {
                CourseID   = "CIS002",
                CourseName = "C#",
                Credits    = 4,
                Online     = true
            },
                new Courses
            {
                CourseID   = "CIS003",
                CourseName = "COBOL II",
                Credits    = 3,
                Online     = true
            },
                new Courses
            {
                CourseID   = "CIS004",
                CourseName = "Java",
                Credits    = 4,
                Online     = false
            },
                new Courses
            {
                CourseID   = "CIS005",
                CourseName = "ASP .NET",
                Credits    = 3,
                Online     = false
            }
                );

            context.SaveChanges();
        }
Exemple #4
0
 /// <summary>
 /// Sets the data contained in a GroupProjectContext object to a new object
 /// </summary>
 /// <param name="context">Represents a GroupProjectContext object</param>
 public CatalogController(GroupProjectContext context)
 {
     _context = context;
 }
Exemple #5
0
        private static readonly Regex regex = new Regex(@"[^a-zA-Z]");  // used to double check results

        /// <summary>
        /// Sets the data contained in a GroupProjectContext object to a new object
        /// </summary>
        /// <param name="context">Represents a GroupProjectContext object</param>
        public CoursesController(GroupProjectContext context)
        {
            _context = context;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CreditCardService" /> class.
 /// </summary>
 /// <param name="cryptoService">The crypto service.</param>
 /// <param name="context">The context.</param>
 /// <param name="dataProtectionProvider">The data protection provider.</param>
 public CreditCardService(ICryptoService cryptoService, GroupProjectContext context, IDataProtectionProvider dataProtectionProvider)
 {
     this.context       = context;
     this.dataProtector = dataProtectionProvider.CreateProtector("CvcCodeProtector");
     this.cryptoService = cryptoService;
 }