public void ConfirmAddition(int problemStepID, int problemID, string problemStepText, int priorityOrder)
        {
            Log.Info(TAG, "ConfirmAddition: problemStepID - " + problemStepID.ToString() + ", problemID - " + problemID.ToString() + ", problemStepText - " + problemStepText + ", priorityOrder - " + priorityOrder.ToString());

            ProblemStep step = null;

            if (problemStepID == -1)
            {
                Log.Info(TAG, "ConfirmAddition: New problem step detected");
                step           = new ProblemStep();
                step.IsNew     = true;
                step.IsDirty   = false;
                step.ProblemID = problemID;
            }
            else
            {
                step         = GlobalData.ProblemSolvingItems.Find(prob => prob.ProblemID == problemID).ProblemSteps.Find(probStep => probStep.ProblemStepID == problemStepID);
                step.IsNew   = false;
                step.IsDirty = true;
            }

            step.ProblemStep   = problemStepText;
            step.PriorityOrder = priorityOrder;

            step.Save();
            if (problemStepID == -1)
            {
                GlobalData.ProblemSolvingItems.Find(prob => prob.ProblemID == problemID).ProblemSteps.Add(step);
            }

            UpdateAdapter();
        }
Ejemplo n.º 2
0
        private void ProblemProAndConList_ItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e)
        {
            try
            {
                Problem          problem          = null;
                ProblemStep      step             = null;
                ProblemIdea      idea             = null;
                ProblemProAndCon problemProAndCon = null;

                ProblemSolvingProsAndConsDialogFragment proAndConFragment = null;
                Log.Info(TAG, "ProblemProAndConList_ItemLongClick: selected item - " + e.Position.ToString() + ", problemID - " + _problemID.ToString());

                problem = GlobalData.ProblemSolvingItems.Find(prob => prob.ProblemID == _problemID);
                if (problem != null)
                {
                    step = problem.ProblemSteps.Find(stp => stp.ProblemStepID == _problemStepID);
                    if (step != null)
                    {
                        idea = step.ProblemStepIdeas.Find(ida => ida.ProblemIdeaID == _problemIdeaID);
                        if (idea != null)
                        {
                            problemProAndCon = idea.ProsAndCons[e.Position];
                        }
                    }
                }
                if (problemProAndCon != null)
                {
                    proAndConFragment = new ProblemSolvingProsAndConsDialogFragment(this, "Edit Pro or Con", _problemID, problemProAndCon.ProblemStepID, problemProAndCon.ProblemIdeaID, problemProAndCon.ProblemProAndConID,
                                                                                    problemProAndCon.ProblemProAndConType, problemProAndCon.ProblemProAndConText.Trim());
                }
                var fragmentTransaction = FragmentManager.BeginTransaction();
                if (fragmentTransaction != null)
                {
                    proAndConFragment.Show(fragmentTransaction, proAndConFragment.Tag);
                }
            }
            catch (Exception ex)
            {
                Log.Error(TAG, "ProblemProAndConList_ItemLongClick: Exception - " + ex.Message);
                if (GlobalData.ShowErrorDialog)
                {
                    ErrorDisplay.ShowErrorAlert(this, ex, GetString(Resource.String.ErrorProblemSolvingProConActivitySelect), "ProblemSolvingProsAndConsActivity.ProblemProAndConList_ItemLongClick");
                }
            }
        }
        private void ProblemStepList_ItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e)
        {
            ProblemStep problemStep = null;
            ProblemSolvingStepsFragment stepFragment = null;

            Log.Info(TAG, "ProblemStepList_ItemLongClick: selected item - " + e.Position.ToString() + ", problemID - " + _problemID.ToString());
            problemStep = GlobalData.ProblemSolvingItems.Find(prob => prob.ProblemID == _problemID).ProblemSteps[e.Position];
            if (problemStep != null)
            {
                stepFragment = new ProblemSolvingStepsFragment(this, "Edit Step", _problemID, problemStep.ProblemStepID, problemStep.ProblemStep.Trim(), problemStep.PriorityOrder);
            }
            var fragmentTransaction = FragmentManager.BeginTransaction();

            if (fragmentTransaction != null)
            {
                stepFragment.Show(fragmentTransaction, stepFragment.Tag);
            }
        }
Ejemplo n.º 4
0
        public async Task <ActionResult <ProblemStepDto> > CreateProblemStep(int problemId, CreateProblemStepDto createProblemStepDto)
        {
            var problemstep = new ProblemStep
            {
                Ideas         = new Collection <ProblemIdea>(),
                PriorityOrder = createProblemStepDto.PriorityOrder,
                Problem       = _mapper.Map <Problem>(await _unitOfWork.ProblemRepository.GetItemAsync(problemId)),
                Step          = createProblemStepDto.Step
            };

            _unitOfWork.ProblemStepRepository.AddItem(problemstep);
            if (await _unitOfWork.Complete())
            {
                return(Ok(_mapper.Map <ProblemStepDto>(problemstep)));
            }

            return(BadRequest("Unable to create ProblemStep"));
        }