public void _sliderDelete(int id) { var res = new SliderRepository().FindbyIdandDisable(id); if (res == Enum.EntityResult.Failed) { this.AddToastMessage("", "Slider silinirken hata", Enum.ToastrType.Error); } else { this.AddToastMessage("", "Slider silme başarılı", Enum.ToastrType.Success); } }
public ActionResult SliderEdit(Slider modified) { if (!ModelState.IsValid) { this.AddToastMessage("", "Alanları kontrol Ediniz", Enum.ToastrType.Warning); return View("SliderCreate", modified); } var res = new SliderRepository().Update(modified); if (res == Enum.EntityResult.Failed) { this.AddToastMessage("", "Slider güncellenirken hata", Enum.ToastrType.Error); return View("SliderCreate", modified); } this.AddToastMessage("", "Kayıt Başarılı", Enum.ToastrType.Success); return RedirectToAction("Slider"); }
public ActionResult SliderCreate(Slider model, HttpPostedFileBase uploadedFile) { if (!ModelState.IsValid) { this.AddToastMessage("", "Alanları kontrol Ediniz", Enum.ToastrType.Warning); return View(model); } if (uploadedFile == null) { this.AddToastMessage("", "Görsel seçmelisiniz", Enum.ToastrType.Warning); return View(model); } if (uploadedFile.ContentLength < 0) { this.AddToastMessage("", "Görsel seçmelisiniz", Enum.ToastrType.Warning); return View(model); } var file = FileSave(uploadedFile, "Slider", Enum.FileType.Media); if (file == null) { this.AddToastMessage("", "Görsel yüklenirken hata!", Enum.ToastrType.Error); return View(model); } model.AuthorId = new AuthenticatedAuthor().Id; model.FileId = file.Id; var res = new SliderRepository().Create(model); if (res == Enum.EntityResult.Failed) { this.AddToastMessage("", "Slider oluşturulurken hata", Enum.ToastrType.Error); return View(model); } this.AddToastMessage("", "Kayıt Başarılı", Enum.ToastrType.Success); return RedirectToAction("Slider"); }
public ActionResult SliderEdit(int id) { var item = new SliderRepository().FindbyId(id); return View("SliderCreate", item); }
public ActionResult SliderCreate(Slider model, HttpPostedFileBase uploadedFile) { if (!ModelState.IsValid) { this.AddToastMessage("", "Alanları kontrol Ediniz", Enum.ToastrType.Warning); return View(model); } if (uploadedFile == null) { this.AddToastMessage("", "Görsel seçmelisiniz", Enum.ToastrType.Warning); return View(model); } if (uploadedFile.ContentLength < 0) { this.AddToastMessage("", "Görsel seçmelisiniz", Enum.ToastrType.Warning); return View(model); } Stream fs = uploadedFile.InputStream; fs.Position = 0; byte[] content = new byte[uploadedFile.ContentLength]; fs.Read(content, 0, uploadedFile.ContentLength); var image = System.Drawing.Image.FromStream(new MemoryStream(content)); var slidersetting = new SettingRepository().SliderSettings(); if (image.Width > slidersetting.Width && image.Height > slidersetting.Height) { this.AddToastMessage("", "Genişlik " + slidersetting.Width + "px. Yükseklik " + slidersetting.Height + "px. olmalı.", Enum.ToastrType.Warning); this.AddToastMessage("", "Ayarlar sayfasından değerleri değiştirebilirsiniz."); return View(model); } var file = FileSave(uploadedFile, "Slider", Enum.FileType.Media); if (file == null) { this.AddToastMessage("", "Görsel yüklenirken hata!", Enum.ToastrType.Error); return View(model); } model.AuthorId = new AuthenticatedAuthor().Id; model.FileId = file.Id; var res = new SliderRepository().Create(model); if (res == Enum.EntityResult.Failed) { this.AddToastMessage("", "Slider oluşturulurken hata", Enum.ToastrType.Error); return View(model); } this.AddToastMessage("", "Kayıt Başarılı", Enum.ToastrType.Success); return RedirectToAction("Slider"); }