public void AddTask(UserTask task) { using (var context = new UserTaskContext(connectionString)) { context.Tasks.Add(task); context.SaveChanges(); } }
public void MarkComplete(int taskId) { using (var context = new UserTaskContext(connectionString)) { var task = context.Tasks.FirstOrDefault(t => t.Id == taskId); task.Completed = true; context.SaveChanges(); } }
public void AddUser(User user, string password) { user.PasswordHash = BCrypt.Net.BCrypt.HashPassword(password); using (var context = new UserTaskContext(connectionString)) { context.Users.Add(user); context.SaveChanges(); } }
public void ChangeStatus(int TaskId, TaskStatus status, User user) { var task = GetTaskById(TaskId); task.Status = status; task.TakenUserId = user.Id; using (var context = new UserTaskContext(_connectionString)) { context.UserTasks.Attach(task); context.Entry(task).State = EntityState.Modified; context.SaveChanges(); } }
public void AddTask(string task) { UserTask userTask = new UserTask { Task = task, Status = TaskStatus.NotTaken, Id = 0 }; using (var context = new UserTaskContext(_connectionString)) { context.UserTasks.Add(userTask); context.SaveChanges(); } }