Пример #1
0
        public void AddAnswer(string answerStr)
        {
            var answer = new QAAnswerModel
            {
                Answer = answerStr
            };

            _question.Answers.Add(answer);
        }
Пример #2
0
        // 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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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));
            }
        }