def save(self, team_entity: TeamEntity): team_model = DataConverters.from_team_entity(team_entity) print(F"Team: {team_model.created_at}") team_model.save() team_model.refresh_from_db() new_team_entity = DataConverters.to_team_entity(team_model) print(F"New team entity: {new_team_entity.name}") return new_team_entity
def delete(self, team_pk): try: team = Team.objects.get(pk=team_pk) team.delete() team_entity = DataConverters.to_team_entity(team) return team_entity except Team.DoesNotExist: raise Team.DoesNotExist
def retrieve_all(self): team_objects = Team.objects.all() team_models = [] for team in team_objects: team_models.append(DataConverters.to_team_entity(team)) return team_models
def team_exists(self, team_pk): try: team_obj = Team.objects.get(pk=team_pk) return DataConverters.to_team_entity(team_obj) except Team.DoesNotExist: return None