Esempio n. 1
0
        public ActionResult PhotosAdd(int id, HttpPostedFileBase fileUpload)
        {
            if (fileUpload != null)
            {
                Image img = Image.FromStream(fileUpload.InputStream);

                Bitmap bm  = new Bitmap(img, AppTools.MeqaleBoyuk);
                Bitmap bm2 = new Bitmap(img, AppTools.MeqaleOrta);
                Bitmap bm3 = new Bitmap(img, AppTools.MeqaleKicik);

                string way  = "/Content/MeqaleSekil/BoyukYol/" + Guid.NewGuid() + Path.GetExtension(fileUpload.FileName);
                string way2 = "/Content/MeqaleSekil/OrtaYol/" + Guid.NewGuid() + Path.GetExtension(fileUpload.FileName);
                string way3 = "/Content/MeqaleSekil/KicikYol/" + Guid.NewGuid() + Path.GetExtension(fileUpload.FileName);

                bm.Save(Server.MapPath(way));
                bm2.Save(Server.MapPath(way2));
                bm3.Save(Server.MapPath(way3));

                PhotosForMeqale p = new PhotosForMeqale();
                p.BoyukYol = way;
                p.OrtaYol  = way2;
                p.KicikYol = way3;
                p.IsActive = true;
                p.MeqaleID = id;


                PhotoForMeqaleORM.Current.Insert(p);

                return(View(1));
            }
            return(View(0));
        }
Esempio n. 2
0
        public ActionResult SekilSil(int photoId)
        {
            PhotosForMeqale p = PhotoForMeqaleORM.Current.SelectById(photoId).Data[0];

            p.IsActive     = false;
            p.KategoriyaID = null;
            int b = (int)p.MeqaleID;

            string mainPath  = /*@"C:/Users/hp2015/source/repos/MyBlog/MyBlog" + */ p.BoyukYol;
            string mainPath2 = /*@"C:/Users/hp2015/source/repos/MyBlog/MyBlog" +*/ p.OrtaYol;
            string mainPath3 = /* @"C:/Users/hp2015/source/repos/MyBlog/MyBlog" +*/ p.KicikYol;

            string path  = Server.MapPath(mainPath);
            string path2 = Server.MapPath(mainPath2);
            string path3 = Server.MapPath(mainPath3);

            FileInfo fi  = new FileInfo(path);
            FileInfo fi2 = new FileInfo(path2);
            FileInfo fi3 = new FileInfo(path3);

            fi.Delete();
            fi2.Delete();
            fi3.Delete();

            //string[] Files = Directory.GetFiles(mainPath);
            //string[] Files2 = Directory.GetFiles(mainPath2);
            //string[] Files3 = Directory.GetFiles(mainPath3);

            //foreach (string item in Files)
            //{
            //    System.IO.File.Delete(item);
            //}
            //foreach (string item in Files2)
            //{
            //    System.IO.File.Delete(item);
            //}
            //foreach (string item in Files3)
            //{
            //    System.IO.File.Delete(item);
            //}

            //System.IO.File.Delete(mainPath);
            //System.IO.File.Delete(mainPath2);
            //System.IO.File.Delete(mainPath3);

            bool a = PhotoForMeqaleORM.Current.Delete(p).Data;

            if (a == false)
            {
                return(View(0));
            }

            return(RedirectToAction("Sekil", "Meqale", new { id = b }));
        }