예제 #1
0
 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
예제 #2
0
 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
예제 #3
0
    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
예제 #4
0
 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