Beispiel #1
0
 private void Application_Startup(object sender, StartupEventArgs e)
 {
     ConnSettingsViewModel = new ConnSettingsViewModel();
     ControlRoomViewModel  = new ControlRoomViewModel();
     DataViewViewModel     = new DataViewViewModel();
     JoystickViewModel     = new JoystickViewModel();
     MapViewModel          = new MapViewModel();
     SlidersViewModel      = new SlidersViewModel();
 }
Beispiel #2
0
        public ActionResult Create([Bind(Include = "SliderTitle,IsActive,StartDate,EndDate,Url")] SlidersViewModel model
                                   , HttpPostedFileBase imgUp)
        {
            if (ModelState.IsValid)
            {
                string imageName;
                if (imgUp != null && imgUp.IsImage())
                {
                    imageName = Guid.NewGuid() + System.IO.Path.GetExtension(imgUp.FileName);
                }
                else
                {
                    ModelState.AddModelError("ImageName", "لطفا تصویر را انتخاب کنید.");
                    return(View());
                }

                PersianCalendar pc = new PersianCalendar();
                //DateTime dt = new DateTime(model.StartDate.get, pc);

                var slider = new Slider
                {
                    SliderTitle = model.SliderTitle,
                    StartDate   = model.StartDate,
                    EndDate     = model.EndDate,
                    Url         = model.Url,
                    ImageName   = imageName,
                    IsActive    = model.IsActive
                };

                db.SliderRepository.Insert(slider);
                db.Save();

                imgUp.SaveAs(Server.MapPath("/Images/Slider/" + slider.ImageName));


                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
 public Sliders()
 {
     DataContext = new SlidersViewModel();
     InitializeComponent();
 }
 public Sliders()
 {
     InitializeComponent();
     vm          = new SlidersViewModel(new SlidersModel());
     DataContext = vm;
 }