コード例 #1
0
 public IEnumerable <ApplicationUser> GetApplicationUsers()
 {
     using (var context = new AcmeDbContext())
     {
         return(context.ApplicationUsers.ToList());
     }
 }
コード例 #2
0
 public IEnumerable <Employee> GetEmployees()
 {
     using (var context = new AcmeDbContext())
     {
         return(context.Employees.Include(e => e.EnteredByUser).ToList());
     }
 }
コード例 #3
0
        public void Add(Employee employee)
        {
            using (var context = new AcmeDbContext())
            {
                context.Employees.Add(employee);

                context.SaveChanges();
            }
        }
コード例 #4
0
        public void Add(ApplicationUser applicationUser)
        {
            using (var context = new AcmeDbContext())
            {
                context.ApplicationUsers.Add(applicationUser);

                context.SaveChanges();
            }
        }
コード例 #5
0
ファイル: UnitTest1.cs プロジェクト: soer33b0/UmbracoOpg
        private AcmeDbContext GetDatabaseContext()
        {
            var options = new DbContextOptionsBuilder<AcmeDbContext>()
                .UseInMemoryDatabase(databaseName: "UnitTestDB")
                .Options;
            var _db = new AcmeDbContext(options);
            _db.Database.EnsureCreated();

            return _db;
        }
コード例 #6
0
        public ApplicationUser GetApplicationUser(string username, string password)
        {
            using (var context = new AcmeDbContext())
            {
                var query = $"Select Id, Username, Password From ApplicationUsers Where Username = '******' And Password = '******'";

                var user = context.Database.SqlQuery <ApplicationUser>(query).FirstOrDefault();

                return(user);
            }
        }
コード例 #7
0
 private void Dispose(bool disposing, AcmeDbContext dbCtx)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             dbCtx.Dispose();
         }
     }
     this.disposed = true;
 }
コード例 #8
0
        public IEnumerable <Employee> GetEmployees(string searchText)
        {
            using (var context = new AcmeDbContext())
            {
                var results = context.Employees
                              .Where(e => e.Firstname.Contains(searchText) || e.Surname.Contains(searchText) || e.WorkEmail.Contains(searchText) || e.PersonalEmail.Contains(searchText))
                              .ToList();

                foreach (var user in results)
                {
                    user.EnteredByUser = context.ApplicationUsers.FirstOrDefault(u => u.Id == user.EnteredByUserId);
                }

                return(results);
            }
        }
コード例 #9
0
 public UserRepository(AcmeDbContext acmeDbContext)
 {
     _dbCtx = acmeDbContext;
 }
コード例 #10
0
 public void Dispose(AcmeDbContext dbCtx)
 {
     Dispose(true, dbCtx);
     GC.SuppressFinalize(this);
 }
コード例 #11
0
 public AcmeUnitOfWork(AcmeDbContext dbContext)
 {
     _dbContext = dbContext;
 }
コード例 #12
0
 public ActivityController(AcmeDbContext acmeDbContext)
 {
     _acmeDbContext = acmeDbContext;
 }
コード例 #13
0
 public RegistrateController(UserManager <AuthenticationUser> userManager, IMapper mapper, AcmeDbContext acmeDbContext)
 {
     _userManager   = userManager;
     _mapper        = mapper;
     _acmeDbContext = acmeDbContext;
 }
コード例 #14
0
 /// <summary>
 /// Ctor
 /// </summary>
 /// <param name="context">Object context</param>
 public EfRepository(AcmeDbContext context)
 {
     this._context = context;
 }
コード例 #15
0
 public SubmissionController(AcmeDbContext context, SubmissionRepo sr)
 {
     _context = context;
     _subRepo = sr;
 }
コード例 #16
0
 public SignupRepository(AcmeDbContext acmeDbContext)
 {
     _dbCtx = acmeDbContext;
 }
コード例 #17
0
 public SubmissionRepo(AcmeDbContext db)
 {
     _db = db;
 }
コード例 #18
0
 public UserController(AcmeDbContext acmeDbContext, IMapper mapper)
 {
     this.acmeDbContext = acmeDbContext;
     this.mapper        = mapper;
 }
コード例 #19
0
 public ActivityController(AcmeDbContext acmeDbContext, IMapper mapper)
 {
     this.acmeDbContext = acmeDbContext;
     this.mapper        = mapper;
 }
コード例 #20
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new AcmeDbContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <AcmeDbContext> >()))
            {
                if (context.Submission.Any())
                {
                    return;   // DB has been seeded
                }

                for (int i = 0; i < 2; i++)
                {
                    context.Submission.AddRange(
                        new Submission
                    {
                        FullName  = "Rasmus Paludan",
                        Email     = "*****@*****.**",
                        Age       = 47,
                        SerialNum = 95676611
                    },
                        new Submission
                    {
                        FullName  = "Kaj Boyesen",
                        Email     = "*****@*****.**",
                        Age       = 45,
                        SerialNum = 32427143
                    },
                        new Submission
                    {
                        FullName  = "Søren Malling",
                        Email     = "*****@*****.**",
                        Age       = 55,
                        SerialNum = 59395710
                    },
                        new Submission
                    {
                        FullName  = "Gordon Ramsey",
                        Email     = "*****@*****.**",
                        Age       = 50,
                        SerialNum = 74457705
                    },
                        new Submission
                    {
                        FullName  = "Morgan Freeman",
                        Email     = "*****@*****.**",
                        Age       = 100,
                        SerialNum = 67800879
                    },
                        new Submission
                    {
                        FullName  = "Kanye West",
                        Email     = "*****@*****.**",
                        Age       = 48,
                        SerialNum = 65996900
                    },
                        new Submission
                    {
                        FullName  = "Egon Olsen",
                        Email     = "*****@*****.**",
                        Age       = 90,
                        SerialNum = 35581572
                    },
                        new Submission
                    {
                        FullName  = "Casper Christensen",
                        Email     = "*****@*****.**",
                        Age       = 52,
                        SerialNum = 88059526
                    },
                        new Submission
                    {
                        FullName  = "Ole Thestrup",
                        Email     = "*****@*****.**",
                        Age       = 80,
                        SerialNum = 93172768
                    },
                        new Submission
                    {
                        FullName  = "Kim Larsen",
                        Email     = "*****@*****.**",
                        Age       = 63,
                        SerialNum = 46632564
                    },
                        new Submission
                    {
                        FullName  = "Margrethe II",
                        Email     = "majestæ[email protected]",
                        Age       = 80,
                        SerialNum = 38875640
                    },
                        new Submission
                    {
                        FullName  = "Mads Mikkelsen",
                        Email     = "*****@*****.**",
                        Age       = 54,
                        SerialNum = 82514261
                    },
                        new Submission
                    {
                        FullName  = "Nikolaj-Lie Kaas",
                        Email     = "*****@*****.**",
                        Age       = 46,
                        SerialNum = 58079554
                    }
                        );
                    context.SaveChanges();
                }
            }
        }
コード例 #21
0
 public ProductsController(AcmeDbContext ctx)
 {
     _ctx = ctx;
 }