Exemplo n.º 1
0
 public void AddTask(UserTask task)
 {
     using (var context = new UserTaskContext(connectionString))
     {
         context.Tasks.Add(task);
         context.SaveChanges();
     }
 }
Exemplo n.º 2
0
 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();
     }
 }
Exemplo n.º 3
0
        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();
            }
        }
Exemplo n.º 4
0
        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();
            }
        }
Exemplo n.º 5
0
        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();
            }
        }