示例#1
0
        public async Task <IActionResult> Index(int pageIndex = 1, int maxResults = 5)
        {
            var userCredentials = GetUserCredentials();

            if (userCredentials is null || userCredentials.Role == "Desconosido")
            {
                return(PageNotFound());
            }

            string currentPage      = (pageIndex < 1) ? "1" : pageIndex.ToString();
            string maxProjectsCount = (maxResults < 5) ? "5" : (maxResults > 100) ? "100" : maxResults.ToString();
            var    queryResult      = new Dictionary <string, string>
            {
                { nameof(pageIndex), currentPage },
                { nameof(maxResults), maxProjectsCount },
                { "role", userCredentials.Role }
            };

            var pendingReviews = await CallApiGETAsync <ReviewsToMakeVM>(uri : "/api/reviews/pending/" + userCredentials.Id.ToString() + QueryString.Create(queryResult), isSecured : true);

            if (pendingReviews == null)
            {
                pendingReviews = new ReviewsToMakeVM();
                pendingReviews.ProjectsToReview = new List <ProjectResponseDTO>();
                pendingReviews.PageIndex        = pageIndex;
            }
            pendingReviews.Review = new ReviewCreateVM();

            return(View(pendingReviews));
        }
示例#2
0
        public async Task <IActionResult> PostReviews(ReviewsToMakeVM reviewData)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Index", reviewData));
            }

            var newReview = (ReviewResponseDTO)reviewData.Review;

            var reviewResponse = await CallApiPOSTAsync <ReviewResponseDTO>(uri : "/api/reviews/", body : newReview, isSecured : true);

            if (reviewResponse is null)
            {
                return(RedirectToAction("Index", reviewData));
            }

            var updatePostulant = new PostulantUpdateDTO
            {
                IsSelected       = true,
                HasWorkReview    = (reviewData.Review.ReviewerRole == "Contratista"),
                HasProyectReview = (reviewData.Review.ReviewerRole == "Profesional")
            };

            var postulantResponse = await CallApiPUTAsync <PostulantUpdateDTO>(
                uri : "api/postulants/" + reviewData.Review.PostulantId, body : updatePostulant, isSecured : true);

            return(RedirectToAction("Index"));
        }