Пример #1
0
 public List <UserTask> GetUserTasks()
 {
     using (var cxt = new UserTaskContext(_connectionString))
     {
         return(cxt.Tasks.ToList());
     }
 }
Пример #2
0
 public User GetByEmail(string email)
 {
     using (var context = new UserTaskContext(_connectionString))
     {
         return(context.Users.FirstOrDefault(u => u.Email == email));
     }
 }
Пример #3
0
 public void AddTask(UserTask task)
 {
     using (var cxt = new UserTaskContext(_connectionString))
     {
         cxt.Tasks.Add(task);
         cxt.SaveChanges();
     }
 }
Пример #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));
     }
 }
Пример #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();
     }
 }
Пример #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();
            }
        }