// --------------------------------------------------------------------------------------------- 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 static TestCodeDTO GetDTO(test_code entity) { return(new TestCodeDTO { id = entity.id, module_id = entity.module_id, position = entity.position, task_answer = entity.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)); }