Example #1
0
        public ActionResult DosyaGuncelle(monthtable p1)
        {
            var dosyalar = db.monthtables.Find(p1.id);
            var zaman    = p1.datetime;

            if (p1.monthphotourl != null)
            {
                var image = Request.Files[0];

                if ((5 * 1024 * 1024) < image.ContentLength)
                {
                    throw new Exception("hata mesaaji");
                }

                var fileInfo = new FileInfo(image.FileName);
                var pic      = "pic_" + DateTime.Now.Ticks + fileInfo.Extension; //new file name

                var filePath = "/Photos/monthphotos/" + pic;                     //sen bunu db'ye yaz..

                var tempFilePath = Server.MapPath("~\\Photos\\monthphotos\\" + pic);

                image.SaveAs(tempFilePath);

                dosyalar.monthphotourl = filePath;
            }

            dosyalar.monthname = p1.monthname;
            dosyalar.datetime  = Convert.ToDateTime(zaman);
            db.SaveChanges();
            return(RedirectToAction("DosyaAdi"));
        }
Example #2
0
        public ActionResult YeniDosyaAdi(string monthname, string monthphotourl, string datetime, int isaktif)
        {
            string zaman = datetime;
            var    ekle  = new monthtable
            {
                monthname     = monthname,
                monthphotourl = monthphotourl,
                datetime      = Convert.ToDateTime(zaman),
                isaktif       = isaktif,
            };

            if (monthphotourl != null)
            {
                var image = Request.Files[0];



                var fileInfo = new FileInfo(image.FileName);
                var pic      = "pic_" + DateTime.Now.Ticks + fileInfo.Extension; //new file name

                var filePath = "/Photos/monthphotos/" + pic;                     //sen bunu db'ye yaz..

                var tempFilePath = Server.MapPath("~\\Photos\\monthphotos\\" + pic);

                image.SaveAs(tempFilePath);

                ekle.monthphotourl = filePath;
            }

            db.monthtables.Add(ekle);
            db.SaveChanges();
            return(RedirectToAction("DosyaAdi"));
        }