Exemple #1
0
 public void Dispose()
 {
     using (var context = new TalkBackContext())
     {
         context.Dispose();
     }
 }
Exemple #2
0
 public UserDb Login(string username, string password)
 {
     using (var context = new TalkBackContext())
     {
         return(context.Users.FirstOrDefault(u => u.Name == username && u.Password == password));
     }
 }
Exemple #3
0
 public UserDb get(int id)
 {
     using (var context = new TalkBackContext())
     {
         return(context.Users.FirstOrDefault(u => u.Id == id));
     }
 }
Exemple #4
0
 public bool IsUserExist(string username)
 {
     using (var context = new TalkBackContext())
     {
         if (context.Users.FirstOrDefault(u => u.Name == username) != null)
         {
             return(true);
         }
         return(false);
     }
 }
Exemple #5
0
 public IEnumerable <string> GetAll()
 {
     using (var context = new TalkBackContext())
     {
         var users = context.Users.Select(u => u.Name);
         if (users != null)
         {
             return(users.ToList());
         }
     }
     return(null);
 }
Exemple #6
0
        //  TalkBackContext _context = new TalkBackContext();

        public UserDb Add(UserDb user)
        {
            using (var context = new TalkBackContext())
            {
                var newUser = context.Users.Add(user);

                context.SaveChanges();
                return(newUser);
            }

            //return newUser;
        }