@startuml
skinparam monochrome true
skinparam packageStyle rectangle
skinparam shadowing false

autonumber

'hide footbox
actor "GSM" as GSM
participant ":MarkTaskCompletedUI" as UI
participant ":MarkTaskCompletedController" as CTRL
participant ":Repositories" as RepositorySingleton
participant "repositories\n:Repositories" as PLAT
participant "agendaEntryRepository:\nAgendaEntryRepository" as Repo
participant "AgendaEntryMapper"
participant "AgendaEntryDTO"



activate GSM

                GSM -> UI : asks to mark a task as completed

                activate UI

                UI -> CTRL** : create
                activate CTRL

                 UI-> CTRL: getEntrysByCollaborato()

                CTRL -> "AgendaEntryMapper"**:  create







                CTRL -> RepositorySingleton : getInstance()
                activate RepositorySingleton

                    RepositorySingleton --> CTRL: repositories
                deactivate RepositorySingleton


                CTRL -> PLAT : getAgendaEntryRepository()
                activate PLAT

                    PLAT --> CTRL: AgendaEntryRepository()
                deactivate PLAT


                CTRL -> Repo :getEntrysByCollaborator(String currentUserEmail)
                activate Repo

                note right: check the email associated with the employee \nand see the team they are included in

                Repo --> CTRL: agendaEntryListCollaborator
                deactivate Repo




                CTRL -> "AgendaEntryMapper" : toDtoList(agendaEntryListCollaborator)
                activate "AgendaEntryMapper"


                 loop for each agendaEntry in agendaEntryList

                 "AgendaEntryMapper" -> "AgendaEntryDTO"** : agendaEntryDTO = toDTO(agendaEntry)

                  activate "AgendaEntryDTO"
                  end
                deactivate "AgendaEntryDTO"

                "AgendaEntryMapper" --> CTRL : agendaEntryDTOList
                deactivate "AgendaEntryMapper"

                 CTRL --> UI : agendaEntryDTOList
                 deactivate CTRL

                  UI --> GSM : shows the list of entries in the Agenda\n and asks to select one


                 GSM-> UI: selects an entry



                UI-> CTRL: completedAgendaEntry(AgendaEntryDTO dto)
                deactivate "AgendaEntryDTO"
                activate CTRL

                CTRL-> Repo: getAgendaEntryByDescriptionAndGreenSpace(description, greenSpace)
                activate Repo
                Repo-->CTRL: agendaEntry
                deactivate Repo



                CTRL-> Repo: update(entry, EntryStatus.DONE)

                activate Repo
                Repo-->CTRL: success/insuccess


              deactivate Repo

                CTRL --> UI : success/insuccess
                deactivate CTRL
               UI --> GSM : shows (in)success message
               deactivate UI


               deactivate GSM

@enduml