public void QuestionAdded(int appointmentID, string question)
        {
            SQLiteDatabase sqlDatabase = null;

            try
            {
                if (question.Trim() != "")
                {
                    AppointmentQuestion newQuestion = new AppointmentQuestion();
                    newQuestion.AppointmentID = appointmentID;
                    newQuestion.Question      = question.Trim();
                    newQuestion.IsNew         = true;
                    _appointment.Questions.Add(newQuestion);
                    _isDirtyQuestions = true;
                    UpdateAdapter();
                }
            }
            catch (Exception e)
            {
                if (sqlDatabase != null && sqlDatabase.IsOpen)
                {
                    sqlDatabase.Close();
                    sqlDatabase = null;
                }
                Log.Error(TAG, "QuestionAdded: Exception - " + e.Message);
                if (GlobalData.ShowErrorDialog)
                {
                    ErrorDisplay.ShowErrorAlert(this, e, GetString(Resource.String.ErrorAddingAppointmentQuestion), "ResourcesAppointmentItemActivity.QuestionAdded");
                }
            }
        }
Exemple #2
0
        public async Task <ActionResult <AppointmentQuestionDto> > CreateAppointmentQuestion(int userId, CreateAppointmentQuestionDto createAppointmentQuestionDto)
        {
            var appointmentQuestion = new AppointmentQuestion
            {
                Question    = createAppointmentQuestionDto.Question,
                Answer      = createAppointmentQuestionDto.Answer,
                Appointment = await _unitOfWork.AppointmentsRepository.GetItemAsync(createAppointmentQuestionDto.AppointmentId)
            };

            _unitOfWork.AppointmentQuestionsRepository.AddItem(appointmentQuestion);
            if (await _unitOfWork.Complete())
            {
                return(Ok(_mapper.Map <AppointmentQuestionDto>(appointmentQuestion)));
            }

            return(BadRequest("Unable to create Appointment question"));
        }