Ejemplo n.º 1
0
 public ActionResult GetByKeywords(string search, int page = 1)
 {
     try
     {
         if (search == null)
         {
             return(RedirectToAction("Index", "Home"));
         }
         var sonuc = new Repository.ArticleRepo()
                     .Queryable()
                     .Where(x => x.Header.Contains(search) ||
                            x.User.UserName.Contains(search) ||
                            x.User.Surname.Contains(search) ||
                            x.Content.Contains(search) ||
                            x.Category.CategoryName.Contains(search)).ToList();
         ViewBag.count = sonuc.Count();
         var model = sonuc.Skip((page - 1) * 5).Take(5).ToList();
         if (model.Count == 0)
         {
             return(RedirectToAction("Index", "Home"));
         }
         return(View(model));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
Ejemplo n.º 2
0
        // GET: Home
        public ActionResult Index(int page = 1)
        {
            var pageSize = 5;
            var model    = new Repository.ArticleRepo().Queryable().Where(x => x.Confirmed == true).OrderByDescending(x => x.AddDate).Skip((page - 1) * pageSize).Take(pageSize).ToList();
            var count    = new Repository.ArticleRepo().GetAll().Count;

            ViewBag.count = count;
            return(View(model));
        }
Ejemplo n.º 3
0
        public ActionResult GetByCatId(int id, int page = 1)
        {
            var sonuc = new Repository.ArticleRepo().Queryable().Where(x => x.CategoryId == id).ToList();

            ViewBag.Count = sonuc.Count;
            var model = sonuc.Skip((page - 1) * 5).Take(5).ToList();

            return(View(model));
        }
Ejemplo n.º 4
0
        public ActionResult EditUsers()
        {
            var popular = new Repository.ArticleRepo().Queryable().Where(x => x.Confirmed == true).OrderByDescending(x => x.LikeCount).Take(5).ToList();

            ViewBag.popular = popular;
            var userStore   = MembershipTools.NewUserStore();
            var userManager = new UserManager <ApplicationUser>(userStore);
            var model       = userManager.Users.ToList();

            return(View(model));
        }
Ejemplo n.º 5
0
 public ActionResult ConfirmArticles(int page = 1)
 {
     try
     {
         var pageSize = 5;
         var model    = new Repository.ArticleRepo().Queryable().Where(x => x.Confirmed == false).OrderByDescending(x => x.AddDate).Skip((page - 1) * pageSize).Take(pageSize).ToList();
         ViewBag.count = new Repository.ArticleRepo().Queryable().Where(x => x.Confirmed == false).Count();
         return(View(model));
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("", ex.Message);
         return(RedirectToAction("Index", "Home"));
     }
 }
Ejemplo n.º 6
0
        public async Task <ActionResult> Profile()
        {
            var popular = new Repository.ArticleRepo().Queryable().Where(x => x.Confirmed == true).OrderByDescending(x => x.LikeCount).Take(5).ToList();

            ViewBag.popular = popular;
            var userManeger = MembershipTools.NewUserManager();
            var user        = await userManeger.FindByIdAsync(HttpContext.User.Identity.GetUserId());

            var model        = new ProfilePasswordMultiViewModel();
            var modelProfile = new ProfileViewModel()
            {
                Email        = user.Email,
                Name         = user.Name,
                Bio          = user.Bio,
                PhotoURL     = user.PhotoURL,
                Surname      = user.Surname,
                UserName     = user.UserName,
                RegisterDate = user.RegisterDate
            };

            model.ProfileViewModel = modelProfile;
            return(View(model));
        }