public ActionResult IlanEkle(Konut konut, HttpPostedFileBase Resim, HttpPostedFileBase Resim2) { konutRepository.Insert(konut); if (Resim != null) { Fotograf foto = new Fotograf() { Resim = ConvertToBytes(Resim), KonutID = konut.ID }; fotografRepository.Insert(foto); // Birden fazla resim eklenmek istendiğinde //Fotograf foto2 = new Fotograf() //{ // Resim = ConvertToBytes(Resim2), // KonutID = konut.ID //}; //fotografRepository.Insert(foto2); } return(RedirectToAction("Index", "Musteri")); }
public IActionResult Snimi(FotografEvidentirajVM x) { Fotograf fotograf = new Fotograf(); x.PutanjaDoSlikeFotografa = UploadFile(x); if (x.FotografID == 0) { _dbContext.Add(fotograf); } else { fotograf = _dbContext.Fotografi.Find(x.FotografID); } fotograf.FotografID = x.FotografID; fotograf.SatnicaSlikanja = x.SatnicaSlikanja; if (!string.IsNullOrEmpty(x.PutanjaDoSlikeFotografa)) { fotograf.PutanjaDoSlikeFotografa = x.PutanjaDoSlikeFotografa; } fotograf.FotografijaID = x.FotografijaID; fotograf.ImeFotografa = x.ImeFotografa; fotograf.PrezimeFotografa = x.PrezimeFotografa; _dbContext.SaveChanges(); return(Redirect("PrikazFotografa?KorisnikID=" + x.KorisnikID)); }
public ActionResult KonutDetay(int id) { // id=KonutID Fotograf resimList = fotografRepository.GetByID(id); return(View(resimList)); }
protected void Button1_Click(object sender, EventArgs e) { try { if (FileUpload1.HasFile) { FileUpload1.SaveAs(Server.MapPath("~/webimages/" + FileUpload1.FileName)); Fotograf f = et1.Fotograf .First(i => i.fotografID == fotografID); f.fotografAciklama = txt_fotoaciklama.Text; f.fotografYol = ("~/webimages/" + FileUpload1.FileName); et1.SaveChanges(); Response.Redirect("foto_galeri.aspx"); } else { Fotograf f = et1.Fotograf .First(i => i.fotografID == fotografID); f.fotografAciklama = txt_fotoaciklama.Text; et1.SaveChanges(); Response.Redirect("foto_galeri.aspx"); } } catch (Exception) { throw; } }
public ActionResult InsertFoto(Fotograf foto) { dbContext.Fotograflar.Add(foto); dbContext.SaveChanges(); return(View()); }
public async Task <IActionResult> Edit(int id, [Bind("Id,EvId,File")] Fotograf fotograf) { if (id != fotograf.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(fotograf); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FotografExists(fotograf.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["EvId"] = new SelectList(_context.Ev, "Id", "EvTipi", fotograf.EvId); return(View(fotograf)); }
public static string FotografGetir(string albumYolu) { string yol = albumYolu + "/"; yol = yol.Replace("~", ""); albumYolu = HttpContext.Current.Server.MapPath(albumYolu); Fotograf r = new Fotograf(); if (Directory.Exists(albumYolu)) { FileInfo[] resimler = new DirectoryInfo(albumYolu).GetFiles(); foreach (FileInfo resim in resimler) { if (resim.Extension.Replace(".", "").ToUpper() == "JPG" || resim.Extension.Replace(".", "").ToUpper() == "PNG") { r.FotografAdi = resim.Name; r.FotografYolu = yol + resim.Name; r.FotografTuru = resim.Extension.Replace(".", "").ToUpper(); r.FotografBoyutu = resim.Length; r.IdFotograf = Convert.ToDecimal(resim.Name.Substring(10, 15)); break; } } } return r.FotografYolu; }
public ActionResult UpdateFoto(Fotograf model) { Fotograf foto = dbContext.Fotograflar.Where(x => x.Id == model.Id).FirstOrDefault(); if (foto != null) { foto.Url = model.Url; foto.Tur = model.Tur; //Burası önemli buradaki ID durumunu çöz int sonuc = dbContext.SaveChanges(); if (sonuc > 0) { ViewBag.Result = "Güncelleme işlemi başarılı."; ViewBag.Status = "success"; } else { ViewBag.Result = "Güncelleme işlemi başarısız."; ViewBag.Status = "danger"; } } return(View(foto)); }
public IActionResult ObrisiFotografa(string KorisnikID, int FotografID) { Fotograf pronadjen = _dbContext.Fotografi.Find(FotografID); _dbContext.Remove(pronadjen); _dbContext.SaveChanges(); return(Redirect("PrikazFotografa?KorisnikID=" + KorisnikID)); }
public ActionResult UpdateFoto(int?id) { Fotograf foto = null; if (id != null) { foto = dbContext.Fotograflar.Where(x => x.Id == id).FirstOrDefault(); } return(View(foto)); }
public ActionResult DeleteFotoo(int?id) { if (id != null) { Fotograf foto = dbContext.Fotograflar.Where(x => x.Id == id).FirstOrDefault(); dbContext.Fotograflar.Remove(foto); dbContext.SaveChanges(); } return(RedirectToAction("ListFoto", "FotografController")); }
public async Task <IActionResult> Create([Bind("Id,ArabaId,Fotograf1")] Fotograf fotograf) { if (ModelState.IsValid) { _context.Add(fotograf); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ArabaId"] = new SelectList(_context.Arabas, "Id", "Ad", fotograf.ArabaId); return(View(fotograf)); }
protected void Page_Load(object sender, EventArgs e) { fotografID = Convert.ToInt32(Request.QueryString["fotografID"]); if (Page.IsPostBack == false) { using (atak_testcaseEntities1 db = new atak_testcaseEntities1()) { Fotograf f = et1.Fotograf .First(i => i.fotografID == fotografID);//Id = fotografID olan kaydı bul txt_fotoaciklama.Text = f.fotografAciklama; } } }
private string UploadedFile(Fotograf model) { string uniqueFileName = null; if (model.tempPath != null) { string uploadsFolder = Path.Combine(webHostEnvironment.WebRootPath, "images"); uniqueFileName = Guid.NewGuid().ToString() + "_" + model.tempPath.FileName; string filePath = Path.Combine(uploadsFolder, uniqueFileName); using (var fileStream = new FileStream(filePath, FileMode.Create)) { model.tempPath.CopyTo(fileStream); } } return(uniqueFileName); }
public ActionResult Kaydet(Personel personel, HttpPostedFileBase file) { if (!ModelState.IsValid) { var model = new PersonelFormViewModel() { Departmanlar = db.Departman.ToList(), Personeller = db.Personel.ToList(), Personel = personel }; return(View("PersonelForm", model)); } Fotograf fotograf = new Fotograf(); if (file.ContentLength > 0) { var fileName = Path.GetFileNameWithoutExtension(file.FileName); var extension = Path.GetExtension(file.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; fotograf.PersonelId = personel.Id; fotograf.Fotograf1 = "~/Images/" + fileName; fileName = Path.Combine(Server.MapPath("~/Images/"), fileName); file.SaveAs(fileName); } if (personel.Id == 0) //Ekleme { if (fotograf != null) { db.Fotograf.Add(fotograf); } db.Personel.Add(personel); } else //Guncelleme { if (fotograf != null) { db.Fotograf.Add(fotograf); } db.Entry(personel).State = System.Data.Entity.EntityState.Modified; } db.SaveChanges(); ModelState.Clear(); return(RedirectToAction("Index")); }
protected void Button1_Click(object sender, EventArgs e) { if (FileUpload1.HasFile) { FileUpload1.SaveAs(Server.MapPath("~/webimages/" + FileUpload1.FileName)); Fotograf yeni_foto = new Fotograf(); yeni_foto.fotografAciklama = txt_foto_aciklama.Text; yeni_foto.fotografYol = ("~/webimages/" + FileUpload1.FileName); //FileUpload1.FileName; et1.Fotograf.AddObject(yeni_foto); et1.SaveChanges(); Response.Redirect("foto_galeri.aspx"); } else { Label2.Text = "Resim Ekleyiniz!"; } }
public async Task <IActionResult> Create(Fotograf fotograf) { if (ModelState.IsValid) { string uniqueFileName = UploadedFile(fotograf); Fotograf fotograf1 = new Fotograf { EvId = fotograf.EvId, File = uniqueFileName, }; _context.Add(fotograf1); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EvId"] = new SelectList(_context.Ev, "Id", "EvTipi", fotograf.EvId); return(View(fotograf)); }
public static List<Fotograf> FotograflariGetir(string albumYolu) { string yol = albumYolu + "/"; yol = yol.Replace("~", ""); albumYolu = HttpContext.Current.Server.MapPath(albumYolu); List<Fotograf> colResim = new List<Fotograf>(); if (Directory.Exists(albumYolu)) { FileInfo[] resimler = new DirectoryInfo(albumYolu).GetFiles(); foreach (FileInfo resim in resimler) { if (resim.Extension.Replace(".", "").ToUpper() == "JPG" || resim.Extension.Replace(".", "").ToUpper() == "PNG") { try { Fotograf r = new Fotograf(); r.FotografAdi = resim.Name; r.FotografYolu = yol + resim.Name; r.FotografTuru = resim.Extension.Replace(".", "").ToUpper(); r.FotografBoyutu = resim.Length; r.IdFotograf = Convert.ToDecimal(resim.Name.Substring(0, 5)); colResim.Add(r); } catch (Exception) { continue; } } } FotografAdeti = colResim.Count; colResim = colResim.OrderByDescending(k => k.IdFotograf).Take(6).ToList(); } return colResim; }
private List <Fotograf> AracFotoGetir(int id) { List <Fotograf> FotografListesi = new List <Fotograf>(); cmd = new SqlCommand("select * from Fotograf where aracId=@id", con); cmd.Parameters.AddWithValue("@id", id); try { con.Open(); rdr = cmd.ExecuteReader(); if (rdr.HasRows) { while (rdr.Read()) { Fotograf f = new Fotograf() { AracId = (int)rdr["AracId"], Foto = (string)rdr["Foto"], Id = (int)rdr["Id"] }; FotografListesi.Add(f); } } } catch (Exception) { throw; } finally { con.Close(); } return(FotografListesi); }
protected void Button1_Click1(object sender, EventArgs e) { Fotograf.yukle(FileUpload1, 150); }
public ActionResult UyeOl(Uye temp, HttpPostedFileBase foto, string parolaTekrar) { string resimAd = Guid.NewGuid().ToString(); //Anonimler için . Eger foto==null ise bu devereye girecek temp.FotoID = 7; if (temp.AdSoyad == null || temp.KullaniciAdi == null || temp.Parola == null || temp.Email == null) { Session["uyeSorun"] = "Lütfen hiç bir alanı boş geçmeyiniz"; return(RedirectToAction("UyeOl")); } if (temp.Parola != parolaTekrar) { Session["uyeSorun"] = "Parolalar uyuşmuyor."; return(RedirectToAction("UyeOl")); } if (foto != null) { Image rsm = Image.FromStream(foto.InputStream); Bitmap btOrta = new Bitmap(rsm, Tools.OrtaBoyutSize.Width, Tools.OrtaBoyutSize.Height); Bitmap btKucuk = new Bitmap(rsm, Tools.KucukBoyutSize.Width, Tools.KucukBoyutSize.Height); string ortaYol = "/Uploads/ProfilResim/Orta/" + resimAd + Path.GetExtension(foto.FileName); string kucukYol = "/Uploads/ProfilResim/Kucuk/" + resimAd + Path.GetExtension(foto.FileName); btOrta.Save(Server.MapPath(ortaYol)); btKucuk.Save(Server.MapPath(kucukYol)); Fotograf ft = new Fotograf(); //UYE RESMI =1 ft.ResimTurID = 1; ft.Orta = ortaYol; ft.Kucuk = kucukYol; ft.Aktif = true; ft.Onay = true; if (!fotograf.Insert(ft)) { Session["uyeSorun"] = "Resim yüklenemedi lütfen tekrar deneyiniz"; return(RedirectToAction("UyeOl")); } int yuklenenResimID = fotograf.Select().FirstOrDefault(x => x.Orta.Contains(resimAd)).Id; temp.FotoID = yuklenenResimID; } temp.Aktif = true; temp.Onay = false; temp.OlusturulmaTarihi = DateTime.Now; //ADMIN DEGIL UYE DEDIK 2 DIYEREK temp.YetkiID = 2; temp.Parola = Crypto.Hash(temp.Parola, "MD5"); if (!uyeler.Insert(temp)) { Session["uyeSorun"] = "Uye kaydı işleminiz başarısız.."; return(RedirectToAction("UyeOl")); } Session["uyeSorun"] = "Uye kaydı işleminiz başarıyla tamamlandı.."; return(RedirectToAction("UyeOl")); }
public ActionResult MakaleDuzenle(Makale temp, HttpPostedFileBase Fotog) { //BURADA MAKALE IDYI ALDK Makale yeni = makale.GetByID(temp.Id); if (Fotog != null) { Image img = Image.FromStream(Fotog.InputStream); Bitmap bOrta = new Bitmap(img, Tools.OrtaBoyutSize); Bitmap bBuyuk = new Bitmap(img, Tools.BuyukBoyutSize); string resimAd = Guid.NewGuid().ToString() + Path.GetExtension(Fotog.FileName); string buyukYol = "/Uploads/MakaleResim/Buyuk/" + resimAd; string ortaYol = "/Uploads/MakaleResim/Orta/" + resimAd; Fotograf eskiFoto = yeni.Fotograf; Fotograf yenifoto = new Fotograf(); yenifoto.Buyuk = buyukYol; yenifoto.Orta = ortaYol; yenifoto.Aktif = true; yenifoto.Onay = false; //Makale Resim belirteci yenifoto.ResimTurID = 3; // YENI RESIM DATABASEYE YUKLENDI if (!fotograf.Insert(yenifoto)) { Session["makaleDuzenleSorun"] = "Fotoğraf değiştirme de sorun yaşandı"; return(RedirectToAction("makaleDuzenle")); } string eskibuyukYol = yeni.Fotograf.Buyuk; string eskiOrtaYol = yeni.Fotograf.Orta; //RESIMLERI SERVERE CEK bOrta.Save(Server.MapPath("/Uploads/MakaleResim/Orta/" + resimAd)); bBuyuk.Save(Server.MapPath("/Uploads/MakaleResim/Buyuk/" + resimAd)); //MAKALEMİZİN BOŞ KALAN FOTO IDSINI DOLDURDUK int yenifotoId = fotograf.Select().FirstOrDefault(x => x.Buyuk == buyukYol).Id; yeni.FotoID = yenifotoId; //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ SAVECHANGE DE KAYDETME YOK! makale.SAVE(); //ESKI RESMIN ID SINI VE KENDISINI SILDIK. if (!fotograf.Delete(eskiFoto.Id)) { Session["makaleDuzenleSorun"] = "Eski fotograf silinemedi.."; return(RedirectToAction("makaleDuzenle")); } //RESMI SERVERDAN SILDIK System.IO.File.Delete(Server.MapPath(eskibuyukYol)); System.IO.File.Delete(Server.MapPath(eskiOrtaYol)); } yeni.Icerik = temp.Icerik; yeni.Baslik = temp.Baslik; yeni.KategoriID = temp.KategoriID; if (!makale.SAVE()) { Session["makaleDuzenleSorun"] = "Makale Değiştirilemedi.."; return(RedirectToAction("makaleDuzenle")); } Session["makaleDuzenleSorun"] = "Makale başarıyla güncellendi"; return(RedirectToAction("makaleDuzenle")); }
public ActionResult IlanEkle(KonutViewModel ilan) { if (!ModelState.IsValid) { return(View(ilan)); } Konut konut = new Konut { Aciklama = ilan.Aciklama, Adres = ilan.Adres, Baslik = ilan.Baslik, BinaYasi = ilan.BinaYasi, Boylam = ilan.Boylam, Enlem = ilan.Enlem, EklenmeTarihi = DateTime.Now, Fiyat = ilan.Fiyat, IlanTuruID = ilan.IlanTuruID, IsitmaTuruID = ilan.IsitmaTuruID, KatTuruID = ilan.KatTuruID, KullaniciID = ilan.KullaniciID, Metrekare = ilan.Metrekare, OdaSayisi = ilan.OdaSayisi, YayindaMi = false, }; konutR.Insert(konut); if (Request.Files.Count > 0) { try { for (int i = 0; i < Request.Files.Count; i++) { HttpPostedFileBase fu = Request.Files[i]; string dosyayolu = string.Empty; string fileName = Path.GetFileNameWithoutExtension(fu.FileName); string extentionName = Path.GetExtension(fu.FileName); if (fu != null && fu.ContentType.Contains("image") && fu.ContentLength < 1000000) { string folderName = Server.MapPath("~/images/ilanlar"); string pathString = System.IO.Path.Combine(folderName, konut.ID.ToString()); System.IO.Directory.CreateDirectory(pathString); fileName = fileName.Replace(" ", ""); fileName += Guid.NewGuid().ToString().Replace("-", ""); dosyayolu = Server.MapPath("~/images/ilanlar/" + konut.ID.ToString() + "/") + fileName + extentionName; fu.SaveAs(dosyayolu); WebImage img = new WebImage(dosyayolu); img.Resize(150, 150); img.Save(dosyayolu); Fotograf fotograf = new Fotograf() { KonutID = konut.ID, Yol = konut.ID.ToString() + "/" + fileName + extentionName }; forografR.Insert(fotograf); } } } catch (Exception ex) { return(RedirectToAction("IlanEkle")); } } return(RedirectToAction("Ilanlarim")); }
public ActionResult makaleEkle(Makale temp, HttpPostedFileBase foto, string Etiketler) { string resimAd = Guid.NewGuid().ToString(); if (temp.Baslik == null || temp.Icerik == null) { Session["makaleSorun"] = "Lütfen makalenin adını veya içeriğini boş bırakmayınız."; return(RedirectToAction("makaleEkle")); } if (foto == null) { Session["makaleSorun"] = "Lütfen makaleye resim yükleyiniz."; return(RedirectToAction("makaleEkle")); } else { Image rsm = Image.FromStream(foto.InputStream); Bitmap btOrta = new Bitmap(rsm, Tools.OrtaBoyutSize.Width, Tools.OrtaBoyutSize.Height); Bitmap btBuyuk = new Bitmap(rsm, Tools.BuyukBoyutSize.Width, Tools.BuyukBoyutSize.Height); string ortaYol = "/Uploads/MakaleResim/Orta/" + resimAd + Path.GetExtension(foto.FileName); string buyukYol = "/Uploads/MakaleResim/Buyuk/" + resimAd + Path.GetExtension(foto.FileName); btOrta.Save(Server.MapPath(ortaYol)); btBuyuk.Save(Server.MapPath(buyukYol)); Fotograf ft = new Fotograf(); //MAAKE RESMI =3 ft.ResimTurID = 3; ft.Orta = ortaYol; ft.Buyuk = buyukYol; ft.Aktif = true; ft.Onay = true; if (!fotograf.Insert(ft)) { Session["makaleSorun"] = "Resim yüklenemedi lütfen tekrar deneyiniz"; return(RedirectToAction("makaleEkle")); } int yuklenenResimID = fotograf.Select().FirstOrDefault(x => x.Orta.Contains(resimAd)).Id; temp.FotoID = yuklenenResimID; temp.Aktif = true; temp.Begenme = 0; temp.Okunma = 0; temp.OlusturmaTarihi = DateTime.Now; temp.UyeID = Convert.ToInt32(Session["aktifUyeId"]); if (!makale.Insert(temp)) { Session["makaleSorun"] = "Makale yüklenemedi lütfen tekrar deneyiniz"; return(RedirectToAction("makaleEkle")); } int makaleID = makale.Select().FirstOrDefault(x => x.FotoID == yuklenenResimID).Id; if (!string.IsNullOrEmpty(Etiketler)) { string[] etikets = Etiketler.Split(','); foreach (var etk in etikets) { Etiket et = new Etiket() { Adi = etk }; et.Aktif = true; etiket.Insert(et); int etiketID = etiket.Select().FirstOrDefault(x => x.Adi == etk).Id; MakaleEtiket me = new MakaleEtiket(); me.EtiketID = etiketID; me.MakaleID = makaleID; me.Aktif = true; makaleetiket.Insert(me); } } } Session["makaleSorun"] = "Makale başarıyla eklendi.."; return(RedirectToAction("makaleEkle")); }
public ActionResult ProfilDuzenle(Uye temp, HttpPostedFileBase Fotog) { Uye eski = uyeler.GetByID(temp.Id); if (Fotog != null) { Image img = Image.FromStream(Fotog.InputStream); Bitmap bOrta = new Bitmap(img, Tools.OrtaBoyutSize); Bitmap bKucuk = new Bitmap(img, Tools.KucukBoyutSize); string resimAd = Guid.NewGuid().ToString() + Path.GetExtension(Fotog.FileName); string kucukYol = "/Uploads/ProfilResim/Kucuk/" + resimAd; string ortaYol = "/Uploads/ProfilResim/Orta/" + resimAd; Fotograf eskiFoto = eski.Fotograf; Fotograf yenifoto = new Fotograf(); yenifoto.Kucuk = kucukYol; yenifoto.Orta = ortaYol; yenifoto.Aktif = true; yenifoto.Onay = true; //Makale Resim belirteci yenifoto.ResimTurID = 1; //YENI RESIM DATABASEYE YUKLENDI if (!fotograf.Insert(yenifoto)) { Session["profilSorun"] = "Fotoğraf değiştirme de sorun yaşandı"; return(RedirectToAction("ProfilDuzenle", new { id = temp.Id })); } string eskiKucukYol = eskiFoto.Kucuk; string eskiOrtaYol = eskiFoto.Orta; //RESIMLERI SERVERE CEK bOrta.Save(Server.MapPath(ortaYol)); bKucuk.Save(Server.MapPath(kucukYol)); //MAKALEMİZİN BOŞ KALAN FOTO IDSINI DOLDURDUK int yenifotoId = fotograf.Select().FirstOrDefault(x => x.Orta == ortaYol).Id; eski.FotoID = yenifotoId; //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ SAVECHANGE DE KAYDETME YOK! uyeler.SAVE(); //ESKI RESMIN ID SINI VE KENDISINI SILDIK. if (!fotograf.Delete(eskiFoto.Id)) { Session["profilSorun"] = "Eski fotograf silinemedi.."; return(RedirectToAction("ProfilDuzenle", new { id = temp.Id })); } //RESMI SERVERDAN SILDIK System.IO.File.Delete(Server.MapPath(eskiKucukYol)); System.IO.File.Delete(Server.MapPath(eskiOrtaYol)); } if (!string.IsNullOrEmpty(temp.Email)) { eski.Email = temp.Email; } if (!string.IsNullOrEmpty(temp.AdSoyad)) { eski.AdSoyad = temp.AdSoyad; } if (!uyeler.SAVE()) { Session["profilSorun"] = "Profil bilgileri değiştirme de sorun yaşandı"; return(RedirectToAction("ProfilDuzenle", new { id = temp.Id })); } Session["profilSorun"] = "Profil bilgileri başarıyla değiştirildi.."; return(RedirectToAction("ProfilDuzenle", new { id = temp.Id })); }