public IHttpActionResult PostInventory(Inventory inventory)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     try
     {
         _repository.Add(inventory);
     }
     catch (Exception ex)
     {
         //must be other actions
         throw;
     }
     return(CreatedAtRoute("DisplayRoute", new { id = inventory.Id }, inventory));
 }
        public void SaveAddEdditQuestion(QuestionViewModel vM, bool isEdit)
        {
            vM.AnswerList[vM.isCorrectNumber].IsCorrect = true;
            var question = _mapper.GetItem <QuestionViewModel, Question>(vM);

            question.Answer = new List <Answer>();
            foreach (var answer in vM.AnswerList)
            {
                question.Answer.Add(answer);
            }

            if (isEdit)
            {
                _questionRepository.Update(question);
                question.Answer.ToList().ForEach(x => _answerRepository.Update(x));
                return;
            }

            _questionRepository.Add(question);
        }