Ejemplo n.º 1
0
 public User GetByEmail(string email)
 {
     using (var context = new RealTimeTasksDataContext(_connectionString))
     {
         return(context.Users.FirstOrDefault(u => u.EmailAddress == email));
     }
 }
Ejemplo n.º 2
0
 public void SetCompleted(int taskId)
 {
     using (var context = new RealTimeTasksDataContext(_connectionString))
     {
         context.ExecuteCommand("UPDATE TaskItems SET IsCompleted = 1 WHERE Id = {0}",
                                taskId);
     }
 }
Ejemplo n.º 3
0
 public void SetDoing(int taskId, int userId)
 {
     using (var context = new RealTimeTasksDataContext(_connectionString))
     {
         context.ExecuteCommand("UPDATE TaskItems SET HandledBy = {0} WHERE Id = {1}",
                                userId, taskId);
     }
 }
Ejemplo n.º 4
0
 public void AddTask(TaskItem task)
 {
     using (var context = new RealTimeTasksDataContext(_connectionString))
     {
         context.TaskItems.InsertOnSubmit(task);
         context.SubmitChanges();
     }
 }
Ejemplo n.º 5
0
 public IEnumerable <TaskItem> GetActiveTasks()
 {
     using (var context = new RealTimeTasksDataContext(_connectionString))
     {
         var loadOptions = new DataLoadOptions();
         loadOptions.LoadWith <TaskItem>(t => t.User);
         context.LoadOptions = loadOptions;
         return(context.TaskItems.Where(t => !t.IsCompleted).ToList());
     }
 }
Ejemplo n.º 6
0
        public void AddUser(User user, string password)
        {
            string salt         = PasswordHelper.GenerateSalt();
            string passwordHash = PasswordHelper.HashPassword(password, salt);

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