Ejemplo n.º 1
0
 protected void grid_OnRowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "delGalleries")
     {
         var aId = int.Parse(e.CommandArgument.ToString());
         IFolderMediaFacade aFolderMediaFacade = new FolderMediaFacade();
         var aFolderMediaInfo = aFolderMediaFacade.SelectById(aId);
         aFolderMediaFacade.Delete(aFolderMediaInfo);
         grid.DataSource = aFolderMediaFacade.Select();
         grid.DataBind();
     }
 }
Ejemplo n.º 2
0
        protected void btnDelete_OnClick(object sender, EventArgs e)
        {
            var    aUserInfo = (UserInfo)Session["UserInfo"];
            Button btnDelete = (Button)sender;
            //var ImageInfos = new List<ImagesInfo>();
            var imgImage = (HiddenField)btnDelete.Parent.FindControl("hdtemplateId");

            int aFolderId = int.Parse(imgImage.Value);

            IFolderMediaFacade aFolderMediaFacade = new FolderMediaFacade();
            var          aFolderMediaInfo         = aFolderMediaFacade.SelectById(aFolderId);
            ITrashFacade aTrashFacade             = new TrashFacade();
            var          aTrashInfo = new TrashInfo();

            aTrashInfo.TrashDate = DateTime.Now;
            if (!Directory.Exists(Server.MapPath("~/Upload/Trash/") + aUserInfo.UserName + DateTime.Now.ToShortDateString()))
            {
                Directory.CreateDirectory(Server.MapPath("~/Upload/Trash/") + aUserInfo.UserName +
                                          DateTime.Now.ToShortDateString());
            }
            aTrashInfo.TrashFolderName = "/Upload/Trash/" + aUserInfo.UserName +
                                         DateTime.Now.ToShortDateString();

            string filename = aFolderMediaInfo.FolderImage.Replace(ServerHostName(), "");
            string desfile  = Server.MapPath(aTrashInfo.TrashFolderName) + "/" +
                              filename.Split('/')[filename.Split('/')
                                                  .Length - 1].Replace(@"\", "").Replace(@"\", "").Replace(@"\", "");

            if (File.Exists(Server.MapPath(filename)))
            {
                File.Move(Server.MapPath(filename), desfile);
            }
            aTrashInfo.TrashImageLink = aTrashInfo.TrashFolderName + "/" + filename.Split('/')[filename.Split('/').Length - 1];
            aTrashFacade.Insert(aTrashInfo);
            if (Directory.Exists(Server.MapPath("~/" + aFolderMediaInfo.FolderName.Replace("template.html", ""))))
            {
                Directory.Delete(Server.MapPath("~/" + aFolderMediaInfo.FolderName.Replace("template.html", "")), true);
            }
            aFolderMediaFacade.Delete(aFolderMediaInfo);
            dtlListTemplate.DataSource = aFolderMediaFacade.Select();
            dtlListTemplate.DataBind();
        }