public void CanCiz(Tank tank1, Tank tank2)
        {
            if (canZaman > 5.0f && (!tank1.oyunBitti && !tank2.oyunBitti))
            {
                Resim.Ciz(can, canx - ortala, cany - ortala, ozellikBuyukluk, ozellikBuyukluk, ozellikDonus);

                if (cany + 35 > tank1.y && cany + 35 < tank1.y + 70 && canx + 35 > tank1.x && canx + 35 < tank1.x + 35 * 2)
                {
                    SFMLSes.Ses.SesCal(canSes);
                    tank1.Can -= 20;
                    canZaman   = 0;
                }
                if (cany + 35 > tank2.y && cany + 35 < tank2.y + 70 && canx + 35 > tank2.x && canx + 35 < tank2.x + 35 * 2)
                {
                    SFMLSes.Ses.SesCal(canSes);
                    tank2.Can -= 20;
                    canZaman   = 0;
                }
            }
            else
            {
                do
                {
                    canx = r.Next(50, 1180);
                    cany = r.Next(10, 760);
                } while (canx + 35 * 2 > 550 && canx < 670 + 35 * 2 && cany + 35 * 2 > 325 && cany < 445 + 35 * 2);
            }
            canZaman += Resim.FrameTime;
        }
Example #2
0
        public ActionResult MarkaEkle(Marka mrk, HttpPostedFileBase fileUpload)
        {
            int resimId = -1;

            if (fileUpload != null)
            {
                Image  img    = Image.FromStream(fileUpload.InputStream);
                int    width  = Convert.ToInt32(ConfigurationManager.AppSettings["MarkaWidth"].ToString());
                int    height = Convert.ToInt32(ConfigurationManager.AppSettings["MarkaHeight"].ToString());
                string name   = "/Content/MarkaResim/" + Guid.NewGuid() + Path.GetExtension(fileUpload.FileName);
                //resim çektiğimiz yer, resmin uzantısını alır.
                Bitmap bm = new Bitmap(img, width, height);
                bm.Save(Server.MapPath(name));
                Resim rsm = new Resim(); //resim tanımladık
                rsm.OrtaYol = name;
                Context.Baglanti.Resims.Add(rsm);
                Context.Baglanti.SaveChanges();
                if (rsm.Id != null)
                {
                    resimId = rsm.Id;
                }
            }
            if (resimId != -1)
            {
                mrk.ResimId = resimId;
            }
            Context.Baglanti.Markas.Add(mrk);
            Context.Baglanti.SaveChanges();
            return(RedirectToAction("Markalar"));
        }
Example #3
0
                public static void ResimYukle(HttpPostedFile Dosya, int Genislik, int Yukseklik, string Yol)
                {
                    Bitmap Resim = new Bitmap(Dosya.InputStream);

                    if (Resim.Width > Genislik || Resim.Height > Yukseklik)
                    {
                        Size   ebatlar = new Size(Resim.Width, Resim.Height);
                        double oran    = ((double)Resim.Width / (double)Resim.Height);
                        if (Resim.Width > Genislik && Genislik > 0)
                        {
                            ebatlar.Width  = Genislik;
                            ebatlar.Height = (int)((double)Genislik / oran);
                        }
                        if (ebatlar.Height > Yukseklik && Yukseklik > 0)
                        {
                            ebatlar.Height = Yukseklik;
                            ebatlar.Width  = (int)((double)Yukseklik * oran);
                        }
                        Resim = new Bitmap(Resim, ebatlar);
                    }

                    if (Dosya.ContentType == "image/jpeg" || Dosya.ContentType == "image/pjpeg")
                    {
                        Resim.Save(Yol, System.Drawing.Imaging.ImageFormat.Jpeg);
                    }
                    else if (Dosya.ContentType == "image/gif")
                    {
                        Resim.Save(Yol, System.Drawing.Imaging.ImageFormat.Gif);
                    }
                    else if (Dosya.ContentType == "image/png" || Dosya.ContentType == "image/x-png")
                    {
                        Resim.Save(Yol, System.Drawing.Imaging.ImageFormat.Png);
                    }
                    Resim.Dispose();
                }
