// --------------------------------------------------------------------------------------------- public static void CopyValues(TestCodeDTO source, test_code target) { target.id = source.id; target.module_id = source.module_id; target.position = source.position; target.task_answer = source.task_answer; }
// PUBLIC // ============================================================================================= public TestCodeDTO UpsertCode(TestCodeDTO codeReceived) { var id = codeReceived.id; test_code code; if (id == 0) { code = new test_code(); TestCodeMapper.CopyValues(codeReceived, code); _codeRepository.Add(code); } else { code = _codeRepository.Get(id); _codeRepository.SetNewValues(codeReceived, code); } return(TestCodeMapper.GetDTO(code)); }
// PUBLIC // ============================================================================================= /* Kopiuje dane z TestCodeDTO do test_code pobranego z bazy i zapisuje zmiany w bazie. */ public void SetNewValues(TestCodeDTO source, test_code result) { _context.Entry(result).CurrentValues.SetValues(source); _context.SaveChanges(); }