public ExamModel InsertExam(ExamModel model) { if (model.Shift != null && model.ShiftId == 0) { model.Shift.CreatedById = model.CreatedById; model.Shift.CreatedDate = model.CreatedDate; model.Shift.LastModifiedById = model.LastModifiedById; model.Shift.LastModifiedDate = model.LastModifiedDate; var shift = _shifts.InsertShift(model.Shift); model.ShiftId = shift.Id; } var inserted = _repo.Insert(model); return(GetExam(inserted.Id)); }