Ejemplo n.º 1
0
        public async Task <IActionResult> AddOrEditFeedback(FeedbackViewModel feedbackViewModel, Guid id, int?feedbackId)
        {
            if (!ModelState.IsValid)
            {
                var survey = await _surveyService.Get(id);

                //The SurveyFeedback is not bound to the model in the View as it is a complex object
                feedbackViewModel.SurveyFeedback = survey.Feedback;
                return(View("Feedback", feedbackViewModel));
            }

            var conditions = await _feedbackService.FindValidConditions(feedbackViewModel.Conditions);

            if (feedbackId != null)
            {
                var survey = await _surveyService.EditFeedback(id, feedbackViewModel.FeedbackText, conditions, feedbackViewModel.ChosenPriority, feedbackId ?? 0);

                return(RedirectToAction("Feedback", new { id = id }));
            }
            else
            {
                var survey = await _surveyService.AddFeedback(id, feedbackViewModel.FeedbackText, conditions, feedbackViewModel.ChosenPriority); //TODO

                return(RedirectToAction("Feedback", new { id = id }));
            }
        }