public async Task <ActionResult> Home(int id) { var laboratory = new LaboratoryViewModel(); var projeto = new ProjetoOutputModel(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseUrl.URL); var response = await client.GetAsync($"api/project/busca?id={id}"); if (response.IsSuccessStatusCode) { var responseContent = await response.Content.ReadAsStringAsync(); projeto = JsonConvert.DeserializeObject <ProjetoOutputModel>(responseContent); var documentos = GetProjetoService.ListaDocumentos(projeto); TempData["IdProjeto"] = projeto.Id; TempData["IdLaboratorio"] = projeto.laboratory.Id; ViewBag.Documentos = documentos; return(View(projeto)); } } return(View()); }
public List <DocumentosViewModel> ListaDocumentos(ProjetoOutputModel projeto) { List <DocumentosViewModel> docs = new List <DocumentosViewModel>(); foreach (PostViewModel p in projeto.Posts) { if (p.UrlDocumento != null) { DocumentosViewModel doc = new DocumentosViewModel() { Url = p.UrlDocumento }; docs.Add(doc); } } return(docs); }