public ActionResult Preview(int projectid)
        {
            User user = (User)Session["currentuserinfo"];



            if (user == null)
            {
                return(RedirectToAction("Index", "AdminLogin"));
            }
            else
            {
                //查询学员信息
                Student stu = new UserService().GetStudetInfo(user.UserId);

                ForProjectUIModel pro = projectservice.GetProjectinfoById(projectid);

                ViewBag.users = user;

                if (stu != null)
                {
                    ViewBag.stuid = stu.StudentId;
                }

                return(View(pro));
            }
        }
Beispiel #2
0
        public ForProjectUIModel GetProjectinfoById(int projectid)
        {
            using (var db = new EFContext())
            {
                List <ProjectSign> lists       = db.ProjectSign.Where(x => x.ProjectStatus == 2).ToList(); //获取所有的正在学习中的项目报名表
                List <ProjectSign> alderylists = db.ProjectSign.Where(x => x.ProjectStatus == 3).ToList(); //获取所有的累计完成的项目报名表

                ForProjectUIModel project = (from list in db.Projects
                                             join list2 in db.Lecturers on list.LecturerId equals list2.LecturerId

                                             select new ForProjectUIModel()
                {
                    ProjectIdUIModel = list.ProjectId,               //项目id
                    ProjectNameUIModel = list.ProjectName,           //项目名称
                    ProjectFrameworkUIModel = list.ProjectFramework, //项目框架
                    LecturerNameUIModel = list2.LecturerName,        //老师名称
                    ProdifficultyUIModel = list.Prodifficulty,       //学习难度
                    LecturerIdUIModel = list2.LecturerId,
                    LecturerIntroduction = list2.Introduction,
                    ProjectIntroductionUIModel = list.ProjectIntroduction,
                    StudyTimeUIModel = list.StudyTime,
                }).FirstOrDefault(x => x.ProjectIdUIModel == projectid);


                List <ProjectSign> prosinlist = lists.Where(x => x.ProjectId == projectid).ToList();             //正在学习的

                List <ProjectSign> prosinlistaldery = alderylists.Where(x => x.ProjectId == projectid).ToList(); //累计完成的

                //优秀评分
                List <ProjectSign> goodlists = db.ProjectSign.Where(x => x.ProjectId == projectid && x.ProjectScore >= 80).ToList();



                project.AlreadyCount = prosinlist.Count;       //正在学习的
                project.AlreadyCount = prosinlistaldery.Count; //累计完成的
                project.GoodCount    = goodlists.Count;        //优秀评分的
                //ForProjectUIModel pro = new ForProjectUIModel();


                return(project);
            }
        }