Example #4
0
        public ActionResult YaziEkle(Yazi yazi, HttpPostedFileBase resim)
        {
            using (BlogSiteEntities1 db = new BlogSiteEntities1())
            {
                Image  img       = Image.FromStream(resim.InputStream);
                Bitmap kckResim  = new Bitmap(img, Settings.ResimKucukBoyut);
                Bitmap ortaResim = new Bitmap(img, Settings.ResimOrtaBoyut);
                Bitmap bykResim  = new Bitmap(img, Settings.ResimBuyukBoyut);

                kckResim.Save(Server.MapPath("/Content/YaziResim/KucukBoyut/" + resim.FileName));
                ortaResim.Save(Server.MapPath("/Content/YaziResim/OrtaBoyut/" + resim.FileName));
                bykResim.Save(Server.MapPath("/Content/YaziResim/BuyukBoyut/" + resim.FileName));

                Resim rsm = new Resim();
                rsm.BuyukBoyut = "/Content/YaziResim/BuyukBoyut/" + resim.FileName;
                rsm.OrtaBoyut  = "/Content/YaziResim/OrtaBoyut/" + resim.FileName;
                rsm.KucukBoyut = "/Content/YaziResim/KucukBoyut/" + resim.FileName;

                db.Resim.Add(rsm);
                db.SaveChanges();
                yazi.ResimID       = rsm.ResimID;
                yazi.EklenmeTarihi = DateTime.Now;
                int yzrId = db.Yazar.FirstOrDefault(x => x.KullaniciAdi == User.Identity.Name).YazarID;
                yazi.YazarID = yzrId;
                db.Yazi.Add(yazi);
                db.Configuration.LazyLoadingEnabled = false;
                db.SaveChanges();


                return(RedirectToAction("Index"));
            }
        }
