package Ġde . d hb w . ka . controllers Ċ Ċ import Ġde . d hb w . ka . domain . entities . Instrument Ċ import Ġde . d hb w . ka . domain . repository . Instrument Repository Ċ import Ġde . d hb w . ka . dto . Instrument DTO Ċ import Ġde . d hb w . ka . dto . Instrument DTO . Instrument Mapper . to Instrument Ċ import Ġde . d hb w . ka . dto . Instrument DTO . Instrument Mapper . to Instrument DTO Ċ import Ġde . d hb w . ka . instrument s . Create Instrument Ċ import Ġde . d hb w . ka . instrument s . GetAll Instrument s Ċ import Ġde . d hb w . ka . repository . Instrument Repository Impl Ċ import Ġde . d hb w . ka . storage . h 2 . H 2 Instrument Storage Ċ import Ġio . ktor . application .* Ċ import Ġio . ktor . http .* Ċ import Ġio . ktor . request .* Ċ import Ġio . ktor . response .* Ċ import Ġio . ktor . routing .* Ċ Ċ internal Ġobject ĠInstrument Properties Ġ{ ĊĠĠĠ Ġval Ġinstrument Repository : ĠInstrument Repository Ġ= ĠInstrument Repository Impl ( instrument Storage Ġ= ĠH 2 Instrument Storage ()) Ċ } Ċ Ċ fun ĠRoute . get Instrument s () Ġ{ ĊĠĠĠ Ġget ("/ instrument s ") Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠgetAll Instrument s UC Ġ= ĠGetAll Instrument s ( instrument Repository Ġ= ĠInstrument Properties . instrument Repository ) ĊĠĠĠĠĠĠĠ Ġval Ġinstrument s : ĠList < Instrument > Ġ= ĠgetAll Instrument s UC . execute () ĊĠĠĠĠĠĠĠ Ġval Ġinstrument s Result List Ġ= Ġmutable ListOf < Instrument DTO >() ĊĠĠĠĠĠĠĠ Ġinstrument s . map Ġ{ Ġinstrument s Result List . add ( to Instrument DTO ( it )) Ġ} ĊĠĠĠĠĠĠĠ Ġcall . respond ( instrument s Result List ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ fun ĠRoute . add Instrument () Ġ{ ĊĠĠĠ Ġpost ("/ instrument s ") Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġreceived Instrument Params Ġ= Ġcall . receive < Instrument DTO >() ĊĠĠĠĠĠĠĠ Ġval Ġcreate New Instrument UC Ġ= ĠCreate Instrument ( instrument Repository Ġ= ĠInstrument Properties . instrument Repository ) ĊĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcreate New Instrument UC . execute ( to Instrument ( received Instrument Params )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcall . respond Text ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Successfully Ġcreated Ġthe Ġinstrument Ġwith Ġthe Ġid Ġ${ received Instrument Params }! Ġ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġstatus Ġ= ĠHttpStatusCode . Created ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( e : ĠException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcall . respond Text (" Unfortunately Ġsomething Ġwent Ġwrong , Ġ${ e . message }") ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġ} Ċ } Ċ Ċ fun ĠApplication . register Instrument Controller () Ġ{ ĊĠĠĠ Ġrouting Ġ{ ĊĠĠĠĠĠĠĠ Ġget Instrument s () ĊĠĠĠĠĠĠĠ Ġadd Instrument () ĊĠĠĠ Ġ} Ċ } ĊĊ