Ejemplo n.º 1
0
        public ActionResult Index(String c, String u)
        {
            string chemin   = Request.QueryString["chemin"];
            string userName = Request.QueryString["userName"];

            if (chemin == "DisplayFile")
            {
                return(Redirect("DisplayFile"));
            }
            User user = MySession.GetUser();

            if (user != null)
            {
                StorageManager sManager         = StorageManager.Instance;
                var            userStockageFree = user.StockageMax - user.Stockage;

                MySession.SetChemin(chemin);

                FileSystemItem fsi = FileSystemItem.GetElement(chemin, user.Id);
                if (!fsi.IsDir)
                {
                    return(RedirectToAction("DisplayFile"));
                }

                FileSystemItem[] items = fsi.Getchilds().ToArray();
                items                = items.Where(i => i.UserId == user.Id).ToArray();
                ViewBag.User         = user;
                ViewBag.Items        = items;
                ViewBag.Chemin       = chemin;
                ViewBag.UserStockage = sManager.KilobyteToGygabyte(userStockageFree);

                return(View());
            }
            else if (!string.IsNullOrEmpty(chemin) && !string.IsNullOrEmpty(userName))
            {
                MySession.SetChemin(chemin);

                FileSystemItem   fsi   = FileSystemItem.GetElement(chemin, Int32.Parse(userName));
                FileSystemItem[] items = fsi.Getchilds().Where(i => i.Shared).ToArray();

                if (items != null && items.Count() > 0)
                {
                    ViewBag.Items  = items;
                    ViewBag.Chemin = chemin;

                    return(View());
                }
                else if (fsi.IsDir)
                {
                    ViewBag.Items  = items;
                    ViewBag.Chemin = chemin;
                    return(View());
                }
                else
                {
                    return(RedirectToAction("Index", "LandingPage"));
                }
            }
            else
            {
                return(RedirectToAction("Index", "LandingPage"));
            }
        }