Update and insert records filter based on conditions in sql server

Same school assignment as this?
Especially this section looks identical: