public override void Execute() { logger.DebugFormat("Executing Add Task command with Name: {0}, Description: {1}, DueDate: {2}", taskName, taskDescription, taskDueDate); if (IsValid()) { using (var scope = new TransactionScope()) { var inserted = tasksDAO.Add( new Task( taskName: taskName, taskDecription: taskDescription, dueDate: taskDueDate ) ); TaskId = inserted.Id; scope.Complete(); logger.DebugFormat("Finished executing Add Task, added task with ID: {0} ", TaskId); } } else { logger.ErrorFormat("Aborted executing Add Task, command was not valid"); throw new ArgumentException("The commmand was not valid"); } }
public override AddTaskCommand Handle(AddTaskCommand addTaskCommand) { tasksDAO.Add( new Task( taskName: addTaskCommand.TaskName, taskDecription: addTaskCommand.TaskDecription, dueDate: addTaskCommand.TaskDueDate ) ); return(addTaskCommand); }
public void Establish() { _taskToBeCompleted = new Task("My Task", "My Task Description", DateTime.Now); _tasksDAO = new Tasks.Adapters.DataAccess.TasksDAO(); _tasksDAO.Clear(); _taskToBeCompleted = _tasksDAO.Add(_taskToBeCompleted); _cmd = new CompleteTaskCommand(_taskToBeCompleted.Id, s_COMPLETION_DATE); s_commandProcessor = A.Fake <IAmACommandProcessor>(); _handler = new CompleteTaskCommandHandler(_tasksDAO, s_commandProcessor); }
public void Establish() { _taskToBeEdited = new Task("My Task", "My Task Description", DateTime.Now); _tasksDAO = new Tasks.Adapters.DataAccess.TasksDAO(); _tasksDAO.Clear(); _taskToBeEdited = _tasksDAO.Add(_taskToBeEdited); _cmd = new EditTaskCommand(_taskToBeEdited.Id, NEW_TASK_NAME, NEW_TASK_DESCRIPTION, _NEW_TIME); s_commandProcessor = A.Fake <IAmACommandProcessor>(); _handler = new EditTaskCommandHandler(_tasksDAO, s_commandProcessor); }
public override AddTaskCommand Handle(AddTaskCommand addTaskCommand) { var inserted = tasksDAO.Add( new Task( taskName: addTaskCommand.TaskName, taskDecription: addTaskCommand.TaskDecription, dueDate: addTaskCommand.TaskDueDate ) ); addTaskCommand.TaskId = inserted.Id; return(addTaskCommand); }
public override AddTaskCommand Handle(AddTaskCommand addTaskCommand) { var inserted = _tasksDAO.Add( new Task( taskName: addTaskCommand.TaskName, taskDecription: addTaskCommand.TaskDescription, dueDate: addTaskCommand.TaskDueDate ) ); addTaskCommand.TaskId = inserted.Id; _commandProcessor.Post(new TaskAddedEvent(addTaskCommand.Id, addTaskCommand.TaskId, addTaskCommand.TaskName, addTaskCommand.TaskDescription, addTaskCommand.TaskDueDate)); return(base.Handle(addTaskCommand)); }
public override AddTaskCommand Handle(AddTaskCommand addTaskCommand) { using (var scope = _tasksDAO.BeginTransaction()) { var inserted = _tasksDAO.Add( new Task( taskName: addTaskCommand.TaskName, taskDecription: addTaskCommand.TaskDescription, dueDate: addTaskCommand.TaskDueDate ) ); scope.Commit(); addTaskCommand.TaskId = inserted.Id; } return(addTaskCommand); }
public override AddTaskCommand Handle(AddTaskCommand addTaskCommand) { using (var scope = _tasksDAO.BeginTransaction()) { var inserted = _tasksDAO.Add( new Task( taskName: addTaskCommand.TaskName, taskDecription: addTaskCommand.TaskDescription, dueDate: addTaskCommand.TaskDueDate ) ); scope.Commit(); addTaskCommand.TaskId = inserted.Id; } _commandProcessor.Post(new TaskAddedEvent(addTaskCommand.Id, addTaskCommand.TaskId, addTaskCommand.TaskName, addTaskCommand.TaskDescription, addTaskCommand.TaskDueDate)); return(base.Handle(addTaskCommand)); }