Skip to content

Commit

Permalink
Update app to make binding functions more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
hmcalister committed Sep 10, 2023
1 parent 2c97edd commit d52327d
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"fmt"
"hmcalister/EventTrackerApp/backend/database"
"hmcalister/EventTrackerApp/backend/models"
"log"
Expand Down Expand Up @@ -50,5 +51,31 @@ func (a *App) initAllEventsFromDatabase() ([]*models.Event, map[uint]*models.Eve
}

func (a *App) GetAllEvents() []*models.Event {
return a.allEventsList
var allEvents []*models.Event
a.databaseConnection.Find(&allEvents)
return allEvents
}

func (a *App) CreateEvent(newEvent *models.Event) *models.Event {
models.RegisterNewEventInDatabase(newEvent, a.databaseConnection)
return newEvent
}

func (a *App) UpdateEvent(updatedEvent *models.Event) *models.Event {
updatedEvent.UpdateEventInDatabase(a.databaseConnection)
return updatedEvent
}

func (a *App) DismissEvent(event *models.Event) *models.Event {
dismissedEvent := event.DismissEvent(a.databaseConnection)
return dismissedEvent
}

func (a *App) DeleteEvent(event *models.Event) *models.Event {
event.IsRecurring = false
return a.DismissEvent(event)
}

func (a *App) PrintEventStruct(event *models.Event) {
fmt.Printf("%+v\n", event)
}

0 comments on commit d52327d

Please sign in to comment.