public User GetByEmail(string email) { using (var context = new TaskItemsContext(_connectionString)) { return(context.Users.FirstOrDefault(u => u.Email == email)); } }
public TaskItem GetById(int id) { using (var context = new TaskItemsContext(_connectionString)) { return(context.TaskItems.Include(t => t.User).FirstOrDefault(i => i.Id == id)); } }
public IEnumerable <TaskItem> GetActiveTasks() { using (var context = new TaskItemsContext(_connectionString)) { return(context.TaskItems.Include(t => t.User) .Where(t => !t.IsCompleted).ToList()); } }
public void AddTask(TaskItem task) { using (var context = new TaskItemsContext(_connectionString)) { context.TaskItems.Add(task); context.SaveChanges(); } }
public void SetCompleted(int taskId) { using (var context = new TaskItemsContext(_connectionString)) { context.Database.ExecuteSqlCommand( "UPDATE TaskItems SET IsCompleted = 1 WHERE Id = @taskId", new SqlParameter("@taskId", taskId)); } }
public void SetDoing(int taskId, int userId) { using (var context = new TaskItemsContext(_connectionString)) { context.Database.ExecuteSqlCommand( "UPDATE TaskItems SET HandledBy = @userId WHERE Id = @taskId", new SqlParameter("@userId", userId), new SqlParameter("@taskId", taskId)); } }
public void AddUser(User user, string password) { user.PasswordHash = PasswordHelper.HashPassword(password); using (var context = new TaskItemsContext(_connectionString)) { context.Users.Add(user); context.SaveChanges(); } }