Beispiel #1
0
#pragma warning disable S4261 // Methods should be named according to their synchronicities
        public async Task <JsonResult> Create(FeedbackViewModel feedbackViewModel)
#pragma warning restore S4261 // Methods should be named according to their synchronicities
        {
            var result = new FeedbackMessageViewModel {
                ResultMessage       = Resources.UI.TournamentController.CheckCaptcha,
                OperationSuccessful = false
            };

            try
            {
                var isCaptchaValid = await _captchaManager.ValidateUserCaptchaAsync(feedbackViewModel.CaptchaResponse);

                if (isCaptchaValid)
                {
                    if (ModelState.IsValid)
                    {
                        var domainFeedback = feedbackViewModel.ToDomain();
                        _feedbackService.Create(domainFeedback);
                        result.ResultMessage       = Resources.UI.TournamentController.SuccessfulSent;
                        result.OperationSuccessful = true;
                    }
                    else
                    {
                        result.ResultMessage = Resources.UI.TournamentController.CheckData;
                    }
                }
            }
            catch (ArgumentException ex)
            {
                ModelState.AddModelError("ValidationMessage", ex.Message);
            }

            return(Json(result, JsonRequestBehavior.DenyGet));
        }