public QuestionDB QuestionToDB(Question item) { QuestionDB result = new QuestionDB(); List <AnswerDB> answers = new List <AnswerDB>(); foreach (var a in item.Answers) { var aDB = AnswerToDB(a); answers.Add(aDB); } result.AnswersDB = answers; result.Date = item.Date.ToString(); result.ReportTimestamp = item.ReportTimestamp.ToString(); result.ReplyTime = item.ReplyTime.ToString(); result.IsOK = BoolToInt(item.IsOK); result.ReportId = item.ReportId.ToString(); result.Text = item.Text; result.State = item.State; result.Description = item.Description; result.Id = item.Id; return(result); }
public Question DBToQuestion(QuestionDB item) { Question result = new Question(); List <Answer> answers = new List <Answer>(); foreach (var aDB in item.AnswersDB) { var a = DBToAnswer(aDB); answers.Add(a); } result.Answers = answers; DateTime.TryParse(item.Date, out DateTime date); result.Date = date; DateTime.TryParse(item.ReportTimestamp, out DateTime timeStamp); result.ReportTimestamp = timeStamp; DateTime.TryParse(item.ReplyTime, out DateTime replied); result.ReplyTime = replied; result.IsOK = IntToBool(item.IsOK); Guid.TryParse(item.ReportId, out Guid reportId); result.ReportId = reportId; result.Text = item.Text; result.State = item.State; result.Description = item.Description; result.Id = item.Id; return(result); }