public void GravaPergunta(Question q, NSAADMEntities n) { try { var i = (from p in n.ML_Question where p.id_question == q.id select p).First(); i.status = q.status; if (q.from != null) { i.answered_questions = q.from.answered_questions; } if (q.answer != null) { i.Answer_date_created = q.answer.date_created; i.Answer_status = q.answer.status; i.Answer_text = q.answer.text; } } catch (Exception) { ML_Question mlQ = conv.ConverteQuestion(q); n.ML_Question.AddObject(mlQ); } n.SaveChanges(); }
public ML_Question ConverteQuestion(Question q) { ML_Question mlq = new ML_Question(); if (q.answer != null) { mlq.Answer_date_created = q.answer.date_created; mlq.Answer_status = q.answer.status; mlq.Answer_text = q.answer.text; } if (q.from != null) { mlq.id_from = q.from.id; mlq.answered_questions = q.from.answered_questions; } mlq.date_created = q.date_created; mlq.id = q.id; if (q.item_id != null) { mlq.item_id = q.item_id; } mlq.seller_id = q.seller_id; mlq.status = q.status; mlq.text = q.text; mlq.id_question = q.id; return mlq; }