public void AddAnswer(string answerStr) { var answer = new QAAnswerModel { Answer = answerStr }; _question.Answers.Add(answer); }
// Get Not needed: QAQuestion will already get them thru DB Call public bool CreateAnswer(QAAnswerModel model) { var entity = MappingUtil.Map <QAAnswerModel, QandAAnswer>(model); _uow.QandAAnswers.Add(entity); _uow.SaveChanges(); MappingUtil.Map(entity, model); return(true); }
public bool UpdateAnswer(QAAnswerModel model) { var entity = MappingUtil.Map <QAAnswerModel, QandAAnswer>(model); try { _uow.QandAAnswers.Update(entity); _uow.SaveChanges(); } catch (Exception) { return(false); } return(true); }
public HttpResponseMessage Patch([FromBody] QAAnswerModel model) { try { if (ModelState.IsValid == false || _qaAnswerSvc.UpdateAnswer(model) == false) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState)); } return(Request.CreateResponse(HttpStatusCode.OK, model)); } catch (ServiceException ex) { return(Request.CreateResponse(ex.HttpStatusCode, ex.Message)); } }