package Ġs ma . trip per . room čĊč Ċ import Ġs ma . trip per . Trip Repository č Ċ import Ġs ma . trip per . data . Event č Ċ import Ġs ma . trip per . data . Trip č Ċ import Ġs ma . trip per . entity . Event Entity č Ċ import Ġs ma . trip per . entity . Trip Entity č Ċ import Ġs ma . trip per . entity . Trip With Events Entity čĊč Ċ class ĠRoom Trip Repository ( private Ġval Ġapp Database : ĠApp Database ) Ġ: ĠTrip Repository Ġ{ čĊĠĠĠ Ġoverride Ġsuspend Ġfun ĠgetAll Tri ps (): ĠList < Trip > Ġ{ čĊĠĠĠĠĠĠĠ Ġreturn Ġapp Database . trip With Events Dao (). get Tri ps With Events (). map Ġ{ Ġit . to Model () Ġ} čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġadd Trip ( trip : ĠTrip ) Ġ{ čĊĠĠĠĠĠĠĠ Ġapp Database . trip Dao (). insert All ( listOf ( trip . to Entity ())) čĊĠĠĠĠĠĠĠ Ġapp Database . event Dao (). insert All ( trip . events . map Ġ{ Ġevent Ġ-> čĊĠĠĠĠĠĠĠĠĠĠĠ ĠEvent Entity ( event . eventId , Ġtrip . trip Id , Ġevent . name , Ġevent . address , Ġevent . thumbnail Url , Ġevent . date , Ġevent . hour , Ġevent . minute ) čĊĠĠĠĠĠĠĠ Ġ}) čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġremove Trip ( trip : ĠTrip ) Ġ{ čĊĠĠĠĠĠĠĠ Ġapp Database . trip Dao (). delete ( trip . to Entity ()) čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġprivate Ġfun ĠEvent Entity . to Model () Ġ= ĠEvent ( eventId , Ġname , Ġaddress , Ġthumbnail Url , Ġdate , Ġhour , Ġminute ) čĊĠĠĠ Ġprivate Ġfun ĠTrip . to Entity () Ġ= ĠTrip Entity ( trip Id , Ġfrom , Ġto , Ġdestination , Ġlat , Ġlng ) čĊĠĠĠ Ġprivate Ġfun ĠTrip With Events Entity . to Model () Ġ: ĠTrip Ġ{ čĊĠĠĠĠĠĠĠ Ġval Ġtrip With Events Ġ= ĠTrip ( trip . trip Id , Ġtrip . from , Ġtrip . to , Ġtrip . destination ) čĊĠĠĠĠĠĠĠ Ġtrip With Events . lat Ġ= Ġtrip . lat čĊĠĠĠĠĠĠĠ Ġtrip With Events . lng Ġ= Ġtrip . lng čĊĠĠĠĠĠĠĠ Ġtrip With Events . events Ġ= Ġevents . to Mutable List (). map Ġ{ Ġit . to Model () Ġ}. to Mutable List () čĊĠĠĠĠĠĠĠ Ġreturn Ġtrip With Events čĊĠĠĠ Ġ} čĊčĊč Ċ }