コード例 #1
0
        public async Task <IActionResult> Index(string DiscId, bool FromPP, bool FileError)
        {
            var disc = await(from di in DBContext.Disciplines.Include(t => t.Teacher).Include(f => f.Files) where di.Id.ToString() == DiscId select di).FirstOrDefaultAsync();
            var spec = await(from s in DBContext.Specialities.Include(s => s.Disciplines)
                             where s.Disciplines.Contains(disc)
                             select s).FirstOrDefaultAsync();
            var dep = await(from d in DBContext.Departments.Include(s => s.Specialities) where d.Specialities.Contains(spec)
                            select d).FirstOrDefaultAsync();
            var inst = await(from i in DBContext.Institutions.Include(s => s.Departments).Include(m => m.Manager)
                             where i.Departments.Contains(dep)
                             select i).FirstOrDefaultAsync();
            var difiles = await(from f in DBContext.Files.Include(u => u.UserLoad) where disc.Files.Contains(f) select f).ToListAsync();
            var model   = new DisciplineDetailsViewModel()
            {
                DisciplineId     = disc.Id.ToString(),
                DisciplineName   = disc.Name,
                TeacherId        = disc.Teacher.Id,
                TeacherEmail     = disc.Teacher.Email,
                InstId           = inst.Id.ToString(),
                InstManagerId    = inst.Manager.Id.ToString(),
                InstManagerEmail = inst.Manager.Email,
                LectionFiles     = new List <EFile>(),
                PracticeFiles    = new List <EFile>(),
                //DisciplineInfo=String.Join("<p></p>",disc.About.Split("\n")),
                DisciplineInfo = disc.About,
                LecH           = disc.LectionH.ToString(),
                PracH          = disc.PracticeH.ToString(),
                ExamType       = disc.ExamType,
                TeacherName    = disc.Teacher.FIO,
                userGrants     = await checkService.getUserGrants(User),
                SpecialityId   = spec.Id.ToString(),
            };

            foreach (var f in difiles)
            {
                if (f.Tag == "lection")
                {
                    model.LectionFiles.Add(f);
                }
                else if (f.Tag == "practice")
                {
                    model.PracticeFiles.Add(f);
                }
            }
            if (FileError)
            {
                ViewBag.FileError = true;
            }
            model.FromPP = FromPP;
            return(View(model));
        }
コード例 #2
0
        // GET: Discipline/Details/5
        public ActionResult Details(Guid id)
        {
            if (!UserIsInRole("Admin"))
            {
                return(RedirectToAction("Index", "Home"));
            }
            var result = _disciplineQuery.Handle(new DisciplineInputGet {
                DisciplineId = id
            }).Discipline;
            var discipline = new DisciplineDetailsViewModel
            {
                Id             = result.Id,
                Course         = result.Course.Name,
                Name           = result.Name,
                Period         = result.Period,
                Professor      = result.Professor.Name,
                WeeklyWorkload = result.WeeklyWorkload
            };

            return(View(discipline));
        }