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