Exemplo n.º 1
0
        public async Task <IActionResult> PostTaskFeedbackCapture(string j, string r, string f, CancellationToken cancellationToken)
        {
            if (!_authService.GetUrlIsSessionAuthorised(HttpContext))
            {
                return(Redirect("/Error/401"));
            }

            int            jobId          = Base64Utils.Base64DecodeToInt(j);
            RequestRoles   requestRole    = (RequestRoles)Base64Utils.Base64DecodeToInt(r);
            FeedbackRating feedbackRating = string.IsNullOrEmpty(f) ? 0 : (FeedbackRating)Base64Utils.Base64DecodeToInt(f);
            var            job            = await _requestService.GetJobSummaryAsync(jobId, cancellationToken);

            var user = await _authService.GetCurrentUser(HttpContext, cancellationToken);

            if (job.JobStatus.Incomplete())
            {
                return(ShowMessage(Result.Failure_IncorrectJobStatus, job.ReferringGroupID));
            }

            if (await _feedbackService.GetFeedbackExists(jobId, requestRole, user?.ID))
            {
                return(ShowMessage(Result.Failure_FeedbackAlreadyRecorded, job.ReferringGroupID));
            }

            return(View(new FeedbackCaptureViewComponentParameters()
            {
                JobId = jobId, RequestRole = requestRole, FeedbackRating = feedbackRating
            }));
        }
        public void Then_Maps_All_Fields(int ukprn, FeedbackRating source)
        {
            var actual = new ProviderRegistrationFeedbackRatingImport().Map(ukprn, source);

            actual.Ukprn.Should().Be(ukprn);
            actual.FeedbackName.Should().Be(source.Key);
            actual.FeedbackCount.Should().Be(source.Value);
        }
Exemplo n.º 3
0
 public ProviderRegistrationFeedbackRatingImport Map(int ukprn, FeedbackRating source)
 {
     return(new ProviderRegistrationFeedbackRatingImport
     {
         Ukprn = ukprn,
         FeedbackCount = source.Value,
         FeedbackName = source.Key
     });
 }
Exemplo n.º 4
0
        public async Task <bool> PostRecordFeedback(int jobId, RequestRoles requestRoles, int?userId, FeedbackRating feedbackRating)
        {
            PostRecordFeedbackRequest request = new PostRecordFeedbackRequest()
            {
                JobId           = jobId,
                RequestRoleType = new RequestRoleType()
                {
                    RequestRole = requestRoles
                },
                UserId             = userId,
                FeedbackRatingType = new FeedbackRatingType()
                {
                    FeedbackRating = feedbackRating
                }
            };
            string              json     = JsonConvert.SerializeObject(request);
            StringContent       data     = new StringContent(json, Encoding.UTF8, "application/json");
            HttpResponseMessage response = await Client.PostAsync("/api/PostRecordFeedback", data);

            string str = await response.Content.ReadAsStringAsync();

            var deserializedResponse = JsonConvert.DeserializeObject <ResponseWrapper <PostRecordFeedbackResponse, FeedbackServiceErrorCode> >(str);

            if (deserializedResponse.HasContent && deserializedResponse.IsSuccessful)
            {
                return(deserializedResponse.Content.Success);
            }
            return(false);
        }