Exemple #1
0
        public ActionResult Index(string category = "", int page = 1, string orderBy = "dateCreated", string asc = "false", Guid? owner = null)
        {
            page = page - 1;
            HomeViewModel model = new HomeViewModel();
            IQueryable<Photo> allPhotos = null;
            model.Page = page + 1;

            if (String.IsNullOrEmpty(category))
            {
                allPhotos = Session.Query<Photo>();
            }
            else
            {
                allPhotos = Session.Query<Photo>().Where(x => x.Category == category);
            }
            if (orderBy == "dateCreated")
            {
                //if (asc == "false")
                //    allPhotos = allPhotos.OrderByDescending(x => x.DateCreated);
                //else
                //    allPhotos = allPhotos.OrderBy(x => x.DateCreated);
            }
            else
            {
                //if (asc == "false")
                //    allPhotos = allPhotos.OrderByDescending(x => x.Likes.Count);
                //else
                //    allPhotos = allPhotos.OrderBy(x => x.Likes.Count);
            }
            model.AllPhotos = allPhotos.OrderByDescending(X => X.DateCreated).ToList();

            model.MaxPages = (int)Math.Ceiling(allPhotos.Count() / 12.0);
            return View(model);
        }
Exemple #2
0
 public ActionResult Login(HomeViewModel model, string returnUrl = "")
 {
     this.TryUpdateModel(model);
     if (this.ModelState.IsValid)
     {
         MvcApplication.SecurityManager.AuthenticateUser(model.LoginUserName, model.LoginPassword);
     }
     if (MvcApplication.SecurityManager.AuthenticatedUser == null)
     {
         return RedirectToAction("Login", "Home", new { error = "true", returnUrl = returnUrl });
     }
     else
     {
         if (string.IsNullOrEmpty(returnUrl))
             return Redirect("~/");
         return Redirect(returnUrl);
     }
 }