protected void AddMailRequests(int id, ChangeList changeList, MailType requestType, List<string> errors = null)
 {
     var reviewers = (from cl in db.Reviewers.AsNoTracking()
                      where cl.ChangeListId == id
                      select cl);
     foreach (var reviewer in reviewers)
     {
         var result = db.AddMailRequest(reviewer.Id, reviewer.ReviewerAlias, id, (int)requestType);
         if (result == 0 && errors != null)
             errors.Add(string.Format("Failed to add {0} request for {1} for {2}", requestType, reviewer.ReviewerAlias,
                                      changeList.CL));
     }
 }
        private static ChangeFile GetChangeFile(ChangeList changeList, int fileId)
        {
            if (fileId == 0)
                fileId = changeList.ChangeFiles.First().Id;

            var changeFile = (from rv in db.ChangeFiles.AsNoTracking()
                              where rv.Id == fileId
                              select rv).FirstOrDefault();
            if (changeFile == null)
                throw new ApplicationException(string.Format("did not find change list id: {0} cl: {1} file: {2}", changeList.Id, changeList.CL, fileId));

            return changeFile;
        }
        protected ChangeList GetChangeList(int id)
        {
            if (_changeList != null && _changeList.Id == id)
                return _changeList;

            if (id > 0)
                _changeList = db.ChangeLists.Find(id);

            if (_changeList == null || _changeList.ChangeFiles.Count == 0)
                throw new ApplicationException(string.Format("Invalid change list id {0}", id));

            return _changeList;
        }
        //
        // GET: /ChangeList/Diff/5
        private ActionResult Diff(ChangeList changeList)
        {
            var userNameInfo = UserName;
            var settings = UserSettings;
            var changeListSettings = ReviewUtil.ChangeListSettings(0, userNameInfo.userName, changeList.CL, db);
            var model = GetChangeListForFile(changeList.Id, userNameInfo.userName, changeListSettings.fileId, settings);

            var js = new JavaScriptSerializer();
            ViewBag.ChangeList = js.Serialize(model);
            ViewBag.Comments = js.Serialize(model.comments);
            ViewBag.UserSettings = js.Serialize(ReviewUtil.GenerateUserContext(0, userNameInfo.userName, "settings", settings));
            ViewBag.ChangeListSettings = js.Serialize(ReviewUtil.GenerateUserContext(0, userNameInfo.userName, model.CL, changeListSettings));

            return View(model);
        }
 public ChangeListStatusDto(ChangeList input)
 {
     id = input.Id;
     status = input.Stage;
 }
        public ChangeListDto(ChangeList input, bool complete)
        {
            if (input == null)
                return;

            this.CL = input.CL;
            //this.description = input.Description;
            this.id = input.Id;
            this.sourceControlId = input.SourceControlId;
            this.stage = input.Stage;
            this.timeStamp = input.TimeStamp;
            this.userClient = input.UserClient;
            this.userName = input.UserName;
            this.reviewerAlias = input.ReviewerAlias;
            input.ChangeFiles.ToList().ForEach(x => changeFiles.Add(new ChangeFileDto(x, false)));

            // All comments
            input.ChangeFiles.ToList().ForEach(item => item.FileVersions.ToList().ForEach(fileVersion =>
            {
                fileVersion.CommentGroups.ToList().ForEach(group => comments.Add(new CommentGroupDto(@group, true)));
            }));

            if (complete)
            {
                //input.MailChangeLists.ToList().ForEach(x => mailChangeLists.Add(new MailChangeListDto(x, false)));
                //input.MailReviewRequests.ToList().ForEach(x => mailReviewRequests.Add(new MailReviewRequestDto(x, false)));
                input.Reviewers.ToList().ForEach(x =>
                    {
                        if (x.Status != (int)ReviewerStatus.Deleted)
                            reviewers.Add(new ReviewerDto(x, false));
                    });
                input.Reviews.ToList().ForEach(x => reviews.Add(new ReviewDto(x, false)));
            }
        }
 public ChangeListDisplayItem(ChangeList item)
 {
     CL = item.CL;
     description = item.Description;
     id = item.Id;
     shortDescription = item.Description.FirstLine();
     stage = Enum.ToObject(typeof(ChangeListStatus), item.Stage).ToString();
     server = item.SourceControl.Server;
 }