Exemplo n.º 1
0
 public Widget GetWidget(Guid id)
 {
     using (var db = new AppDbContext())
     {
         return db.Widgets.First(u => u.Id == (Guid)id);
     }
 }
Exemplo n.º 2
0
 public IList<Widget> GetWidgets()
 {
     using (var db = new AppDbContext())
     {
         return db.Widgets.AsNoTracking().OrderBy(u => u.Name).ToList();
     }
 }
Exemplo n.º 3
0
 public IList<Widget> GetWidgets(string searchString)
 {
     using (var db = new AppDbContext())
     {
         return db.Widgets.AsNoTracking().Where(u => u.Name.ToLower().Contains(searchString.ToLower())).OrderBy(u => u.Name).ToList();
     }
 }
Exemplo n.º 4
0
 public IList<User> GetUsers(string searchString)
 {
     using (var db = new AppDbContext())
     {
         return db.Users.AsNoTracking().Where(u => u.Nickname.ToLower().Contains(searchString.ToLower())).OrderBy(u => u.Nickname).ToList();
     }
 }
Exemplo n.º 5
0
 public User GetUser(Guid id)
 {
     using (var db = new AppDbContext())
     {
         return db.Users.FirstOrDefault(u => u.Id == id);
     }
 }
Exemplo n.º 6
0
 public IList<User> GetUsers()
 {
     using (var db = new AppDbContext())
     {
         return db.Users.AsNoTracking().OrderBy(u=>u.Nickname).ToList();
     }
 }
Exemplo n.º 7
0
 public async Task SaveWidget(Widget widget)
 {
     using (var db = new AppDbContext())
     {
         db.Widgets.Add(widget);
         await db.SaveChangesAsync();
     }
 }
Exemplo n.º 8
0
 public async Task SaveUser(User user)
 {
     using (var db = new AppDbContext())
     {
         db.Users.Add(user);
         await db.SaveChangesAsync();
     }
 }
Exemplo n.º 9
0
 public async Task DeleteWidget(Guid id)
 {
     using (var db = new AppDbContext())
     {
         var widget = GetWidget(id);
         db.Widgets.Attach(widget);
         db.Widgets.Remove(widget);
         await db.SaveChangesAsync();
     }
 }
Exemplo n.º 10
0
 public async Task DeleteUser(Guid id)
 {
     using (var db = new AppDbContext())
     {
         var user = GetUser(id);
         db.Users.Attach(user);
         db.Users.Remove(user);
         await db.SaveChangesAsync();
     }
 }