public override void Execute() { logger.DebugFormat("Executing Edit Task command with Name: {0}, Description: {1}, DueDate: {2}", taskName, taskDescription, taskDueDate); if (IsValid()) { using (var scope = new TransactionScope()) { Task task = tasksDAO.FindById(taskId); task.TaskName = taskName; task.TaskDescription = taskDescription; task.DueDate = taskDueDate; tasksDAO.Update(task); scope.Complete(); logger.DebugFormat("Finished executing Add Task, edited task with ID: {0} ", taskId); } } else { logger.ErrorFormat("Aborted executing Edited Task, command was not valid"); throw new ArgumentException("The commmand was not valid"); } }
public override EditTaskCommand Handle(EditTaskCommand editTaskCommand) { Task task = tasksDAO.FindById(editTaskCommand.TaskId); task.TaskName = editTaskCommand.TaskName; task.TaskDescription = editTaskCommand.TaskDescription; task.DueDate = editTaskCommand.TaskDueDate; tasksDAO.Update(task); return(editTaskCommand); }
public override EditTaskCommand Handle(EditTaskCommand editTaskCommand) { var task = _tasksDAO.FindById(editTaskCommand.TaskId); task.TaskName = editTaskCommand.TaskName; task.TaskDescription = editTaskCommand.TaskDescription; task.DueDate = editTaskCommand.TaskDueDate; _tasksDAO.Update(task); _commandProcessor.Post(new TaskEditedEvent(editTaskCommand.Id, editTaskCommand.TaskId, editTaskCommand.TaskName, editTaskCommand.TaskDescription, editTaskCommand.TaskDueDate)); return(base.Handle(editTaskCommand)); }
public override CompleteTaskCommand Handle(CompleteTaskCommand completeTaskCommand) { Task task = tasksDAO.FindById(completeTaskCommand.TaskId); if (task != null) { task.CompletionDate = completeTaskCommand.CompletionDate; tasksDAO.Update(task); } else { throw new ArgumentOutOfRangeException("completeTaskCommand", completeTaskCommand, "Could not find the task to complete"); } return(completeTaskCommand); }
public override EditTaskCommand Handle(EditTaskCommand editTaskCommand) { using (var scope = _tasksDAO.BeginTransaction()) { Task task = _tasksDAO.FindById(editTaskCommand.TaskId); task.TaskName = editTaskCommand.TaskName; task.TaskDescription = editTaskCommand.TaskDescription; task.DueDate = editTaskCommand.TaskDueDate; _tasksDAO.Update(task); scope.Commit(); } return(editTaskCommand); }
public override void Execute() { using (var scope = new TransactionScope()) { Task task = tasksDAO.FindById(taskId); if (task != null) { task.CompletionDate = completionDate; tasksDAO.Update(task); scope.Complete(); } else { throw new ArgumentOutOfRangeException("Could not find the task to complete"); } } }
public override CompleteTaskCommand Handle(CompleteTaskCommand completeTaskCommand) { using (var scope = _tasksDAO.BeginTransaction()) { Task task = _tasksDAO.FindById(completeTaskCommand.TaskId); if (task != null) { task.CompletionDate = completeTaskCommand.CompletionDate; _tasksDAO.Update(task); scope.Commit(); } else { throw new ArgumentOutOfRangeException("completeTaskCommand", completeTaskCommand, "Could not find the task to complete"); } } return(completeTaskCommand); }
public override CompleteTaskCommand Handle(CompleteTaskCommand completeTaskCommand) { var task = _tasksDAO.FindById(completeTaskCommand.TaskId); if (task != null) { task.CompletionDate = completeTaskCommand.CompletionDate; _tasksDAO.Update(task); } else { throw new ArgumentOutOfRangeException(nameof(completeTaskCommand), completeTaskCommand, "Could not find the task to complete"); } _commandProcessor.Post(new TaskCompletedEvent(completeTaskCommand.Id, completeTaskCommand.TaskId, completeTaskCommand.CompletionDate)); return(base.Handle(completeTaskCommand)); }
public override EditTaskCommand Handle(EditTaskCommand editTaskCommand) { using (var scope = _tasksDAO.BeginTransaction()) { Task task = _tasksDAO.FindById(editTaskCommand.TaskId); task.TaskName = editTaskCommand.TaskName; task.TaskDescription = editTaskCommand.TaskDescription; task.DueDate = editTaskCommand.TaskDueDate; _tasksDAO.Update(task); scope.Commit(); } _commandProcessor.Post(new TaskEditedEvent(editTaskCommand.Id, editTaskCommand.TaskId, editTaskCommand.TaskName, editTaskCommand.TaskDescription, editTaskCommand.TaskDueDate)); return(base.Handle(editTaskCommand)); }