Exemple #1
0
 public User Get(int userId)
 {
     using (var context = new UserAppContext(configuration, httpAccessor))
     {
         return(context.Users.Find(userId));
     }
 }
Exemple #2
0
 public IEnumerable <User> Get()
 {
     using (var context = new UserAppContext(configuration, httpAccessor))
     {
         return(context.Users.ToList());
     }
 }
Exemple #3
0
 public void Delete(int id)
 {
     using (var context = new UserAppContext(configuration, httpAccessor))
     {
         context.Users.Remove(context.Users.Find(id));
         context.SaveChanges();
     }
 }
Exemple #4
0
 public User Update(int id, User user)
 {
     using (var context = new UserAppContext(configuration, httpAccessor))
     {
         context.Users.Update(user);
         context.SaveChanges();
         return(user);
     }
 }
Exemple #5
0
 public User Save(User user)
 {
     using (var context = new UserAppContext(configuration, httpAccessor))
     {
         context.Users.Add(user);
         context.SaveChanges();
         return(user);
     }
 }
Exemple #6
0
 public IEnumerable <User> Get(string name, string email, string login)
 {
     using (var context = new UserAppContext(configuration, httpAccessor))
     {
         return(context.Users.Where(a => string.IsNullOrEmpty(name) || a.Name.Contains(name))
                .Where(a => string.IsNullOrEmpty(email) || a.Email.Contains(email))
                .Where(a => string.IsNullOrEmpty(login) || a.Login.Contains(login))
                .ToList());
     }
 }