Example #5
0
        public ActionResult AddProduct(Food u, HttpPostedFileBase fileUpload)
        {
            int resimId = -1;

            if (fileUpload != null)
            {
                Image img    = Image.FromStream(fileUpload.InputStream);
                int   width  = Convert.ToInt32(ConfigurationManager.AppSettings["MarkaWidth"].ToString());
                int   height = Convert.ToInt32(ConfigurationManager.AppSettings["MarkaHeight"].ToString());

                string name = "/Content/UrunResim/" + Guid.NewGuid() + Path.GetExtension(fileUpload.FileName);

                Bitmap bm = new Bitmap(img, width, height);
                bm.Save(Server.MapPath(name));

                Resim rsm = new Resim();
                rsm.OrtaYol = name;
                ctx.Resims.Add(rsm);
                ctx.SaveChanges();
                if (rsm.Id != 0)
                {
                    resimId = rsm.Id;
                }
            }
            if (resimId != -1)
            {
                u.ResimID = resimId;
            }

            ctx.Foods.Add(u);
            ctx.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #6
0
 public void MermiHakkiYaz(string isim, int x, int y, Tank tank)
 {
     if (zaman > 0.1f && tank.mermiHakki <= 0)
     {
         tank.mermiHakki--;
         zaman = 0;
     }
     if (tank.mermiHakki <= 0 || tank.ozelGucDurum)
     {
         if (tank.mermiHakki % 2 == 0 || tank.ozelGucDurum)
         {
             if (tank.ozelGucDurum)
             {
                 Resim.YaziYaz("SINIRSIZ MERMI", x, y - 30, 50);
             }
             else
             {
                 Resim.YaziYaz("MERMINIZ BITTI", x, y - 30, 50);
                 Resim.YaziYaz(isim, x + 100, y + 20, 25);
             }
         }
     }
     else
     {
         Resim.YaziYaz("KALAN MERMI SAYISI = " + " " + tank.mermiHakki.ToString(), x, y - 30, 30);
         Resim.YaziYaz(isim, x, y, 20);
     }
     if (tank.mermiHakki <= 0)
     {
         zaman += Resim.FrameTime;
     }
 }
Example #7
0
        public ActionResult Edit(FormCollection collection, Resim resim, HttpPostedFileBase Adi)
        {
            try
            {
                resim.Adi = collection["resimAdi"];

                if (Adi != null)
                {
                    ResimSil(resim.Adi);

                    string resimAdi = ImageLibrary.Images.GetImageName(Path.GetExtension(Adi.FileName));
                    Adi.SaveAs(Server.MapPath("~/Content/Products/Sayfa/" + resimAdi));
                    resim.Adi = resimAdi;
                }

                _imageRepository.Update(resim);
                Successful(this, "Banner kaydı başarı ile güncellendi.");

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                Error(this, ex.ToString());
                SiteDileri();
                return(View(resim));
            }
        }
Example #8
0
        public ActionResult kullaniciKayit(Kullanicilar kullaniciVeri, HttpPostedFileBase resim)
        {
            var k = db.Kullanicilar.FirstOrDefault(x => x.kullaniciAdi == kullaniciVeri.kullaniciAdi);

            if (k == null)
            {
                Kullanicilar yeniKullanici = new Kullanicilar();
                yeniKullanici = kullaniciVeri;

                if (resim != null)
                {
                    Image  img = Image.FromStream(resim.InputStream);
                    string url = "/images/" + Guid.NewGuid() + Path.GetExtension(resim.FileName);
                    img.Save(Server.MapPath(url));

                    Resim yeniRsm = new Resim();
                    yeniRsm.resimUrl = url;
                    db.Resim.Add(yeniRsm);
                    db.SaveChanges();
                    yeniKullanici.resimID = yeniRsm.resimID;
                    db.Kullanicilar.Add(yeniKullanici);
                    db.SaveChanges();
                }
                TempData["a"] = kullaniciVeri.ad + " İsimli Kullanıcı Kaydedildi .";
            }
            else
            {
                TempData["a"] = kullaniciVeri.kullaniciAdi + " Kullanıcı Adı Kullanılıyor .";
            }
            return(RedirectToAction(""));
        }
Example #9
0
 public void KalkanCiz()
 {
     if (kalkanDurum)
     {
         Resim.Ciz(kalkan, x - 45, y - 25, 150, 150);
     }
 }
Example #10
0
        public ActionResult MarkaEkle(Marka mrk, HttpPostedFileBase fileUpload)
        {
            int resimId = -1;

            if (fileUpload != null)
            {
                Image img    = Image.FromStream(fileUpload.InputStream);
                int   width  = Convert.ToInt32(ConfigurationManager.AppSettings["MarkaResimWidth"].ToString());  //Web Config de <add key="DegerİsmiYazılır" value="Deger Atanır" şeklinde eklediğimiz width ve height leri burak ConfigurationManager.AppSettings ile ulaşarak int değer içine atadık/>
                int   height = Convert.ToInt32(ConfigurationManager.AppSettings["MarkaResimHeight"].ToString()); //Web Config de <add key="DegerİsmiYazılır" value="Deger Atanır" şeklinde eklediğimiz width ve height leri burak ConfigurationManager.AppSettings ile ulaşarak int değer içine atadık/>

                // Guid 24 basamaklı eşi benzeri olmayan bir string ifade verir
                string name = "/Content/MarkaResim/" + Guid.NewGuid() + Path.GetExtension(fileUpload.FileName);

                Bitmap bm = new Bitmap(img, width, height);
                bm.Save(Server.MapPath(name));

                Resim rsm = new Resim();

                rsm.OrtaYol = name;
                Context.Baglanti.Resim.Add(rsm);
                Context.Baglanti.SaveChanges();
                if (rsm.Id != null)
                {
                    resimId = rsm.Id;
                }
            }
            if (resimId != -1)
            {
                mrk.ResimID = resimId;
            }
            Context.Baglanti.Marka.Add(mrk);
            Context.Baglanti.SaveChanges();
            return(RedirectToAction("Markalar"));
        }
Example #11
0
        public ActionResult ResimEkle(Resimler resim, int urunid)
        {
            //Her resim için yükleme işlemini yap
            foreach (var dosya in resim.Dosyalar)
            {
                if (dosya.ContentLength > 0)
                {
                    //Her resim dosyası benzersiz bir isme sahip olması için Guid metodu kullanılıyor
                    //Gelen her resim dosyası, resimler klasörüne kaydediliyor
                    var dosyaAdi = Guid.NewGuid() + Path.GetExtension(dosya.FileName);
                    var adres    = Path.Combine(Server.MapPath("~/Resimler"), dosyaAdi);
                    dosya.SaveAs(adres);

                    //Klasöre kaydedilen resim, veritabanına da kaydediliyor
                    Resim rsm = new Resim();
                    rsm.UrunID   = urunid;
                    rsm.ResimAdi = dosyaAdi;
                    db.Resim.Add(rsm);
                }
                else
                {
                    ViewBag.Mesaj = "Resim yükleme yapılamadı";
                    return(View());
                }
            }
            db.SaveChanges();
            return(RedirectToAction("Index")); //Urun listeleme sayfasına geri dön
        }
 public void Insert(Resim resim)
 {
     using (Database db = new Database())
     {
         db.Insert("Resim", "Id", resim);
     }
 }
 public void TekrarOyna(Tank tank1, Tank tank2)
 {
     if (Resim.KeyPressed(SFML.Window.Keyboard.Key.Return) && (tank1.oyunBitti || tank2.oyunBitti))
     {
         tank1.oyunBitti     = false;
         tank2.oyunBitti     = false;
         tank1.Can           = 0;
         tank2.Can           = 0;
         tank1.mermiHakki    = 30;
         tank2.mermiHakki    = 30;
         tank1.x             = 400;
         tank1.y             = 400;
         tank2.x             = 800;
         tank2.y             = 400;
         tank1.rotation      = 0;
         tank2.rotation      = 0;
         ozelGucZaman        = 0;
         kontrolZaman        = 0;
         kalkanDurum         = false;
         ozellikBuyuklukSoru = false;
         tank1.kutuAcik      = true;
         tank2.kutuAcik      = true;
         tank1.cerceveSoru   = false;
         tank2.cerceveSoru   = false;
         tank1.ozelGucDurum  = false;
         tank2.ozelGucDurum  = false;
         tank1.kutuDurum     = false;
         tank2.kutuDurum     = false;
         tank1.kalkanDurum   = false;
         tank2.kalkanDurum   = false;
         canZaman            = 0;
         mermiZaman          = 0;
     }
 }
        public void OzelGucCiz(Tank tank1, Tank tank2)
        {
            ozelGunEffectAnimNo += 15 * Resim.FrameTime;
            ozelGunEffectAnimNo  = ozelGunEffectAnimNo > 15 ? 0 : ozelGunEffectAnimNo;

            if (!tank1.ozelGucDurum && !tank2.ozelGucDurum)
            {
                ozelGucAnimNo = ozelGucAnimNo > 13 ? 0 : ozelGucAnimNo;
                Resim.Ciz(ozelGuc[(int)ozelGucAnimNo], 580, 362, 125, 150);
                ozelGucAnimNo += 15 * Resim.FrameTime;
            }
            if (tank1.ozelGucDurum)
            {
                Resim.Ciz(ozelGucEffect[(int)ozelGunEffectAnimNo], tank1.x - 100, tank1.y - 70, 250, 250);
            }
            if (tank2.ozelGucDurum)
            {
                Resim.Ciz(ozelGucEffect[(int)ozelGunEffectAnimNo], tank2.x - 45, tank2.y - 25, 150, 150);
            }



            if (362 + 35 > tank1.y && 362 + 35 < tank1.y + 70 && 580 + 35 > tank1.x && 580 + 35 < tank1.x + 35 * 2 && !tank2.ozelGucDurum)
            {
                SFMLSes.Ses.SesCal(kukre);
                tank1.ozelGucDurum = true;
                tank1.x            = 400;
                tank1.y            = 400;
                tank2.x            = 800;
                tank2.y            = 400;
                tank1.rotation     = 0;
                tank2.rotation     = 0;
                tank1.kutuAcik     = true;
                tank1.kutuCan      = 3;
                do
                {
                    tank1.kutuX = tank2.kutuX = r.Next(50, 1180);
                    tank1.kutuY = tank2.kutuY = r.Next(10, 760);
                } while (tank1.kutuX + 35 * 2 > 550 && tank1.kutuX < 670 + 35 * 2 && tank1.kutuY + 35 * 2 > 325 && tank1.kutuY < 445 + 35 * 2);
            }
            else if (362 + 35 > tank2.y && 362 + 35 < tank2.y + 70 && 580 + 35 > tank2.x && 580 + 35 < tank2.x + 35 * 2 && !tank1.ozelGucDurum)
            {
                SFMLSes.Ses.SesCal(kukre);
                tank2.ozelGucDurum = true;
                tank1.x            = 400;
                tank1.y            = 400;
                tank2.x            = 800;
                tank2.y            = 400;
                tank1.rotation     = 0;
                tank2.rotation     = 0;
                tank1.kutuAcik     = true;
                tank2.kutuAcik     = true;
                tank1.kutuCan      = 3;
                do
                {
                    tank1.kutuX = tank2.kutuX = r.Next(50, 1180);
                    tank1.kutuY = tank2.kutuY = r.Next(10, 760);
                } while (tank1.kutuX + 35 * 2 > 550 && tank1.kutuX < 670 + 35 * 2 && tank1.kutuY + 35 * 2 > 325 && tank1.kutuY < 445 + 35 * 2);
            }
        }
        // Resim işlemleri
        public ActionResult ResimUpload(FormCollection collection, HttpPostedFileBase resim)
        {
            try
            {
                string resimAdi = ImageLibrary.Images.GetImageName(Path.GetExtension(resim.FileName));
                resim.SaveAs(Server.MapPath("~/Content/Products/Big/" + resimAdi));
                Images.SmallImage.Save(resimAdi, 250);
                Images.LittleImage.Save(resimAdi, 100);

                int   BaslikId = Convert.ToInt32(collection["BaslikId"]);
                Resim _resim   = new Resim
                {
                    Adi       = resimAdi,
                    Baslik    = collection["resimBaslik"],
                    GenelId   = BaslikId,
                    Parametre = "galeri",
                    Sira      = 1
                };

                _imageRepository.Insert(_resim);
            }
            catch (Exception ex)
            {
                Error(this, ex.ToString());
            }

            return(Redirect(collection["hdfRetUrl"] + "&resim=true"));
        }
        public ActionResult UrunResimEkle(int Uid, HttpPostedFileBase fileUpload)
        {
            if (fileUpload != null)
            {
                Image  img        = Image.FromStream(fileUpload.InputStream);
                Bitmap ortaresim  = new Bitmap(img, Settings.UrunOrtaBoyut);
                Bitmap buyukresim = new Bitmap(img, Settings.UrunBuyukBoyut);
                // Bitmap kucukresim = new Bitmap(img, Settings.UrunKucukBoyut);
                string ortaYol  = "/Content/UrunResim/Orta/" + Guid.NewGuid() + Path.GetExtension(fileUpload.FileName);
                string buyukYol = "/Content/UrunResim/Buyuk/" + Guid.NewGuid() + Path.GetExtension(fileUpload.FileName);
                //string kucukYol = "/Content/UrunResim/Kucuk/" + Guid.NewGuid() + Path.GetExtension(fileUpload.FileName);
                ortaresim.Save(Server.MapPath(ortaYol));
                buyukresim.Save(Server.MapPath(buyukYol));
                // kucukresim.Save(Server.MapPath(kucukYol));


                Resim resim = new Resim();
                resim.Buyukyol = buyukYol;
                resim.Ortayol  = ortaYol;
                //resim.Kucukyol = kucukYol;
                resim.UrunId = Uid;
                if (db.Resim.FirstOrDefault(x => x.UrunId == Uid && x.Varsayilan == false) != null)
                {
                    resim.Varsayilan = true;
                }
                else
                {
                    resim.Varsayilan = false;
                }
                db.Resim.Add(resim);
                db.SaveChanges();
                return(View(Uid));
            }
            return(View(Uid));
        }
Example #17
0
        public ActionResult Create(Haber haber, HttpPostedFileBase resim)
        {
            try
            {
                Image  img   = Image.FromStream(resim.InputStream);
                Bitmap Resim = new Bitmap(img);
                Resim.Save(Server.MapPath("/Images/" + resim.FileName));

                Resim rsm = new Resim();
                rsm.OrtaBoy = "/Images/" + resim.FileName;

                db.Resims.Add(rsm);
                db.SaveChanges();

                haber.ResimID = rsm.ResimId;
                db.Habers.Add(haber);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult MarkaEkle(Marka marka, HttpPostedFileBase fileUpload)
        {
            int resimId = -1;

            if (fileUpload != null)
            {
                Image  image  = Image.FromStream(fileUpload.InputStream);
                int    width  = Convert.ToInt32(ConfigurationManager.AppSettings["MarkaWidht"].ToString());
                int    height = Convert.ToInt32(ConfigurationManager.AppSettings["MarkaHeight"].ToString());
                string name   = "/Content/MarkaResim/" + Guid.NewGuid() + Path.GetExtension(fileUpload.FileName);
                Bitmap bm     = new Bitmap(image, width, height);
                bm.Save(Server.MapPath(name));
                Resim rsm = new Resim();
                rsm.Ortayol = name;
                db.Resim.Add(rsm);
                db.SaveChanges();
                if (rsm.Id != 0)
                {
                    resimId = rsm.Id;
                }
            }
            if (resimId != -1)
            {
                marka.ResimId = resimId;
            }
            db.Marka.Add(marka);
            db.SaveChanges();
            return(RedirectToAction("Markalar"));
        }
Example #19
0
        public ActionResult UrunResimEkle(int uId, HttpPostedFileBase resim)
        {
            if (resim != null)
            {
                Image  img        = Image.FromStream(resim.InputStream);
                Bitmap ortaresim  = new Bitmap(img, Settings.UrunOrtaBoyut);
                Bitmap buyukresim = new Bitmap(img, Settings.UrunBuyukBoyut);
                string ortaYol    = "/Resim/Orta/" + Guid.NewGuid() + Path.GetExtension(resim.FileName);
                string buyukYol   = "/Resim/Buyuk/" + Guid.NewGuid() + Path.GetExtension(resim.FileName);
                ortaresim.Save(Server.MapPath(ortaYol));
                buyukresim.Save(Server.MapPath(buyukYol));

                Resim rs = new Resim();
                rs.BuyukYol = buyukYol;
                rs.OrtaYol  = ortaYol;
                rs.UrunId   = uId;
                var VarsayilanSorgula = ent.Resim.Where(u => u.UrunId == uId).ToList();
                var count             = VarsayilanSorgula.Where(u => u.Varsayilan == true).Count();
                if (count <= 0)
                {
                    rs.Varsayilan = true;
                }
                else
                {
                    rs.Varsayilan = false;
                }
                ent.Resim.Add(rs);
                ent.SaveChanges();
                return(View(uId));
            }
            return(View(uId));
        }
Example #20
0
        public ActionResult Create(Uye uye, HttpPostedFileBase foto)
        {
            try
            {
                Image  img   = Image.FromStream(foto.InputStream);
                Bitmap Resim = new Bitmap(img);
                Resim.Save(Server.MapPath("/Images/" + foto.FileName));

                Resim rsm = new Resim();
                rsm.KucukBoy = "/Images/" + foto.FileName;

                db.Resims.Add(rsm);
                db.SaveChanges();

                uye.ResimID = rsm.ResimId;
                uye.YetkiId = 2;
                db.Uyes.Add(uye);
                db.SaveChanges();
                Session["uyeId"]        = uye.UyeId;
                Session["kullaniciAdi"] = uye.KullaniciAdi;
                return(RedirectToAction("Index", "Home"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Create(Article makale, HttpPostedFileBase resim)
        {
            try
            {
                Image  img   = Image.FromStream(resim.InputStream);
                Bitmap Resim = new Bitmap(img);
                Resim.Save(Server.MapPath("/Images/" + resim.FileName));

                Resim rsm = new Resim();
                rsm.BuyukBoyut = "/Images/" + resim.FileName;

                db.Resims.Add(rsm);
                db.SaveChanges();

                makale.ResimID            = rsm.ResimId;
                makale.GoruntulenmeSayisi = 0;
                makale.Begeni             = 0;
                db.Articles.Add(makale);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult MarkaEkle(Marka mrk, HttpPostedFileBase filee)
        {
            int resimID = -1;

            if (filee != null)
            {
                Image img    = Image.FromStream(filee.InputStream);
                int   width  = Convert.ToInt32(ConfigurationManager.AppSettings["MarkaWidth"].ToString());
                int   height = Convert.ToInt32(ConfigurationManager.AppSettings["MarkaHeight"].ToString());

                string name = "/Content/MarkaResim/" + Guid.NewGuid() + Path.GetExtension(filee.FileName);

                Bitmap bm = new Bitmap(img, width, height);
                bm.Save(Server.MapPath(name));

                Resim rsm = new Resim();
                rsm.OrtaYol = name;

                _resimManagement.Add(rsm);

                if (rsm.id != null)
                {
                    resimID = rsm.id;
                }
            }
            if (resimID != -1)
            {
                mrk.ResimID = resimID;
            }

            _markaManagement.Add(mrk);
            return(RedirectToAction("Markalar"));
        }
Example #23
0
        public override Resim IstekGetir(int id)
        {
            string commandText = "select * from Resimler where ResimId = @id";

            Resim resim = new Resim();

            SqlConnection _sqlConnection = new SqlConnection(yol);


            if (_sqlConnection.State == ConnectionState.Closed)
            {
                _sqlConnection.Open();
            }

            SqlCommand _sqlCommand = new SqlCommand(commandText, _sqlConnection);



            _sqlCommand.Parameters.AddWithValue("@id", id);

            SqlDataReader reader = _sqlCommand.ExecuteReader();

            while (reader.Read())
            {
                resim.ResimId   = Convert.ToInt32(reader["ResimId"]);
                resim.ResimAdi  = reader["ResimAdi"].ToString();
                resim.ResimYolu = reader["ResimYolu"].ToString();
            }

            reader.Close();
            _sqlConnection.Close();

            return(resim);
        }
        public IActionResult Yeni(YeniResimViewModel model)
        {
            //https://stackoverflow.com/questions/30701006/how-to-get-the-current-logged-in-user-id-in-asp-net-core
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

            if (ModelState.IsValid)
            {
                var ext       = Path.GetExtension(model.Resim.FileName);
                var dosyaAd   = Guid.NewGuid() + ext;
                var dosyaYolu = Path.Combine(_webHostEnvironment.WebRootPath, "uploads", dosyaAd);

                using (var stream = new FileStream(dosyaYolu, FileMode.Create))
                {
                    model.Resim.CopyTo(stream);
                }
                Resim resim = new Resim()
                {
                    IdentityUserId = userId,
                    ResimYolu      = dosyaAd,
                    YuklenmeZamani = DateTime.Now
                };
                _db.Resimler.Add(resim);
                _db.SaveChanges();
                return(RedirectToAction("Index", "Home"));
            }
            return(View());
        }
Example #25
0
 public ActionResult UrunResimEkle(int uId, HttpPostedFileBase fileUpload)
 {
     if (fileUpload != null)
     {
         Image  img        = Image.FromStream(fileUpload.InputStream);
         Bitmap ortaResim  = new Bitmap(img, Settings.UrunOrtaBoyut);
         Bitmap buyukResim = new Bitmap(img, Settings.UrunBuyukBoyut);
         string ortaYol    = "/Content/UrunResim/Orta/" + Guid.NewGuid() + Path.GetExtension(fileUpload.FileName);
         string buyukYol   = "/Content/UrunResim/Buyuk/" + Guid.NewGuid() + Path.GetExtension(fileUpload.FileName);
         ortaResim.Save(Server.MapPath(ortaYol));
         buyukResim.Save(Server.MapPath(buyukYol));
         Resim rsm = new Resim();
         rsm.BuyukYol = buyukYol;
         rsm.OrtaYol  = ortaYol;
         rsm.UrunId   = uId;
         if (Context.Baglanti.Resims.FirstOrDefault(x => x.UrunId == uId && x.Varsayilan == false) != null)
         {
             rsm.Varsayilan = true;
         }
         else
         {
             rsm.Varsayilan = false;
         }
         Context.Baglanti.Resims.Add(rsm);
         Context.Baglanti.SaveChanges();
         return(View(uId));
     }
     return(View(uId));
 }
        public ActionResult ResimSil(int ID)
        {
            Resim resim = _resimServis.GetById(ID);

            if (resim == null)
            {
                Urun urun = _urunServis.Get(x => x.ID == ID);
                if (urun == null)
                {
                    throw new Exception("Resim bulunamadı !");
                }
                string   dosyaAdi = urun.Resim;
                string   Yolu     = Server.MapPath(dosyaAdi);
                FileInfo file     = new FileInfo(Yolu);
                if (file.Exists)
                {
                    file.Delete();
                }
                urun.Resim = null;
                _urunServis.Save();
                return(RedirectToAction("Update", "Urun", new { id = ID }));
            }
            string   DosyaAdi = resim.ResimUrl;
            string   yolu     = Server.MapPath(DosyaAdi);
            FileInfo dosya    = new FileInfo(yolu);

            if (dosya.Exists)
            {
                dosya.Delete();
            }
            _resimServis.Delete(ID);
            _resimServis.Save();
            return(RedirectToAction("Update", "Urun", new { id = resim.UrunID }));
        }
        public ActionResult MakaleEkle(Makale mkl, HttpPostedFileBase resim)
        {
            Image  img      = Image.FromStream(resim.InputStream);
            Bitmap kckResim = new Bitmap(img, Settings.ResimKucukBoyut);
            Bitmap ortResim = new Bitmap(img, Settings.ResimOrtaBoyut);
            Bitmap bykResim = new Bitmap(img, Settings.ResimBuyukBoyut);

            kckResim.Save(Server.MapPath("/Content/MakaleResim/KucukBoyut/" + resim.FileName));
            ortResim.Save(Server.MapPath("/Content/MakaleResim/OrtaBoyut/" + resim.FileName));
            bykResim.Save(Server.MapPath("/Content/MakaleResim/BuyukBoyut/" + resim.FileName));

            Resim rsm = new Resim();

            rsm.KucukBoyut = "/Content/MakaleResim/KucukBoyut/" + resim.FileName;
            rsm.OrtaBoyut  = "/Content/MakaleResim/OrtaBoyut/" + resim.FileName;
            rsm.BuyukBoyut = "/Content/MakaleResim/BuyukBoyut/" + resim.FileName;

            context.Resims.Add(rsm);
            context.SaveChanges();

            mkl.ResimID            = rsm.ResimId;
            mkl.EklenmeTarihi      = DateTime.Now;
            mkl.GoruntulenmeSayisi = 0;
            mkl.Begeni             = 0;

            int yzrId = context.Kullanicis.FirstOrDefault(x => x.KullaniciAdi == User.Identity.Name).KullaniciId;

            mkl.YazarID = yzrId;

            context.Makales.Add(mkl);
            context.SaveChanges();

            return(RedirectToAction("Home", "Index"));
        }
        public IHttpActionResult PutResim(int id, Resim resim)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != resim.ResimId)
            {
                return(BadRequest());
            }

            db.Entry(resim).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ResimExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #29
0
        public ActionResult ResimEkle(Resimler resim, int urunid)
        {
            foreach (var dosya in resim.Dosyalar)
            {
                if (dosya.ContentLength > 0)
                {
                    //REsimler klasörüne resimleri ekliyoruz..
                    var dosyaAdi = Guid.NewGuid() + Path.GetExtension(dosya.FileName);
                    var adres    = Path.Combine(Server.MapPath("~/Resimler"), dosyaAdi);
                    dosya.SaveAs(adres);


                    // veri tabanına kaydediyoruz..

                    Resim rsm = new Resim();
                    rsm.urunID   = urunid;
                    rsm.resimAdi = dosyaAdi;
                    db.Resim.Add(rsm);
                }
                else
                {
                    ViewBag.Mesaj = "yükleme işlemi yapılamadı";
                    return(View());
                }
            }
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #30
0
        public ActionResult MarkaEkle(Marka marka, List <HttpPostedFileBase> image)
        {
            Resim _resim;

            foreach (var item in image)
            {
                _resim = new Resim();
                var extension = Path.GetExtension(item.FileName);
                if (image != null && (extension == ".jpg" || extension == ".png" || extension == ".jpeg"))
                {
                    var path           = Server.MapPath("~/UploadImages");
                    var RandomFileName = Path.GetRandomFileName();
                    var Name           = Path.ChangeExtension(RandomFileName, ".jpg");
                    var final          = Path.Combine(path, Name);
                    item.SaveAs(final);
                    _resim.Ad = Name;
                    marka.Resim.Add(_resim);
                }
            }

            _marka.PostMarka(marka);

            ViewBag.Ekleme = "true";
            return(View("MarkaIslem", _marka.GetMarkas()));
        }