Exemple #1
0
 public void SetTaskCompleted(int taskId)
 {
     using (var context = new TasksDataContext(_connectionString))
     {
         context.ExecuteCommand("UPDATE Tasks SET Completed = 1 where Id = {0}", taskId);
     }
 }
Exemple #2
0
 public User GetByEmail(string email)
 {
     using (var context = new TasksDataContext(_connectionString))
     {
         return(context.Users.FirstOrDefault(u => u.Email == email));
     }
 }
Exemple #3
0
 public void SetUserForTask(int taskId, int userId)
 {
     using (var context = new TasksDataContext(_connectionString))
     {
         context.ExecuteCommand("UPDATE Tasks SET UserId = {1} where Id = {0}", taskId, userId);
     }
 }
Exemple #4
0
 public void AddTask(Task task)
 {
     using (var context = new TasksDataContext(_connectionString))
     {
         context.Tasks.InsertOnSubmit(task);
         context.SubmitChanges();
     }
 }
Exemple #5
0
 public Task GetById(int id)
 {
     using (var context = new TasksDataContext(_connectionString))
     {
         var loadOptions = new DataLoadOptions();
         loadOptions.LoadWith <Task>(t => t.User);
         context.LoadOptions = loadOptions;
         return(context.Tasks.First(i => i.Id == id));
     }
 }
Exemple #6
0
 public IEnumerable <Task> GetIncompletedTasks()
 {
     using (var context = new TasksDataContext(_connectionString))
     {
         var loadOptions = new DataLoadOptions();
         loadOptions.LoadWith <Task>(t => t.User);
         context.LoadOptions = loadOptions;
         return(context.Tasks.Where(t => !t.Completed).ToList());
     }
 }
Exemple #7
0
        public void AddUser(User user, string password)
        {
            string passwordSalt = PasswordHelper.GenerateSalt();
            string passwordHash = PasswordHelper.HashPassword(password, passwordSalt);

            user.PasswordSalt = passwordSalt;
            user.PasswordHash = passwordHash;
            using (var context = new TasksDataContext(_connectionString))
            {
                context.Users.InsertOnSubmit(user);
                context.SubmitChanges();
            }
        }