public int Log(long eventID, EventCommand command) { //remove the EventCommand commandToInsert = new EventCommand { CommandName = command.GetType().ToString(), EventID = eventID, }; //take results from passed in command var result = command.EventCommandResults; context.EventCommands.Add(commandToInsert); if (context.SaveChanges() > 0) { foreach (var eventCommandResult in result) { eventCommandResult.EventCommandID = commandToInsert.EventCommandID; context.EventCommandResults.Add(eventCommandResult); } context.SaveChanges(); return 0; } return -1; }
/// <summary> /// Logs /// </summary> /// <returns></returns> public int LogEventAndCommandandCommandResult(Event anEvent, EventCommand eventCommand, EventCommandResult result) { anEvent.EventCommands = null; //can't log a command without an event if (LogEvent(anEvent).Equals(0)) { _commandLogger.Log(anEvent.EventID, eventCommand); return 0; } return -1; }