Ejemplo n.º 1
0
 public void SetTaskCompleted(int taskId)
 {
     using (var context = new TasksDataContext(_connectionString))
     {
         context.ExecuteCommand("UPDATE Tasks SET Completed = 1 where Id = {0}", taskId);
     }
 }
Ejemplo n.º 2
0
 public User GetByEmail(string email)
 {
     using (var context = new TasksDataContext(_connectionString))
     {
         return(context.Users.FirstOrDefault(u => u.Email == email));
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 4
0
 public void AddTask(Task task)
 {
     using (var context = new TasksDataContext(_connectionString))
     {
         context.Tasks.InsertOnSubmit(task);
         context.SubmitChanges();
     }
 }
Ejemplo n.º 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));
     }
 }
Ejemplo n.º 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());
     }
 }
Ejemplo n.º 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();
            }
        }