// GET api/<controller>
        public DriveDTO Get([FromUri] string name = "")
        {
            List <String>  FolderList    = new List <string>();
            RDirectoryItem CurrentFolder = new RDirectoryItem();

            string       FolderPath  = string.Empty;
            Member       CurrentUser = db.Members.FirstOrDefault(d => d.Email == User.Identity.Name);
            DriveManager DM          = new DriveManager(CurrentUser, System.Web.Hosting.HostingEnvironment.MapPath(Utility.SiteDriveFolderPath), string.Format("{0}/{1}", Utility.SiteURL, Utility.SiteDriveFolderName));

            DM.ItemDeletable = true;

            if (!string.IsNullOrEmpty(name))
            {
                FolderPath = name;
            }


            FolderList    = FolderPath.Split('/').ToList <string>();
            CurrentFolder = DM.GetFolderName(FolderPath);

            DriveDTO result = new DriveDTO();

            result.Crumbs.AddRange(DM.GetCrumbs(FolderPath));
            result.Directories.AddRange(DM.GetDirectoryItemList(FolderPath));
            result.Files.AddRange(DM.GetFileItemList(FolderPath));

            return(result);
        }
Beispiel #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (CurrentUser.UserType == (byte)MemberTypeType.Admin)
            {
                DM = new DriveManager(CurrentUser, Server.MapPath(Utility.SiteDriveFolderPath),
                                      string.Format("{0}/{1}", Utility.SiteURL, Utility.SiteDriveFolderName));
                DM.ItemDeletable = true;
            }
            else if (CurrentUser.UserType == (byte)MemberTypeType.Author)
            {
                DM = new DriveManager(CurrentUser, Server.MapPath(Utility.SiteDriveFolderPath + "/" + CurrentUser.ID.ToString()),
                                      string.Format("{0}/{1}/{2}", Utility.SiteURL, Utility.SiteDriveFolderName, CurrentUser.ID.ToString()));
                DM.ItemDeletable = true;
                //check if author drive folder exists if not create one.
                DM.VerifyDrive();
            }

            if (Request.QueryString["folderpath"] != null)
            {
                FolderPath = Request.QueryString["folderpath"].ToString().Trim();
            }
            else
            {
                FolderPath = string.Empty;
            }

            FolderList    = FolderPath.Split('/').ToList <string>();
            CurrentFolder = DM.GetFolderName(FolderPath);


            FolderTableRepeater.DataSource = DM.GetDirectoryItemList(FolderPath);
            FolderTableRepeater.DataBind();
            FileItemRepeater.DataSource = DM.GetFileItemList(FolderPath);
            FileItemRepeater.DataBind();
        }
        catch (Exception ex)
        {
            message4.Text     = string.Format("Unable to process request. Error - {0}", ex.Message);
            message4.Visible  = true;
            message4.Indicate = AlertType.Error;
        }
    }