public ActionResult SliderAdd(Slider data, HttpPostedFileBase Image) { data.SliderPath = ImageUploader.UploadSingleImage("/Sliders/", Image); if (data.SliderPath == "0" || data.SliderPath == "1" || data.SliderPath == "2") { data.SliderPath = "Content/Images/Web/Home/product.jpg"; } _sliderService.Add(data); return(Redirect("/Admin/CMS/SliderList")); }
public ActionResult Insert(HttpPostedFileBase ImagePath, Slider item) { User u = (User)Session["oturum"]; item.UserID = u.ID; try { using (TransactionScope ts = new TransactionScope()) { if (ModelState.IsValid) { bool sonuc; string yoluTut = FxFunction.ImageUpload(ImagePath, Path.Sliders, out sonuc); if (sonuc) { item.ImagePath = yoluTut; if (ss.Add(item)) { ts.Complete(); return(RedirectToAction("Index")); } else { return(View(item)); } } else { ViewBag.Message = $"Resim yükleme işlemi sırasında bir hata oluştu. {yoluTut}"; } } else { return(View()); } } } catch (Exception) { throw; } return(View()); }
protected void btnKaydet_Click(object sender, EventArgs e) { try { Slider slider = new Slider(); Users newsUser = (Users)Session["user"]; string selectLanguage = ddlLanguage.SelectedItem.Text; Language language = (from l in db.Language where l.LanguageName == selectLanguage && l.IsActive == true select l).FirstOrDefault(); slider.sliderTitle = txtBaslik.Text; slider.SliderWriting = txtYazi.Text; slider.SliderURL = lblInfo.Text; slider.LanguageID = language.ID; if (int.Parse(RadioButtonList1.SelectedItem.Value) == 1) { slider.IsActive = true; } else { slider.IsActive = false; } slider.CreatedBy = newsUser.ID; slider.CreatedDate = DateTime.Now; _sliderService.Add(slider); clear(); Butonvisible(true); panelVisible(true, true, false, false); Uyari("Kayıt işlemi başarıyla gerçekleşti", true); } catch (Exception) { Uyari("Kayıt işlemi sırasında bir hata oluştu", false); } }
public ActionResult Add(Slider _Slider) { _Slider.UserID = _UserService.GetByDefault(x => x.UserName == User.Identity.Name).ID; _SliderService.Add(_Slider); return(Redirect("/SysAdmin/Slider/List")); }