public async Task <IActionResult> Index(string InstId, bool FromPP) { //-----!!!! Это был тест отправки сообщений - пусть он тут побудет // EmailService es = new EmailService(); // await es.SendEmailAsync("*****@*****.**", "SMTP_TEST", "YOLO"); //-----!!!!! var inst = await(from i in DBContext.Institutions.Include(d => d.Departments).Include(m => m.Manager) where i.Id.ToString() == InstId select i).FirstOrDefaultAsync(); var deps = await(from d in DBContext.Departments.Include(h => h.HeadTeacher) where inst.Departments.Contains(d) select d).ToListAsync(); var departs = deps; var man = inst.Manager; var name = inst.Name; var mail = inst.Manager.Email; //var manager var model = new DepartmentsViewModel() { InstitutionId = InstId, InstitutionName = name, ManagerId = man.Id, Departments = deps, ManagerEmail = mail, userGrants = await checkService.getUserGrants(User) }; model.FromPP = FromPP; return(View(model)); }
public async Task <IActionResult> Index() { InstitutionsViewModel model = new InstitutionsViewModel() { Institutions = DBContext.Institutions.Include(m => m.Manager).ToList(), userGrants = await checkService.getUserGrants(User) }; return(View(model)); }
public async Task <IActionResult> Index() { var users = userManager.Users.ToList(); users.Sort(new EUser.CompareByFIO()); var model = new UsersAdminViewModel(database) { Users = users, WhyTitles = new Dictionary <EUser, string>(), userGrants = await checkService.getUserGrants(User) }; return(View(model)); }
public async Task <IActionResult> ForumNode(string NodeId) { if (NodeId == "1") { var forum = await(from f in DBContext.ForumNodes .Include(e => e.ChildEndpoints) .Include(n => n.ChildNodes) where f.CreatorId == "-1" select f).FirstOrDefaultAsync(); var model = new ForumNodeViewModel() { NodeId = forum.Id.ToString(), NodeName = forum.Name, Endpoints = forum.ChildEndpoints.OrderByDescending(d => d.CreationDate).ToList(), Nodes = forum.ChildNodes.OrderByDescending(d => d.CreationDate).ToList(), CreatorId = "-1", CreatorName = "System", CreationDateString = forum.CreationDate.ToString("d"), userGrants = await checkService.getUserGrants(User) }; return(View(model)); } else { var forum = await(from f in DBContext.ForumNodes .Include(e => e.ChildEndpoints) .Include(n => n.ChildNodes) .Include(p => p.ParentNode) where f.Id.ToString() == NodeId select f).FirstOrDefaultAsync(); var creator = await(from c in DBContext.Users where c.Id == forum.CreatorId.ToString() select c).FirstOrDefaultAsync(); var model = new ForumNodeViewModel() { NodeId = forum.Id.ToString(), NodeName = forum.Name, Endpoints = forum.ChildEndpoints.OrderByDescending(d => d.CreationDate).ToList(), Nodes = forum.ChildNodes.OrderByDescending(d => d.CreationDate).ToList(), CreatorId = forum.CreatorId.ToString(), CreatorName = creator.FIO, CreatorEmail = creator.Email.ToLower(), CreationDateString = forum.CreationDate.ToString("d"), ParentNodeId = forum.ParentNode.Id.ToString(), userGrants = await checkService.getUserGrants(User) }; return(View(model)); } }
public async Task <IActionResult> Index(List <string> SecuritySettingsErrors, bool SettingsChanged) { if (!User.Identity.IsAuthenticated) { UserPageViewModel model = new UserPageViewModel(DBContext) { userGrants = await checkService.getUserGrants(User) }; return(View(model)); } else { UserPageViewModel model = new UserPageViewModel(DBContext) { UserFIO = (from usr in DBContext.Users where usr.Email == User.Identity.Name select usr.FIO).FirstOrDefault(), UserId = (from usr in DBContext.Users where usr.Email == User.Identity.Name select usr.Id).FirstOrDefault(), userGrants = await checkService.getUserGrants(User) }; if (SecuritySettingsErrors != null) { ViewBag.Errors = new List <string>(); foreach (var err in SecuritySettingsErrors) { ViewBag.Errors.Add(err); } } if (SettingsChanged) { ViewBag.Success = "Настройки безопасности успешно обновлены"; } await model.CheckAsync(); return(View(model)); } }
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)); }
public async Task <IActionResult> Index(string DepId) { var dep = await(from i in DBContext.Departments.Include(s => s.Specialities).Include(h => h.HeadTeacher) where i.Id.ToString() == DepId select i).FirstOrDefaultAsync(); var specs = await(from d in DBContext.Specialities where dep.Specialities.Contains(d) select d).ToListAsync(); if (dep != null && specs != null) { var inst = await(from i in DBContext.Institutions.Include(d => d.Departments).Include(m => m.Manager) where i.Departments.Contains(dep) select i).FirstOrDefaultAsync(); //var manager var model = new SpecialitiesViewModel() { Specialities = specs, DepartmentId = DepId, DepartmentName = dep.Name, InstId = inst.Id.ToString(), InstManagerId = inst.Manager.Id.ToString(), InstManagerEmail = inst.Manager.Email, HeadTeacherId = dep.HeadTeacher.Id.ToString(), HeadTeacherEmail = dep.HeadTeacher.Email, userGrants = await checkService.getUserGrants(User) }; return(View(model)); } else { ModelState.AddModelError("Index", "No such department"); } return(RedirectToAction("Index")); }
public async Task <IActionResult> Index(string SpecId, bool FromPP) { var spec = await(from sp in DBContext.Specialities.Include(d => d.Disciplines).Include(s => s.Students).Include(s => s.Schedules) where sp.Id.ToString() == SpecId select sp).FirstOrDefaultAsync(); if (spec != null) { //var sched = await (from s in DBContext.WeekSchedules.Include(w => w.Schedule) // where s.Speciality.Id == spec.Id // select s).FirstOrDefaultAsync(); var dis = await(from d in DBContext.Disciplines.Include(t => t.Teacher) where spec.Disciplines.Contains(d) select d).ToListAsync(); var dep = await(from i in DBContext.Departments.Include(d => d.Specialities) where i.Specialities.Contains(spec) select i).FirstOrDefaultAsync(); var inst = await(from i in DBContext.Institutions.Include(d => d.Departments).Include(m => m.Manager) where i.Departments.Contains(dep) select i).FirstOrDefaultAsync(); var model = new DisciplinesViewModel() { SpecialityId = spec.Id.ToString(), SpecialityName = spec.Name, InstId = inst.Id.ToString(), InstManagerId = inst.Manager.Id, InstManagerEmail = inst.Manager.Email, Disciplines = dis, Students = spec.Students, Schedules = spec.Schedules.OrderBy(s => s.Name).ToList <EWeekSchedule>(), userGrants = await checkService.getUserGrants(User), DepartmentId = dep.Id.ToString() }; model.FromPP = FromPP; return(View(model)); } return(View());//сделать редирект на страницу с ошибкой }