public IEnumerable <ApplicationUser> GetApplicationUsers() { using (var context = new AcmeDbContext()) { return(context.ApplicationUsers.ToList()); } }
public IEnumerable <Employee> GetEmployees() { using (var context = new AcmeDbContext()) { return(context.Employees.Include(e => e.EnteredByUser).ToList()); } }
public void Add(Employee employee) { using (var context = new AcmeDbContext()) { context.Employees.Add(employee); context.SaveChanges(); } }
public void Add(ApplicationUser applicationUser) { using (var context = new AcmeDbContext()) { context.ApplicationUsers.Add(applicationUser); context.SaveChanges(); } }
private AcmeDbContext GetDatabaseContext() { var options = new DbContextOptionsBuilder<AcmeDbContext>() .UseInMemoryDatabase(databaseName: "UnitTestDB") .Options; var _db = new AcmeDbContext(options); _db.Database.EnsureCreated(); return _db; }
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); } }
private void Dispose(bool disposing, AcmeDbContext dbCtx) { if (!this.disposed) { if (disposing) { dbCtx.Dispose(); } } this.disposed = true; }
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); } }
public UserRepository(AcmeDbContext acmeDbContext) { _dbCtx = acmeDbContext; }
public void Dispose(AcmeDbContext dbCtx) { Dispose(true, dbCtx); GC.SuppressFinalize(this); }
public AcmeUnitOfWork(AcmeDbContext dbContext) { _dbContext = dbContext; }
public ActivityController(AcmeDbContext acmeDbContext) { _acmeDbContext = acmeDbContext; }
public RegistrateController(UserManager <AuthenticationUser> userManager, IMapper mapper, AcmeDbContext acmeDbContext) { _userManager = userManager; _mapper = mapper; _acmeDbContext = acmeDbContext; }
/// <summary> /// Ctor /// </summary> /// <param name="context">Object context</param> public EfRepository(AcmeDbContext context) { this._context = context; }
public SubmissionController(AcmeDbContext context, SubmissionRepo sr) { _context = context; _subRepo = sr; }
public SignupRepository(AcmeDbContext acmeDbContext) { _dbCtx = acmeDbContext; }
public SubmissionRepo(AcmeDbContext db) { _db = db; }
public UserController(AcmeDbContext acmeDbContext, IMapper mapper) { this.acmeDbContext = acmeDbContext; this.mapper = mapper; }
public ActivityController(AcmeDbContext acmeDbContext, IMapper mapper) { this.acmeDbContext = acmeDbContext; this.mapper = mapper; }
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(); } } }
public ProductsController(AcmeDbContext ctx) { _ctx = ctx; }