示例#1
0
        public async Task <int> CreateReview([FromBody] FullReviewSetup setup)
        {
            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", HttpContext.Session.GetString("SecurityToken"));
                string json = JsonConvert.SerializeObject(setup);
                HttpResponseMessage message = await client.PostAsync(siteName + "/api/Review/CreateReview", new StringContent(json, Encoding.UTF8, "application/json"));

                int reviewId = JsonConvert.DeserializeObject <int>(await message.Content.ReadAsStringAsync());
                //return RedirectToAction("GetReview", "Review", new { id = reviewId });
                return(reviewId);
            }
        }
示例#2
0
        public int CreateReview([FromBody] FullReviewSetup review)
        {
            Review r = new Review()
            {
                Name        = review.Setup.Name,
                CloseDate   = review.Setup.EndDate,
                Description = review.Setup.Description,
                StartDate   = review.Setup.StartDate,
                //WorkproductId = review.Setup.WorkProduct,
                ReviewTameplateId = review.Setup.Tameplate,
                Html    = review.Setup.Html,
                IsEmpty = review.Setup.IsEmpty
            };
            var tmp = context.ReviewTameplate.Where(x => x.Id == review.Setup.Tameplate).
                      Include(p => p.HeaderRow).FirstOrDefault();

            foreach (var t in tmp.HeaderRow)
            {
                HeaderRowData data = new HeaderRowData()
                {
                    HeaderRowId = t.Id
                };
                r.HeaderRowData.Add(data);
            }
            foreach (var p in review.Participant)
            {
                UserReviewRole userReviewRole = new UserReviewRole()
                {
                    UsersEmail   = p.Email,
                    ReviewRoleId = p.Role,
                };
                r.UserReviewRole.Add(userReviewRole);
            }
            foreach (int i in review.Artifact)
            {
                var artifact         = context.IbmArtifact.Where(a => a.Id == i).FirstOrDefault();
                IbmArtifactReview ar = new IbmArtifactReview();
                ar.IbmArtifactIbmId = artifact.IbmId;
                ar.IbmArtifactId    = artifact.Id;
                r.IbmArtifactReview.Add(ar);
                r.IbmArtifact.Add(artifact);
            }
            context.Workproduct.Where(w => w.Id == review.Setup.WorkProduct).FirstOrDefault().Review.Add(r);
            //context.Review.Add(r);
            context.SaveChanges();
            return(r.Id);
        }