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")); }
public async Task <IActionResult> SelectProfesional(Guid postulanId, Guid proyectId) { PostulantUpdateDTO postulantData = new PostulantUpdateDTO(); if (!ModelState.IsValid) { return(View(postulantData)); } postulantData.IsSelected = true; var response = await CallApiPUTAsync <PostulantUpdateDTO>( uri : "api/Postulants/" + postulanId, body : postulantData, isSecured : true); return(RedirectToAction("Index", "Project", new { projectId = proyectId })); }
public ActionResult UpdatePostulant([FromRoute] Guid postulantId, [FromBody] PostulantUpdateDTO postulantData) { if (postulantId == default) { return(BadRequest(new { Message = $"Error: el parametro {nameof(postulantId)} no puede ser nulo." })); } if (!ModelState.IsValid) { return(BadRequest(new { Message = "La informacion de registro del proyecto son invalidos.", ErrorsCount = ModelState.ErrorCount, Errors = ModelState.Select(x => x.Value.Errors) })); } var postulantToUpdate = _appDBContext.Postulants.FirstOrDefault(x => x.Id == postulantId); if (postulantToUpdate != null) { postulantToUpdate.IsSelected = (postulantData.IsSelected) ? postulantData.IsSelected : postulantToUpdate.IsSelected; postulantToUpdate.HasWorkReview = (postulantData.HasWorkReview) ? postulantData.HasWorkReview : postulantToUpdate.HasWorkReview; postulantToUpdate.HasProyectReview = (postulantData.HasProyectReview) ? postulantData.HasProyectReview : postulantToUpdate.HasProyectReview; this._appDBContext.Postulants.Update(postulantToUpdate); this._appDBContext.SaveChanges(); var postulantsModel = _mapper.Map <PostulantResponseDTO>(postulantToUpdate); return(Ok(new { Message = "OK", Result = postulantsModel })); } else { return(NotFound(new { Error = "No se encontro el postulante a actualizar." })); } }