public FullReview GetReview(int id) { FullReview review = new FullReview(); Review r = context.Review.Where(x => x.Id == id).FirstOrDefault(); Workproduct w = context.Workproduct.Where(s => s.Id == r.WorkproductId).FirstOrDefault(); Project p = context.Project.Where(i => i.Id == w.ProjectId).FirstOrDefault(); Setup setup = new Setup() { ProjectName = p.Name, WorkProductName = w.Name, Html = r.Html, IsEmpty = r.IsEmpty, Complete = r.Complete }; review.Setup = setup; review.Participant = GetParticipants(id); List <Header> headers = new List <Header>(); List <int> ids = context.HeaderRowData.Where(x => x.ReviewId == r.Id).Select(x => x.HeaderRowId).ToList(); List <HeaderRow> rows = context.HeaderRow.Where(x => x.ReviewTameplateId == r.ReviewTameplateId && ids.Contains(x.Id)).ToList(); for (int i = 0; i < rows.Count; i++) { string name = context.ReviewColumn.Where(x => x.Id == rows[i].ReviewColumnId).Select(a => a.Name).FirstOrDefault(); string data = context.HeaderRowData.Where(x => x.ReviewId == r.Id && x.HeaderRowId == rows[i].Id).Select(o => o.Value).FirstOrDefault(); Header h = new Header() { Fcn = rows[i].Function, Name = rows[i].Name, Id = rows[i].Id, Parameter = rows[i].Parameter, ColumnName = name, Data = data }; headers.Add(h); } review.HeadersRow = headers; return(review); }
public async Task <IActionResult> GetReview(int id) { using (HttpClient client = new HttpClient()) { client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", HttpContext.Session.GetString("SecurityToken")); HttpResponseMessage msg2 = await client.GetAsync(siteName + "/api/Review/GetReview?id=" + id); FullReview review = JsonConvert.DeserializeObject <FullReview>(await msg2.Content.ReadAsStringAsync()); ViewBag.ReviewId = id; ViewBag.ReviewSetup = review; return(View("~/Views/Review/ReviewForm.cshtml")); } }