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 async Task <IActionResult> Index(AboutSection about)
        {
            if (!ModelState.IsValid)
            {
                return(View(about));
            }
            AboutSection aboutDb = await _context.AboutSections.FirstOrDefaultAsync();

            if (aboutDb == null)
            {
                return(NotFound());
            }

            if (aboutDb.Photo != null)
            {
                if (!aboutDb.Photo.PhotoValidate(ModelState))
                {
                    return(View(about));
                }
                string folder   = Path.Combine("site", "img", "about");
                string fileName = await about.Photo.SaveImage(_env.WebRootPath, folder);

                aboutDb.Image = fileName;
            }
            aboutDb.Title       = about.Title;
            aboutDb.Description = about.Description;

            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
예제 #3
0
 public ActionResult AboutSection(AboutSection aboutSection)
 {
     if (ModelState.IsValid)
     {
         _db.AboutSections.Add(aboutSection);
         _db.SaveChanges();
     }
     return(View());
 }
예제 #4
0
        public async Task <IActionResult> PostAboutSection([FromBody] AboutSection aboutSection)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.AboutSections.Add(aboutSection);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAboutSection", new { id = aboutSection.Id }, aboutSection));
        }
예제 #5
0
        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));
        }
예제 #6
0
        public IActionResult Index()
        {
            Header         header      = _context.Headers.First();
            AboutSection   about       = _context.AboutSections.First();
            List <Service> service     = _context.Services.ToList();
            var            testimonial = _context.Testimonials.ToList();
            var            blog        = _context.Blogs.ToList();
            List <Brands>  brand       = _context.Brands.ToList();
            HomeVM         homeVM      = new HomeVM()
            {
                Header       = header,
                AboutSection = about,
                Services     = service,
                Testimonials = testimonial,
                Blogs        = blog,
                Brands       = brand
            };

            return(View(homeVM));
        }
예제 #7
0
        public async Task <IActionResult> PutAboutSection([FromRoute] int id, [FromBody] AboutSection aboutSection)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != aboutSection.Id)
            {
                return(BadRequest());
            }

            _context.Entry(aboutSection).State = EntityState.Modified;

            foreach (var p in aboutSection.Paragraphs)
            {
                _context.Entry(p).State = EntityState.Modified;
            }
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AboutSectionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #8
0
        public async Task <IActionResult> PostWebsite([FromBody] Website website)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            _context.Websites.Add(website);
            Website newWebsite = new Website()
            {
                Id = website.Id, Name = website.Name, WebsiteUrl = website.WebsiteUrl
            };

            HomeSection newhome = new HomeSection()
            {
                Header = website.Name + "Head",
                // BackgroundImageUrl = website.Name + "bg url",
                Paragraphs = new List <Paragraph>()
                {
                    new Paragraph()
                    {
                        Text = "Home Para 1"
                    },
                    new Paragraph()
                    {
                        Text = "Home Para 2"
                    }
                },
                WebsiteId = website.Id,
                isActive  = true
            };

            _context.HomeSections.Add(newhome);
            AboutSection newabout = new AboutSection()
            {
                Header     = website.Name + " about",
                Paragraphs = new List <Paragraph>()
                {
                    new Paragraph()
                    {
                        Text = "about Para 1"
                    },
                    new Paragraph()
                    {
                        Text = "about Para 2"
                    }
                },
                WebsiteId = website.Id,
                isActive  = true
            };

            _context.AboutSections.Add(newabout);
            DownloadSection newdownload = new DownloadSection()
            {
                Header             = website.Name + " download",
                BackgroundImageUrl = "assets/img/downloads-bg.jpg",
                Paragraphs         = new List <Paragraph>()
                {
                    new Paragraph()
                    {
                        Text = "download Para 1"
                    },
                    new Paragraph()
                    {
                        Text = "download Para 2"
                    }
                },
                WebsiteId = website.Id,
                isActive  = true
            };

            _context.DownloadSections.Add(newdownload);
            ContactUsSection newcontactus = new ContactUsSection()
            {
                Header     = website.Name + " contactus",
                Paragraphs = new List <Paragraph>()
                {
                    new Paragraph()
                    {
                        Text = "contactus Para 1"
                    }
                },
                WebsiteId = website.Id,
                isActive  = true
            };

            _context.ContactUsSections.Add(newcontactus);
            List <SocialPortal> socials = new List <SocialPortal>()
            {
                new SocialPortal()
                {
                    SocialTypeId = 1, url = "facebook url", ContactUsId = newcontactus.Id
                }
            };

            newcontactus.SocialPortals = socials;

            //website.home = newhome;
            await _context.SaveChangesAsync();

            CreatedAtActionResult car = CreatedAtAction("GetWebsite", new { id = newWebsite.Id }, newWebsite);

            return(car);
            //if (!ModelState.IsValid)
            //{
            //    return BadRequest(ModelState);
            //}
            //_context.Websites.Add(website);
            //await _context.SaveChangesAsync();
            //return CreatedAtAction("GetWebsite", new { id = website.Id }, website);
        }