public ActionResult Index(int page = 1)
        {
            ViewModelEduhome models = new ViewModelEduhome();

            models.Setting     = db.Settings.FirstOrDefault();
            models.SocialLinks = db.SocialLinks.ToList();
            models.BgImage     = db.BgImages.FirstOrDefault();
            models.Blogs       = db.Blogs.Include("BlogCategory").OrderByDescending(o => o.Id).Take(3).ToList();

            ViewModelBlogCategory vmbc = new ViewModelBlogCategory();

            vmbc.Blogs = db.Blogs.ToList();

            ViewModelBlog vmb = new ViewModelBlog();

            vmb.CurrentPage = page;
            vmb.PageCount   = Convert.ToInt32(Math.Ceiling(db.Blogs.Count() / 4.0));
            vmb.Blogs       = db.Blogs.Include("Admin").OrderByDescending(o => o.Id).Skip((page - 1) * 4).Take(4).ToList();


            models.BlogCategories        = db.BlogCategories.ToList();
            models.BlogComments          = db.BlogComments.ToList();
            models.Tags                  = db.Tags.ToList();
            models.ViewModelBlog         = vmb;
            models.ViewModelBlogCategory = vmbc;

            return(View(models));
        }
        public ActionResult Index(ViewModelEduhome vme)
        {
            if (ModelState.IsValid)
            {
                User loginner = db.Users.FirstOrDefault(u => u.Username == vme.UserLogin.Username);

                if (loginner != null)
                {
                    if (Crypto.VerifyHashedPassword(loginner.Password, vme.UserLogin.Password))
                    {
                        Session["Loginner"]   = loginner;
                        Session["LoginnerId"] = loginner.Id;

                        return(RedirectToAction("Index", "Home"));
                    }
                    else
                    {
                        ModelState.AddModelError("Password", "Incorrect Password!");
                    }
                }
                else
                {
                    ModelState.AddModelError("Username", "Incorrect Username!");
                }
            }

            ViewModelEduhome models = new ViewModelEduhome();

            models.Setting     = db.Settings.FirstOrDefault();
            models.SocialLinks = db.SocialLinks.ToList();
            models.BgImage     = db.BgImages.FirstOrDefault();

            return(View(models));
        }
        public ActionResult Index()
        {
            ViewModelEduhome models = new ViewModelEduhome();

            models.Setting     = db.Settings.FirstOrDefault();
            models.SocialLinks = db.SocialLinks.ToList();
            models.BgImage     = db.BgImages.FirstOrDefault();

            return(View(models));
        }
        public ActionResult Index()
        {
            ViewModelEduhome models = new ViewModelEduhome();

            models.Setting     = db.Settings.FirstOrDefault();
            models.SocialLinks = db.SocialLinks.ToList();
            models.SocialTeams = db.SocialTeams.ToList();
            models.Teachers    = db.Teachers.Include("TeacherProfession").ToList();
            models.BgImage     = db.BgImages.FirstOrDefault();
            return(View(models));
        }
Esempio n. 5
0
        public ActionResult Index()
        {
            ViewModelEduhome models = new ViewModelEduhome();

            models.Setting         = db.Settings.FirstOrDefault();
            models.SocialLinks     = db.SocialLinks.ToList();
            models.BgImage         = db.BgImages.FirstOrDefault();
            models.Events          = db.Events.Include("EventCategory").ToList();
            models.EventCategories = db.EventCategories.ToList();
            models.Blogs           = db.Blogs.Include("Admin").Include("BlogCategory").OrderByDescending(o => o.Id).Take(3).ToList();
            models.Tags            = db.Tags.ToList();
            return(View(models));
        }
        public ActionResult CourseDetails(int id)
        {
            ViewModelEduhome models = new ViewModelEduhome();

            models.Setting          = db.Settings.FirstOrDefault();
            models.SocialLinks      = db.SocialLinks.ToList();
            models.Course           = db.Courses.Find(id);
            models.Courses          = db.Courses.ToList();
            models.CourseCategories = db.CourseCategories.ToList();
            models.CourseComments   = db.CourseComments.ToList();
            models.BgImage          = db.BgImages.FirstOrDefault();
            models.Blogs            = db.Blogs.Include("Admin").OrderByDescending(o => o.Id).Take(3).ToList();
            models.Tags             = db.Tags.ToList();
            return(View(models));
        }
        public ActionResult Index()
        {
            ViewBag.Page = "About";

            ViewModelEduhome models = new ViewModelEduhome();

            models.Setting         = db.Settings.FirstOrDefault();
            models.SocialLinks     = db.SocialLinks.ToList();
            models.About           = db.Abouts.FirstOrDefault();
            models.BgImage         = db.BgImages.FirstOrDefault();
            models.SocialTeams     = db.SocialTeams.ToList();
            models.Teachers        = db.Teachers.Include("TeacherProfession").Take(4).ToList();
            models.StudentFeedback = db.StudentFeedbacks.FirstOrDefault();
            models.NoticeBoards    = db.NoticeBoards.ToList();
            return(View(models));
        }
Esempio n. 8
0
        public ActionResult Index()
        {
            ViewBag.Page = "Home";

            ViewModelEduhome models = new ViewModelEduhome();

            models.Setting         = db.Settings.FirstOrDefault();
            models.SocialLinks     = db.SocialLinks.ToList();
            models.Homes           = db.Homes.ToList();
            models.About           = db.Abouts.FirstOrDefault();
            models.Courses         = db.Courses.Take(3).ToList();
            models.NoticeBoards    = db.NoticeBoards.ToList();
            models.StudentFeedback = db.StudentFeedbacks.FirstOrDefault();
            models.Events          = db.Events.Take(4).ToList();
            models.Blogs           = db.Blogs.Include("Admin").Take(3).ToList();
            models.BlogComments    = db.BlogComments.ToList();
            return(View(models));
        }
        public ActionResult Index(ViewModelEduhome vme)
        {
            if (ModelState.IsValid)
            {
                if (db.Users.Any(u => u.Email == vme.UserRegister.Email))
                {
                    ModelState.AddModelError("Email", "This Email is already in use");
                }

                if (db.Users.Any(u => u.Username == vme.UserRegister.Username))
                {
                    ModelState.AddModelError("Username", "This Username is already in use");
                }

                User User = new User();
                User.Name        = vme.UserRegister.Name;
                User.Surname     = vme.UserRegister.Surname;
                User.Email       = vme.UserRegister.Email;
                User.Username    = vme.UserRegister.Username;
                User.PhoneNumber = vme.UserRegister.PhoneNumber;
                User.CreatedDate = DateTime.Now;
                User.Password    = Crypto.HashPassword(vme.UserRegister.Password);

                db.Users.Add(User);
                db.SaveChanges();
                return(RedirectToAction("Index", "Login"));
            }

            ViewModelEduhome models = new ViewModelEduhome();

            models.Setting     = db.Settings.FirstOrDefault();
            models.SocialLinks = db.SocialLinks.ToList();
            models.BgImage     = db.BgImages.FirstOrDefault();


            return(View(models));
        }