public static JobStateDto ToDto(this State state) { if (state == null) { return(null); } var jobState = new JobState(state); return(new JobStateDto() { JobName = jobState.Name, LastExecutionDate = jobState.LastExecutionDate, LastExecutionDurationMs = jobState.LastExecutionTimeMs, Message = jobState.Message, Status = jobState.Status.ToDto(), Error = jobState.GetJobError().ToDto(), Progress = jobState.GetProgressDto(), Custom = jobState.GetCustomFields().ToDto() }); }