Beispiel #1
0
        // Post

        async Task ProcessPost(HttpContext context)
        {
            Console.WriteLine($"{nameof(FeedbackLoader)} ProcessPost");

            FeedbackModel model = await DeserializeModel(context);

            try
            {
                if (ValidateModel(model))
                {
                    await sender.Send(model);

                    RedirectSuccess(context);
                }
                else
                {
                    Console.WriteLine($"{nameof(FeedbackLoader)} ERROR - ValidateModel");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{nameof(FeedbackLoader)} Exception {ex.Message}");
            }

            RedirectError(context);
        }
        public async Task <IActionResult> Post([FromBody] PlayerFeedBackRequest feedback)
        {
            var ubiUserIdExtractionResult = UbiUserIdHeader.ExtractUbiUserId(Request);

            if (ubiUserIdExtractionResult.IsError)
            {
                return(BadRequest(ubiUserIdExtractionResult.Error));
            }

            var utcTimeNow = _clock.GetTimeNow();

            var feedbackSendingResult =
                await _feedbackSender.Send(feedback.ToDto(utcTimeNow, ubiUserIdExtractionResult.Value));

            if (feedbackSendingResult.IsOk)
            {
                return(Ok());
            }

            return(BadRequest(feedbackSendingResult.Error));
        }