public IActionResult Index() { List <Sliders> slider = _context.Sliders.Where(s => s.Activeted && !s.IsDeleted).ToList(); List <Teacher> teachers = _context.Teachers.Where(t => !t.IsDeleted && t.Activeted).Take(4).OrderByDescending(teachers => teachers.Id).ToList(); List <Course> courses = _context.Courses.Where(c => !c.IsDeleted && c.Activeted).Take(3).OrderByDescending(c => c.Created_at).ToList(); List <Event> @event = _context.Events.Where(e => !e.IsDeleted && e.Activeted).Take(4).ToList(); List <Blog> blogs = _context.Blogs.Where(b => !b.IsDeleted && b.Activeted).Take(3).OrderByDescending(b => b.Created_at).ToList(); _context.IncludeModeratorsBlog(true); AboutSection aboutSection = _context.AboutSections.FirstOrDefault(); NoticeSection noticeSection = _context.NoticeSections.Include(n => n.Notices).FirstOrDefault(); List <TestimonialSection> testimonialSection = _context.TestimonialSections.ToList(); HomeVM homeVM = new HomeVM() { Sliders = slider, Teachers = teachers, Courses = courses, Events = @event, Blogs = blogs, AboutSections = aboutSection, NoticeSections = noticeSection, TestimonialSections = testimonialSection }; return(View(homeVM)); }
public static ISectionParser GetSectionParser(string noticeContent, TedLabelDictionary tedLabelDictionary, Language noticeLanguage, NoticeSection noticeSection) { switch (noticeSection) { case NoticeSection.SectionI: return(new SectionIParser(noticeContent, tedLabelDictionary, noticeLanguage)); case NoticeSection.SectionIi: return(new SectionIiParser(noticeContent, tedLabelDictionary, noticeLanguage)); case NoticeSection.SectionIii: return(new SectionIiiParser(noticeContent, tedLabelDictionary, noticeLanguage)); case NoticeSection.SectionIv: return(new SectionIvParser(noticeContent, tedLabelDictionary, noticeLanguage)); case NoticeSection.SectionV: break; case NoticeSection.SectionVi: return(new SectionViParser(noticeContent, tedLabelDictionary, noticeLanguage)); default: throw new ArgumentOutOfRangeException(nameof(noticeSection), noticeSection, null); } throw new ArgumentException("Couldn't create a parser for the given section"); }
public async Task <IActionResult> Create(Notice notice) { if (!ModelState.IsValid) { return(View(notice)); } NoticeSection noticeSectionDb = await _context.NoticeSections.FirstOrDefaultAsync(); noticeSectionDb.Notices = new List <Notice> { notice }; await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public IActionResult Index() { List <Teacher> teachers = _context.Teachers.Where(t => !t.IsDeleted && t.Activeted).Take(4).OrderByDescending(teachers => teachers.Id).ToList(); AboutSection aboutSection = _context.AboutSections.FirstOrDefault(); NoticeSection noticeSection = _context.NoticeSections.Include(n => n.Notices).FirstOrDefault(); List <TestimonialSection> testimonialSection = _context.TestimonialSections.ToList(); HomeVM homeVM = new HomeVM() { Teachers = teachers, AboutSections = aboutSection, NoticeSections = noticeSection, TestimonialSections = testimonialSection }; return(View(homeVM)); }
public async Task <IActionResult> Index(NoticeSection noticeSection) { if (!ModelState.IsValid) { return(View(noticeSection)); } NoticeSection noticeSectionDb = await _context.NoticeSections.FirstOrDefaultAsync(); if (noticeSectionDb == null) { return(NotFound()); } noticeSectionDb.VideoUrl = noticeSection.VideoUrl; await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }