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 TaskModel Get(int taskId) { var matchingTask = _tasksDao.FindById(taskId); string dueDate = matchingTask.DueDate != null?matchingTask.DueDate.ToString() : string.Empty; return(new TaskModel(dueDate: dueDate, taskName: matchingTask.TaskName, taskDescription: matchingTask.TaskDescription)); }
public void When_completing_an_existing_task() { _handler.Handle(_cmd); _taskToBeCompleted = _tasksDAO.FindById(_cmd.TaskId); //_should_update_the_tasks_completed_date Assert.AreEqual(s_COMPLETION_DATE.Date, _taskToBeCompleted.CompletionDate.Value.Date); //_should_post_event A.CallTo(() => s_commandProcessor.Post(A <TaskCompletedEvent> ._)).MustHaveHappened(Repeated.Exactly.Once); }
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 void When_adding_a_new_task_to_the_list() { _handler.Handle(_cmd); _taskToBeAdded = _tasksDAO.FindById(_cmd.TaskId); //_should_have_the_matching_task_name Assert.AreEqual(TASK_NAME, _taskToBeAdded.TaskName); //_should_have_the_matching_task_description Assert.AreEqual(TASK_DESCRIPTION, _taskToBeAdded.TaskDescription); //_should_have_the_matching_task_name Assert.AreEqual(_now.Date, _taskToBeAdded.DueDate.Value.Date); }
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 void When_editing_an_existing_task() { _handler.Handle(_cmd); _taskToBeEdited = _tasksDAO.FindById(_cmd.TaskId); //_should_update_the_task_with_the_new_task_name Assert.AreEqual(NEW_TASK_NAME, _taskToBeEdited.TaskName); //_should_update_the_task_with_the_new_task_description Assert.AreEqual(NEW_TASK_DESCRIPTION, _taskToBeEdited.TaskDescription); //_should_update_the_task_with_the_new_task_time Assert.AreEqual(_NEW_TIME.Date, _taskToBeEdited.DueDate.Value.Date); //_should_post_event A.CallTo(() => s_commandProcessor.Post(A <TaskEditedEvent> ._)).MustHaveHappened(Repeated.Exactly.Once); }
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)); }
public TaskViewModel Get(int id) { var task = tasksDao.FindById(id); if (task == null) { return(null); } return(new TaskViewModel { Id = task.Id, Name = task.TaskName, Description = task.TaskDescription, DueDate = task.DueDate, Completed = task.CompletionDate.HasValue }); }