コード例 #1
0
        public async Task <IActionResult> Create(AboutWelcome aboutWelcome)
        {
            if (aboutWelcome.Photo == null)
            {
                ModelState.AddModelError("", "Zehmet olmasa şəkil seçin !");
                return(View());
            }
            if (!aboutWelcome.Photo.IsImage())
            {
                ModelState.AddModelError("Photo", "Zehmet olmasa şəkil formati seçin !");
                return(View());
            }
            if (aboutWelcome.Photo.MaxLenght(500))
            {
                ModelState.AddModelError("Photo", "Secilen şəkil olcusu maksimum 500kb olmalidi seçin !");
                return(View());
            }

            aboutWelcome.Image = await aboutWelcome.Photo.SaveImage(_env.WebRootPath, "img/about");

            _db.AboutWelcomes.Add(aboutWelcome);
            await _db.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
コード例 #2
0
        public async Task <IActionResult> Index()
        {
            AboutWelcome          aboutWelcome = _db.AboutWelcomes.FirstOrDefault();
            ICollection <Teacher> teachers     = await _db.Teachers.Include(t => t.TeacherContact).Take(4).ToListAsync();

            AboutSlider aboutSlider = await _db.AboutSliders.FirstOrDefaultAsync();

            AboutVideo aboutVideo = await _db.AboutVideos.FirstOrDefaultAsync();

            ICollection <AboutNotice> aboutNotices = await _db.AboutNotices.Take(6).ToListAsync();

            Bio bio = await _db.Bios.FirstOrDefaultAsync();

            AboutVM aboutVM = new AboutVM()
            {
                AboutWelcome = aboutWelcome,
                Teachers     = teachers,
                Bio          = bio,
                AboutSlider  = aboutSlider,
                AboutVideo   = aboutVideo,
                AboutNotices = aboutNotices
            };

            return(View(aboutVM));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            AboutWelcome FindaboutWelcome = await _db.AboutWelcomes.FindAsync(id);

            if (FindaboutWelcome == null)
            {
                return(NotFound());
            }
            return(View(FindaboutWelcome));
        }
コード例 #4
0
        public async Task <IActionResult> Detail(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            AboutWelcome aboutWelcomeFind = await _db.AboutWelcomes.FindAsync(id);

            if (aboutWelcomeFind == null)
            {
                return(NotFound());
            }
            return(View(aboutWelcomeFind));
        }
コード例 #5
0
        public async Task <IActionResult> DeletePost(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            AboutWelcome aboutWelcomeFind = await _db.AboutWelcomes.FindAsync(id);

            if (aboutWelcomeFind == null)
            {
                return(NotFound());
            }
            PhotoFileDelete.IsDeletePhoto(_env.WebRootPath, "img/about", aboutWelcomeFind.Image);
            _db.AboutWelcomes.Remove(aboutWelcomeFind);
            await _db.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
コード例 #6
0
        public async Task <IActionResult> Edit(int?id, AboutWelcome aboutWelcome)
        {
            AboutWelcome aboutWelcomeFind = await _db.AboutWelcomes.FindAsync(id);

            if (!ModelState.IsValid)
            {
                return(View(aboutWelcomeFind));
            }
            if (aboutWelcome == null)
            {
                return(NotFound());
            }
            if (id == null)
            {
                return(NotFound());
            }

            if (aboutWelcome.Photo != null)
            {
                if (!aboutWelcome.Photo.IsImage())
                {
                    ModelState.AddModelError("Photo", "Zehmet olmasa şəkil formati seçin !");
                    return(View());
                }
                if (aboutWelcome.Photo.MaxLenght(500))
                {
                    ModelState.AddModelError("Photo", "Secilen şəkil olcusu maksimum 500kb olmalidi seçin !");
                    return(View());
                }
                PhotoFileDelete.IsDeletePhoto(_env.WebRootPath, "img/about", aboutWelcomeFind.Image);
                aboutWelcomeFind.Image = await aboutWelcome.Photo.SaveImage(_env.WebRootPath, "img/about");
            }

            aboutWelcomeFind.Title       = aboutWelcome.Title;
            aboutWelcomeFind.Description = aboutWelcome.Description;
            await _db.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
コード例 #7
0
        public async Task <IActionResult> Index()
        {
            ICollection <HomeSlider> homeSliders = await _db.HomeSliders.ToListAsync();

            ICollection <Course> courses = await _db.Courses.Take(3).ToListAsync();

            ICollection <AboutNotice> aboutNotices = await _db.AboutNotices.Take(5).ToListAsync();

            ICollection <Event> events = await _db.Events.Take(4).ToListAsync();

            AboutSlider aboutSliders = await _db.AboutSliders.FirstOrDefaultAsync();

            ICollection <Blog> blogs = await _db.Blogs.Take(3).ToListAsync();

            AboutVideo aboutVideo = await _db.AboutVideos.FirstOrDefaultAsync();

            ICollection <AppUser> appUser = await _userManager.Users.ToListAsync();

            AboutWelcome aboutWelcome = await _db.AboutWelcomes.FirstOrDefaultAsync();

            Bio bio = await _db.Bios.FirstOrDefaultAsync();

            HomeVM homeVM = new HomeVM()
            {
                HomeSliders  = homeSliders,
                AboutWelcome = aboutWelcome,
                Courses      = courses,
                AboutVideo   = aboutVideo,
                AboutNotices = aboutNotices,
                AboutSliders = aboutSliders,
                Events       = events,
                AppUser      = appUser,
                Blogs        = blogs,
                Bio          = bio
            };

            return(View(homeVM));
        }