public ApiController(IUserRepository userRepo, IRepository <TramLocation> tramsRepo, DatabaseContext.DatabaseContext context) { UserRepo = userRepo; TramsRepo = tramsRepo; this.context = context; Client = new HttpClient(); Client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); }
public void DatabaseExistsTest() { using(var context = new DatabaseContext.DatabaseContext(@"TestData\testDbV1.db")) { context.WorkingTimes.Add(new BusinessData.WorkingTimeRange() { StartTime = DateTime.Now, PauseDuration = 15, EndTime = DateTime.Now.AddHours(7) }); context.SaveChanges(); var item = context.WorkingTimes.FirstOrDefault(); Assert.IsNotNull(item); } }
public void DatabseNotExists() { using(var context = new DatabaseContext.DatabaseContext(Guid.NewGuid().ToString() + ".db")) { context.WorkingTimes.Add(new BusinessData.WorkingTimeRange() { StartTime = DateTime.Now, PauseDuration = 15, EndTime = DateTime.Now.AddHours(7) }); context.SaveChanges(); var item = context.WorkingTimes.FirstOrDefault(); Assert.IsNotNull(item); } }
static void Main(string[] args) { using (DatabaseContext.DatabaseContext db = new DatabaseContext.DatabaseContext()) { UsersRepos userRepos = new UsersRepos(db); var users = db.Users; foreach (Users u in users) { Console.WriteLine($"{u.Id}.{u.Name}"); } var photos = db.Photos; foreach (Photos photo in photos) { Console.WriteLine($"Photo id: {photo.Id} by user {photo.UserId}.{userRepos.GetById(photo.UserId).Name}"); } } Console.Read(); }
public UserRepository(DatabaseContext.DatabaseContext ctx) : base(ctx) { }
public ReadRepository(DatabaseContext.DatabaseContext ctx) { context = ctx; dbSet = context.Set <T>(); }