Ejemplo n.º 1
0
        public ActionResult AssignReviewer(int?paperId)
        {
            if (paperId == null)
            {
                return(HttpNotFound());
            }
            var          reviewers = db.Reviewers.ToList();   //list all reviewers
            var          paper     = db.Papers.Find(paperId); //list paper
            Checkboxlist checklist = new Checkboxlist
            {
                paper     = paper,//first is checkboxlist's paper, second is "var paper" get paper
                checklist = new List <Checkbox>(),
            };

            foreach (var reviewer in reviewers) //show all reviewers find in "var reviewers"
            {
                var checkbox = new Checkbox     //build checkbox
                {
                    IsSelected = false,         //intial state isn't be selected
                    reviewerId = reviewer.reviewerId,
                };
                User user1 = db.Users.Find(reviewer.reviewerId);//ba shang mian de reviewer de id qu user li mian zhao
                if (user1 != null)
                {
                    checkbox.name = user1.name;
                }
                LogEntities db2   = new LogEntities();
                AspNetUser  user2 = db2.AspNetUsers.Find(reviewer.reviewerId);
                if (user2 != null)
                {
                    checkbox.Email = user2.Email;
                }
                var keywordbrgs = db.Reviewers.Where(m => m.reviewerId == reviewer.reviewerId).ToList();
                foreach (var keywordbrg in keywordbrgs)
                {
                    var keywordEntity = db.Keywords.Find(keywordbrg.keywords);
                    checkbox.keyword += keywordEntity.keyword1 + ", ";
                }
                checklist.checklist.Add(checkbox);//1 is "Checkboxlist checklist = new Checkboxlist"
            }//2 is checklist class's attribute

            return(View(checklist));
        }
Ejemplo n.º 2
0
        public ActionResult AssignReviewer(Checkboxlist model)
        {
            var selected = model.GetSelectedId();//huo de bei xuan de reviewer
            var paper    = db.Papers.Find(model.paper.paperId);

            if (selected.Count() == 4 || selected.Count() == 3)
            {
                foreach (string reviewerId in selected)
                {
                    Review review = new Review
                    {
                        paperId    = paper.paperId,
                        reviewerId = reviewerId,//1 is reviewer class's reviewer id, 2 is for loop's
                    };
                    db.Reviews.Add(review);
                }
                paper.reviewstatus    = "Assigned";
                db.Entry(paper).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", "Home"));
            }
            return(View(model));
        }