Exemplo n.º 1
0
 public List <UserTask> GetUserTasks()
 {
     using (var cxt = new UserTaskContext(_connectionString))
     {
         return(cxt.Tasks.ToList());
     }
 }
Exemplo n.º 2
0
 public User GetByEmail(string email)
 {
     using (var context = new UserTaskContext(_connectionString))
     {
         return(context.Users.FirstOrDefault(u => u.Email == email));
     }
 }
Exemplo n.º 3
0
 public void AddTask(UserTask task)
 {
     using (var cxt = new UserTaskContext(_connectionString))
     {
         cxt.Tasks.Add(task);
         cxt.SaveChanges();
     }
 }
Exemplo n.º 4
0
 public void DeleteTask(int userTaskId)
 {
     using (var context = new UserTaskContext(_connectionString))
     {
         context.Database.ExecuteSqlCommand(
             "DELETE FROM Tasks WHERE Id = @id",
             new SqlParameter("@id", userTaskId));
     }
 }
Exemplo n.º 5
0
 public void UpdateTask(UserTask task)
 {
     using (var context = new UserTaskContext(_connectionString))
     {
         context.Tasks.Attach(task);
         context.Entry(task).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Exemplo n.º 6
0
        public void AddUser(User user, string password)
        {
            user.PasswordHash = BCrypt.Net.BCrypt.HashPassword(password);

            using (var context = new UserTaskContext(_connectionString))
            {
                context.Users.Add(user);
                context.SaveChanges();
            }
        }