public void completedTask(int taskId) { using (var context = new TasksRepositoryDataContext(_connectionString)) { context.ExecuteCommand("UPDATE Tasks SET Completed = 1 WHERE Id = {0}", taskId); } }
public void UpdateTask(int taskId, int userId) { using (var context = new TasksRepositoryDataContext(_connectionString)) { context.ExecuteCommand("UPDATE Tasks SET IsHandled = {0} WHERE Id = {1}", userId, taskId); } }
public User GetByEmail(string email) { using (var context = new TasksRepositoryDataContext(_connectionString)) { return(context.Users.First(u => u.Email == email)); } }
public Task GetTaskById(int taskId) { using (var context = new TasksRepositoryDataContext(_connectionString)) { var loadOptions = new DataLoadOptions(); loadOptions.LoadWith <Task>(t => t.User); context.LoadOptions = loadOptions; return(context.Tasks.First(t => t.Id == taskId)); } }
public IEnumerable <Task> AllTasks() { using (var context = new TasksRepositoryDataContext(_connectionString)) { var loadOptions = new DataLoadOptions(); loadOptions.LoadWith <Task>(t => t.User); context.LoadOptions = loadOptions; return(context.Tasks.Where(t => !t.Completed).ToList()); } }
public void AddTask(string title) { using (var context = new TasksRepositoryDataContext(_connectionString)) { Task task = new Task { Title = title, Completed = false }; context.Tasks.InsertOnSubmit(task); context.SubmitChanges(); } }
public void AddUser(User user, string password) { var salt = PasswordHelper.GenerateSalt(); var hash = PasswordHelper.HashPassword(password, salt); user.PasswordHash = hash; user.PasswordSalt = salt; using (var context = new TasksRepositoryDataContext(_connectionString)) { context.Users.InsertOnSubmit(user); context.SubmitChanges(); } }