public static TaskModel FromRepositoryType(Task repositoryModel) { if (repositoryModel == null) { return(null); } var ownerRepositoryModel = UserModel.FromRepositoryType(repositoryModel.Owner); var scriptRepositoryModel = ScriptModel.FromRepositoryType(repositoryModel.Script); var targetRepositoryModel = ComputerModel.FromRepositoryType(repositoryModel.Target); var result = new TaskModel { Expiration = repositoryModel.Expiration, Id = repositoryModel.Id, Origin = repositoryModel.Origin, Owner_Id = ownerRepositoryModel?.Id, ReceivedTimestamp = repositoryModel.ReceivedTimestamp, Script_Id = scriptRepositoryModel?.Id, Target_Id = targetRepositoryModel?.Id, }; return(result); }