public void Handle(CopyActivity command) { if (command == null) { throw new ArgumentNullException("command"); } var createActivity = new CreateActivity(command.Principal) { Mode = command.Mode, NoCommit = true, }; _createActivity.Handle(createActivity); command.CreatedActivity = createActivity.CreatedActivity; var originalActivity = _entities.Get <Activity>().ById(command.ActivityId, false); command.CreatedActivity.Original = originalActivity; originalActivity.WorkCopy = command.CreatedActivity; if (!command.NoCommit) { _entities.SaveChanges(); } }
public void Handle(CreateActivityAndValues command) { if (command == null) { throw new ArgumentNullException("command"); } // create activity entity var createActivity = new CreateActivity(command.Principal) { Mode = ActivityMode.Draft, NoCommit = true, }; _createActivity.Handle(createActivity); // create values entity var createValues = new CreateActivityValues(command.Principal) { NoCommit = true, Activity = createActivity.CreatedActivity, Mode = createActivity.CreatedActivity.Mode, }; _createValues.Handle(createValues); // pass back created activity command.CreatedActivity = createActivity.CreatedActivity; _unitOfWork.SaveChanges(); }