예제 #1
0
        public ActionResult SliderUpdate(SliderDTO data)
        {
            Slider slider = _sliderService.GetByID(data.ID);

            slider.Queue = data.Queue;
            _sliderService.Update(slider);
            return(Redirect("/Admin/CMS/SliderList"));
        }
        public ActionResult Update(SliderDTO SliderDTO)
        {
            Slider Slider = _SliderService.GetByID(SliderDTO.ID);

            Slider.Content    = SliderDTO.Content;
            Slider.Header     = SliderDTO.Header;
            Slider.ImageUrl   = SliderDTO.ImageUrl;
            Slider.Name       = SliderDTO.Name;
            Slider.SliderUrl1 = SliderDTO.SliderUrl1;
            Slider.SliderUrl2 = SliderDTO.SliderUrl2;
            _SliderService.Update(Slider);
            return(Redirect("/SysAdmin/Slider/List"));
        }
예제 #3
0
        public IActionResult Update(string id, [FromBody] Slider sliderIn)
        {
            var slider = _sliderService.Get(id);

            if (slider == null)
            {
                return(NotFound());
            }

            _sliderService.Update(id, sliderIn);

            return(Ok());
        }
예제 #4
0
        public async Task <ActionResult> AddOrUpdate(SliderViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(Json(new AjaxResult(ModelState.JoinMessages())));
                }

                var isUpdate = model.Id > 0;

                model.Pictures?.ForEach(x => x.Link = FileHelper.CopyFile(x.Link, AppConst.Folder.Slider));
                if (isUpdate)
                {
                    var pics = _service.SliderRepository.Asset(model.Id).SelectMany(x => x.Pictures).ToList();
                    pics.ForEach(x =>
                    {
                        if (!model.Pictures.Select(a => a.Link).Contains(x.Link))
                        {
                            FileHelper.RemoveFile(x.Link);
                        }
                    });
                }

                var result = isUpdate ? await _service.Update(model.Id, model) : await _service.Create(model);

                if (result.NotFound)
                {
                    return(Json(new AjaxResult("اسلایدر مورد نظر یافت نشد.")));
                }

                if (result.Succeeded)
                {
                    model.Pictures?.ForEach(x =>
                    {
                        if (!string.Equals(x.Link, x.LinkOld, StringComparison.CurrentCultureIgnoreCase))
                        {
                            FileHelper.RemoveFile(x.LinkOld);
                        }
                    });
                    return(Json(new AjaxResult(true, "اطلاعات با موفقیت ذخیره گردید.")));
                }

                return(Json(new AjaxResult(result.State.Errors.JoinMessages())));
            }
            catch (Exception e)
            {
                return(Json(new AjaxResult(e.JoinMessages())));
            }
        }
        protected void btnGuncelle_Click(object sender, EventArgs e)
        {
            try
            {
                int      ID             = int.Parse(lblInfo2.Text);
                Slider   oldSlider      = _sliderService.Get(ID);
                Users    user           = (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();

                oldSlider.sliderTitle   = txtBaslik.Text;
                oldSlider.SliderWriting = txtYazi.Text;
                oldSlider.SliderURL     = lblInfo.Text;
                oldSlider.LanguageID    = language.ID;
                if (Int32.Parse(RadioButtonList1.SelectedItem.Value) == 1)
                {
                    oldSlider.IsActive = true;
                }
                else
                {
                    oldSlider.IsActive = false;
                }
                oldSlider.ModifiedBy   = user.ID;
                oldSlider.ModifiedDate = DateTime.Now;

                _sliderService.Update(oldSlider);

                clear();
                Butonvisible(true);
                panelVisible(true, true, false, false);
                Uyari("Güncelleme işlemi başarıyla gerçekleşti", true);
            }
            catch (Exception)
            {
                Uyari("Güncelleme işlemi sırasında bir hata oluştu", false);
            }
        }
예제 #6
0
        public ActionResult Update(HttpPostedFileBase PosterPath, Slider item)
        {
            User u = (User)Session["oturum"];

            item.UserID = u.ID;
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    if (ModelState.IsValid)
                    {
                        item.Status = Status.Updated;
                        if (PosterPath == null)
                        {
                            if (ss.Update(item))
                            {
                                ts.Complete();
                                return(RedirectToAction("Index"));
                            }
                            else
                            {
                                return(View(item));
                            }
                        }
                        else
                        {
                            bool   sonuc;
                            string yoluTut = FxFunction.ImageUpload(PosterPath, Path.Sliders, out sonuc);

                            if (sonuc)
                            {
                                string tamYol = Request.MapPath("~/Content/" + item.ImagePath);
                                if (System.IO.File.Exists(tamYol))
                                {
                                    System.IO.File.Delete(tamYol);
                                }
                                item.ImagePath = yoluTut;
                                if (ss.Update(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(null);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(View());
        }