public async Task <IActionResult> Put(int id, [FromBody] ChoiceDTO choice)
        {
            try
            {
                if (choice.Id != id)
                {
                    return(BadRequest());
                }

                var foundChoice = await _choiceRepo.GetAsync(id);

                if (foundChoice == null)
                {
                    return(NotFound());
                }

                _mapper.Map(choice, foundChoice);

                await _choiceRepo.SaveAsync();

                return(NoContent());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(BadRequest());
            }
        }
        public JsonResult Delete([DataSourceRequest] DataSourceRequest request, ChoiceDTO choiceDTO)
        {
            try
            {
                long questionId = choiceDTO.ChoiceQuestionId;

                //check to ensure the user owns the resources she is trying to access. if not; we get out of here.
                //Somebody is trying to do bad stuff.
                if (!ProbeValidate.IsChoiceForLoggedInUser(choiceDTO.Id))
                {
                    ModelState.AddModelError("", "Choice Delete could not be accomplished");
                    return(Json(ModelState.ToDataSourceResult()));
                }

                if (choiceDTO != null && ModelState.IsValid)
                {
                    Choice choice = db.Choice.Find(choiceDTO.Id);
                    db.Choice.Remove(choice);
                    db.SaveChanges(Request != null ? Request.LogonUserIdentity.Name : null);
                }

                NotifyProbe.NotifyChoiceChanged(User.Identity.Name); //let all clients know where was a game change.

                return(Json(ModelState.IsValid ? true : ModelState.ToDataSourceResult()));
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex); //log to elmah
                ModelState.AddModelError("", ProbeConstants.MSG_UnsuccessfulOperation_STR);
                return(Json(ModelState.ToDataSourceResult()));
            }
        }//public JsonResult Delete([DataSourceRequest] DataSourceRequest request, ChoiceDTO choiceDTO)
        public JsonResult Create([DataSourceRequest] DataSourceRequest request, ChoiceDTO choiceDTO)
        {
            try
            {
                //check to ensure the user owns the resources she is trying to access. if not; we get out of here.
                //Somebody is trying to do bad stuff.
                if (!ProbeValidate.IsQuestionForLoggedInUser(choiceDTO.ChoiceQuestionId))
                {
                    ModelState.AddModelError("", "Question Create could not be accomplished");
                    return(Json(ModelState.ToDataSourceResult()));
                }

                if (choiceDTO.Correct)
                {
                    ValidateChoice(choiceDTO.ChoiceQuestionId);                    //only validate if choice selected uses correct
                }
                //Set choice name - same as question name
                choiceDTO.Name = db.ChoiceQuestion.Find(choiceDTO.ChoiceQuestionId).Name;
                if (ModelState.IsValid)
                {
                    Choice choice = new Choice
                    {
                        Id = choiceDTO.Id,
                        ChoiceQuestionId = choiceDTO.ChoiceQuestionId,
                        Name             = choiceDTO.Name,
                        Text             = choiceDTO.Text,
                        Correct          = choiceDTO.Correct,
                        OrderNbr         = choiceDTO.OrderNbr
                    };
                    db.Choice.Add(choice);
                    db.SaveChanges(Request != null ? Request.LogonUserIdentity.Name : null);
                    choiceDTO.Id = choice.Id;
                }

                NotifyProbe.NotifyChoiceChanged(User.Identity.Name); //let all clients know where was a game change.

                return(Json(new[] { choiceDTO }.ToDataSourceResult(request, ModelState)));
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex); //log to elmah
                ModelState.AddModelError("", ProbeConstants.MSG_UnsuccessfulOperation_STR);
                return(Json(ModelState.IsValid ? true : ModelState.ToDataSourceResult()));
            }
        }//public JsonResult Create([DataSourceRequest] DataSourceRequest request, ChoiceDTO choiceDTO)