package Ġcom . mand ay . management . ui . view models Ċ Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Mediator LiveData Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . Observer Ċ import Ġcom . mand ay . core data . Executor ViewModel Ċ import Ġcom . mand ay . core data . utils . add Source NotNull Ċ import Ġcom . mand ay . core data . utils . remove Source NotNull Ċ import Ġcom . mand ay . management . data . entities . Skill Entity Ċ import Ġcom . mand ay . management . domain . Employee Model Ċ import Ġcom . mand ay . management . repository . Employee Repository Ċ import Ġcom . mand ay . management . repository . Skill Repository Ċ import Ġorg . k oin . java . K oin Java Component . inject Ċ Ċ internal Ġclass ĠEmployee Detail ViewModel Ġ: ĠExecutor ViewModel () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġemployee Repository : ĠEmployee Repository Ġby Ġinject ( Employee Repository :: class . java ) ĊĠĠĠ Ġprivate Ġval Ġskill Repository : ĠSkill Repository Ġby Ġinject ( Skill Repository :: class . java ) ĊĊĠĠĠ Ġprivate Ġval Ġerror Field List Ġ= Ġmutable ListOf < Error Field >() ĊĠĠĠ Ġval Ġskills Ġ= ĠMed iator LiveData < List < Skill Entity > ?> () ĊĠĠĠ Ġlateinit Ġvar Ġemployee Model : ĠEmployee Model ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ Ġskills . add Source NotNull ( skill Repository . getList Skill (), ĠObserver Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġskills . remove Source NotNull ( skill Repository . getList Skill ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġskills . post Value ( it ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġinitialize ( employee : ĠEmployee Model ) Ġ{ ĊĠĠĠĠĠĠĠ Ġthis . employee Model Ġ= Ġemployee ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġfields (): ĠLive Data < List < Error Field >> Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresponse ViewModel Ġ= ĠMutable LiveData < List < Error Field >>() ĊĊĠĠĠĠĠĠĠ Ġerror Field List . clear () ĊĠĠĠĠĠĠĠ Ġemployee Model . let Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( it . name . isEmpty ()) Ġerror Field List . add ( Error Field . ERROR _ FIELD _ NAME ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( it . surname . isEmpty ()) Ġerror Field List . add ( Error Field . ERROR _ FIELD _ SUR NAME ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( it . phone . isEmpty ()) Ġerror Field List . add ( Error Field . ERROR _ FIELD _ PHONE ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( it . email . isEmpty ()) Ġerror Field List . add ( Error Field . ERROR _ FIELD _ EMAIL ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( it . country . isEmpty ()) Ġerror Field List . add ( Error Field . ERROR _ FIELD _ COUNTRY ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( it . skill Employee Description . isEmpty ()) Ġerror Field List . add ( Error Field . ERROR _ FIELD _ SK ILL ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġresponse ViewModel . post Value ( error Field List ) ĊĊĠĠĠĠĠĠĠ Ġreturn Ġresponse ViewModel ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġbutton Save Clicked () Ġ= ĊĠĠĠĠĠĠĠ Ġdo In Background ({ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġemployee Repository . add Employee ( employee Model ) ĊĠĠĠĠĠĠĠ Ġ}) ĊĊĊĠĠĠ Ġenum Ġclass ĠError Field Ġ{ ĊĠĠĠĠĠĠĠ ĠERROR _ FIELD _ NAME , ĠERROR _ FIELD _ SUR NAME , ĠERROR _ FIELD _ EMAIL , ĠERROR _ FIELD _ PHONE , ĠERROR _ FIELD _ COUNTRY , ĠERROR _ FIELD _ SK ILL ĊĠĠĠ Ġ} Ċ } ĊĊ