private async Task<tbSurveyClientAnswer> SaveClientAnswer(dtoSurveyClientAnswer clientAnswer) { tbSurveyClientAnswer ca = new tbSurveyClientAnswer(); try { ca.ClientId = clientAnswer.ClientId; ca.QuestionId = clientAnswer.QuestionId; ca.QuestionItemId = clientAnswer.QuestionItemId; ca.IsChecked = clientAnswer.IsChecked; ca.CreatedDate = DateTime.UtcNow; _db.tbSurveyClientAnswers.Add(ca); await _db.SaveChangesAsync(); } catch (DataException dex) { throw new ApplicationException("Data error!", dex); } return ca; }
private static dtoSurveyClientAnswer ConvertToDtoAnswwer(this tbSurveyClientAnswer source, dtoSurveyClientAnswer data = null) { if (data == null) data = new dtoSurveyClientAnswer(); if (source == null) return null; data.AnswerId = source.AnswerId; data.ClientId = source.ClientId; data.QuestionId = source.QuestionId; data.QuestionItemId = source.QuestionItemId; data.IsChecked = source.IsChecked; return data; }