public ResponseModel CreateSliderItem(AddSliderModel new_slider)
        {
            ResponseModel result = new ResponseModel();

            result = AddSliderValidate(new_slider);

            if (!result.IsSuccess)
            {
                return(result);
            }

            try
            {
                MainSliderSettings new_item = new MainSliderSettings();
                new_item.ButtonText  = new_slider.ButtonText;
                new_item.ButtonUrl   = new_slider.ButtonUrl;
                new_item.MediumTitle = new_slider.MediumTitle;
                new_item.PhotoUrl    = new_slider.PhotoUrl;
                new_item.SmallTitle  = new_slider.SmallTitle;
                _imgM.SaveSliderImage(new_slider.SliderImage, new_slider.SaveBaseAddress);
                int id = _sliderRepo.Insert(new_item);
                new_slider.ID    = id;
                result.IsSuccess = true;
                result.Message   = "Slider başarı ile eklendi!";
                BTC.Common.Constants.StaticSettings.ReloadSettings();
            }
            catch (Exception ex)
            {
                result.Message   = ex.Message;
                result.IsSuccess = false;
                throw;
            }
            return(result);
        }
        public ResponseModel AddSliderValidate(AddSliderModel slider)
        {
            ResponseModel result = new ResponseModel();

            if (slider.SliderImage == null)
            {
                result.Message = "Slider görseli boş olamaz!";
                return(result);
            }
            else
            {
                var img = System.Drawing.Image.FromStream(slider.SliderImage.InputStream, true, true);
                int w   = img.Width;
                int h   = img.Height;

                if (w < 1910 || w > 1930 || h < 470 || h > 490)
                {
                    result.Message = "Slider görseli istenilen boyutlarda değil! (1920 - 480)";
                    return(result);
                }
            }

            if (!string.IsNullOrWhiteSpace(slider.ButtonText) && string.IsNullOrWhiteSpace(slider.ButtonUrl))
            {
                result.Message = "Buton adı dolu ise yönlendirme urli dolu olmalıdır!";
                return(result);
            }

            result.IsSuccess = true;
            return(result);
        }
示例#3
0
        public JsonResult addSlider(AddSliderModel slider)
        {
            string file_name         = Guid.NewGuid().ToString().Replace("-", "") + ".jpg";
            string base_file_path    = WebConfigurationManager.AppSettings["BaseSliderAddress"];
            string base_file_address = HttpContext.Server.MapPath(base_file_path);
            string savedBaseFilePath = Path.Combine(base_file_address, file_name);

            slider.SaveBaseAddress = savedBaseFilePath;
            slider.PhotoUrl        = file_name;
            ResponseModel result = _mainM.CreateSliderItem(slider);

            return(Json(result));
        }
示例#4
0
        public virtual ActionResult AddSlider(AddSliderModel SliderModel)
        {
            var lstSliderStatus = new List <SelectListItem>
            {
                new SelectListItem {
                    Text = "عادی", Value = "visible", Selected = true
                },
                new SelectListItem {
                    Text = "پنهان", Value = "hidden"
                },
                new SelectListItem {
                    Text = "پیش نویس", Value = "draft"
                },
                new SelectListItem {
                    Text = "آرشیو", Value = "archive"
                }
            };

            ViewBag.SliderStatus = lstSliderStatus;

            if (!ModelState.IsValid)
            {
                return(PartialView(MVC.Admin.Shared.Views._ValidationSummery));
            }


            var Slider = new Slider
            {
                Priority     = SliderModel.SliderPriority,
                CreatedDate  = DateAndTime.GetDateTime(),
                Link         = SliderModel.SliderLink,
                Picture      = SliderModel.SliderPicture,
                Status       = SliderModel.SliderStatus.ToString().ToLower(),
                Title        = SliderModel.SliderTitle,
                EditedByUser = _userService.GetUserByUserName(User.Identity.Name)
            };


            Slider.User = _userService.GetUserByUserName(User.Identity.Name);

            _SliderService.AddSlider(Slider);
            _uow.SaveChanges();


            return(PartialView(MVC.Admin.Shared.Views._Alert,
                               new Alert {
                Message = "اسلاید جدید با موقیت در سیستم ثبت شد", Mode = AlertMode.Success
            }));
        }