public async Task <IActionResult> Update(SlideShowViewModel slideShowViewModel, IFormFile photo, string pto) { if (ModelState.IsValid) { if (photo != null) { string nameAndPath = Path.Combine(_iHostingEnvironment.WebRootPath + "/slide_show", Path.GetFileName(photo.FileName)); await photo.CopyToAsync(new FileStream(nameAndPath, FileMode.Create)); slideShowViewModel.Photo = "slide_show/" + photo.FileName; } if (photo == null) { slideShowViewModel.Photo = pto; } SlideShow updateSlideShow = _iMapper.Map <SlideShow>(slideShowViewModel); bool isAdd = await _iSlideShowManager.Update(updateSlideShow); if (isAdd) { return(RedirectToAction("Index")); } else { ViewBag.ErrorMessage = "Failed to Update Slide-Show"; } } return(View(slideShowViewModel)); }
public LandscapeView() { InitializeComponent(); this.BindingContext = viewModel = ViewModelLocator.SlideshowViewModel; density = Xamarin.Essentials.DeviceDisplay.MainDisplayInfo.Density; buttonSize = (float)(30 * density); buttonTop = (float)(150 * density) + buttonSize; // set initial values currentHeading = Heading1; currentBody = Body1; offscreenHeading = Heading2; offscreenBody = Body2; // set initial onscreen text currentHeading.Text = viewModel.CurrentLocation.Title; currentBody.Text = viewModel.CurrentLocation.Description; // SurfaceDuo: align image to the hinge if (DualScreenInfo.Current.SpanMode == TwoPaneViewMode.Wide) { var paneWidth = DualScreenInfo.Current.HingeBounds.X; landscapeGrid.ColumnDefinitions[0].Width = paneWidth + 60; landscapeBoxView.Margin = new Thickness(0, 0, -30, 0); } else { landscapeGrid.ColumnDefinitions[0].Width = 225; landscapeBoxView.Margin = new Thickness(-70, 0, -30, 0); } }
public async Task <IActionResult> Create(SlideShowViewModel slideShowViewModel) { if (!ModelState.IsValid) { return(View(slideShowViewModel)); } if (!_fileManager.ValidateUploadedFile(slideShowViewModel.SlideShowPictrureFile, UploadFileType.Image, 4, ModelState)) { return(View(slideShowViewModel)); } string fileName = await _fileManager.UploadFileAsync(slideShowViewModel.SlideShowPictrureFile, new List <string> { "images", "slider" }); var slideShow = _mapper.Map <SlideShowViewModel, SlideShow>(slideShowViewModel); slideShow.SlideShowPictrure = fileName; await _mediator.Send(new AddNewSlideShowCommand { SlideShow = slideShow }); TempData["SlideShowMessage"] = "اسلاید شو با موفقیت ثبت شد."; return(RedirectToAction("ManageSlideShow")); }
public virtual async Task <ActionResult> AddSlideShow(SlideShowViewModel slideShowModel) { if (!ModelState.IsValid) { slideShowModel.SlideShowImages = await _slideShowService.GetSlideShowImages(); return(View(slideShowModel)); } var slide = new SlideShowImage(); _mappingEngine.Map(slideShowModel, slide); var otherSlideShows = new List <SlideShowImage>(); _mappingEngine.Map <IList <SlideShowViewModel>, IList <SlideShowImage> >(slideShowModel.SlideShowImages, otherSlideShows); if (slideShowModel.Id.HasValue) { _slideShowService.EditSlide(slide, otherSlideShows); TempData["message"] = "اسلاید مورد نظر با موفقیت ویرایش شد"; } else { _slideShowService.AddSlide(slide, otherSlideShows); TempData["message"] = "اسلاید جدید با موفقیت در سیستم ثبت شد"; } await _unitOfWork.SaveAllChangesAsync(); return(RedirectToAction(MVC.SlideShow.Admin.ActionNames.Index)); }
private static void ParseSlideshows(XmlNode slideshowNode, Configuration config) { Log.TraceMsg("Configuration.ParseSlideshows: Parsing slideshows"); foreach (XmlNode node in slideshowNode.ChildNodes) { if (!CheckRolesForInclusion(node, config)) { continue; } var interval = node.Attr(DisplayIntervalInSecondsAttribute); var path = node.Attr("Path"); SlideShowViewModel slideshow; var dirInfo = new DirectoryInfo(path); if (dirInfo.Exists) { slideshow = new SlideShowViewModel(dirInfo.FullName); } else { continue; } slideshow.DisplayIntervalInSeconds = int.Parse(interval); config.SlideShows.Add(slideshow); } Log.TraceMsg("Configuration.ParseSlideshows: {0} slideshows loaded", config.SlideShows.Count); }
public ActionResult Create() { var model = new SlideShowViewModel(); //Add locales to model AddLocales(_languageService, model.Locales); return(base.View(model)); }
public ActionResult Edit(SlideShowViewModel model, string ReturnUrl) { ActionResult action; try { if (!base.ModelState.IsValid) { String messages = String.Join(Environment.NewLine, ModelState.Values.SelectMany(v => v.Errors) .Select(v => v.ErrorMessage + " " + v.Exception)); base.ModelState.AddModelError("", messages); return(base.View(model)); } else { SlideShow slideShow = this._slideShowService.Get((SlideShow x) => x.Id == model.Id, false); if (model.Image != null && model.Image.ContentLength > 0) { string fileName = Path.GetFileName(model.Image.FileName); string extension = Path.GetExtension(model.Image.FileName); fileName = string.Concat(model.Title.NonAccent(), extension); string str = Path.Combine(base.Server.MapPath(string.Concat("~/", Contains.AdsFolder)), fileName); model.Image.SaveAs(str); model.ImgPath = string.Concat(Contains.AdsFolder, fileName); } SlideShow modelMap = Mapper.Map <SlideShowViewModel, SlideShow>(model, slideShow); this._slideShowService.Update(modelMap); //Update Localized foreach (var localized in model.Locales) { _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Title, localized.Title, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Description, localized.Description, localized.LanguageId); } base.Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.UpdateSuccess, FormUI.SlideShow))); if (!base.Url.IsLocalUrl(ReturnUrl) || ReturnUrl.Length <= 1 || !ReturnUrl.StartsWith("/") || ReturnUrl.StartsWith("//") || ReturnUrl.StartsWith("/\\")) { action = base.RedirectToAction("Index"); } else { action = this.Redirect(ReturnUrl); } } } catch (Exception exception1) { Exception exception = exception1; base.ModelState.AddModelError("", exception.Message); ExtentionUtils.Log(string.Concat("SlideShow.Edit: ", exception.Message)); return(base.View(model)); } return(action); }
/// <summary> /// Constructor for the MainWindow. /// </summary> public MainWindow() { InitializeComponent(); // Get hold of the instance of the ViewModel for this page. It's // defined as a Window.Resource, so we can look for that resource. _vm = (SlideShowViewModel) this.FindResource("ImagesSource"); // Attach a handler for the PropertyChanging event of the ViewModel. _vm.PropertyChanging += _vm_PropertyChanging; }
/// <summary> /// 轮播图数据验证 /// </summary> /// <param name="model">轮播图模型</param> /// <returns>验证结果</returns> private ActionResult SlideShowValidate(SlideShowViewModel model) { ActionResult result = new ActionResult(true); if (string.IsNullOrEmpty(model.Code)) { result.Success = false; result.Message = "HybridApp.CodeNotNull"; } return(result); }
public async Task <IActionResult> RenderCreate() { var nextOrder = await _slideShowService.GetNextOrder(); var viewModel = new SlideShowViewModel() { IsShow = true, Order = nextOrder, }; return(View("Create", viewModel)); }
public ActionResult Create() { var model = new SlideShowViewModel { Status = 1, OrderDisplay = 1 }; //Add locales to model AddLocales(_languageService, model.Locales); return(View(model)); }
public PortraitView() { InitializeComponent(); this.BindingContext = viewModel = ViewModelLocator.SlideshowViewModel; currentBody = Body1; currentHeading = Heading1; offscreenBody = Body2; offscreenHeading = Heading2; offscreenBody.Opacity = 0; offscreenHeading.Opacity = 0; currentBitmap = BitmapExtensions.LoadBitmapResource(this.GetType(), viewModel.CurrentLocation.ImageResource); }
public ActionResult Edit(int Id) { SlideShowViewModel modelMap = Mapper.Map <SlideShow, SlideShowViewModel>(this._slideShowService.Get((SlideShow x) => x.Id == Id, false)); //Add Locales to model AddLocales(_languageService, modelMap.Locales, (locale, languageId) => { locale.Id = modelMap.Id; locale.LocalesId = modelMap.Id; locale.Title = modelMap.GetLocalized(x => x.Title, modelMap.Id); locale.Description = modelMap.GetLocalized(x => x.Description, Id); }); return(base.View(modelMap)); }
public async Task <ActionResult <SlideShowViewModel> > Update(int?id) { if (id == null) { return(NotFound()); } SlideShowViewModel existSlideShow = _iMapper.Map <SlideShowViewModel> (await _iSlideShowManager.GetById(id)); if (existSlideShow == null) { return(NotFound()); } return(View(existSlideShow)); }
public override ActionResult Index(SlideShowBlock currentBlock) { var model = new SlideShowViewModel(); model.CurrentBlock = currentBlock; if (!ContentReference.IsNullOrEmpty(currentBlock.ImageFolder)) { var contentLoader = ServiceLocator.Current.GetInstance <IContentLoader>(); var images = contentLoader.GetChildren <ImageFile>(currentBlock.ImageFolder).ToList(); model.Images = images; } return(PartialView(model)); }
public ActionResult Create(SlideShowViewModel model, string returnUrl) { ActionResult action; try { if (!ModelState.IsValid) { var messages = String.Join(Environment.NewLine, ModelState.Values.SelectMany(v => v.Errors) .Select(v => v.ErrorMessage + " " + v.Exception)); ModelState.AddModelError("", messages); return(View(model)); } ImageHandler(model); var modelMap = Mapper.Map <SlideShowViewModel, SlideShow>(model); _slideShowService.Create(modelMap); //Update Localized foreach (var localized in model.Locales) { _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Title, localized.Title, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Description, localized.Description, localized.LanguageId); } Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.CreateSuccess, FormUI.SlideShow))); if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\")) { action = RedirectToAction("Index"); } else { action = Redirect(returnUrl); } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); LogText.Log(string.Concat("SlideShow.Edit: ", ex.Message)); return(View(model)); } return(action); }
public PortraitView() { InitializeComponent(); this.BindingContext = viewModel = ViewModelLocator.SlideshowViewModel; currentHeading = Heading1; currentBody = Body1; currentBitmap = BitmapExtensions.LoadBitmapResource(this.GetType(), viewModel.CurrentLocation.ImageResource); offscreenHeading = Heading2; offscreenBody = Body2; // set intial values offscreenHeading.Text = viewModel.CurrentLocation.Title; offscreenBody.Text = viewModel.CurrentLocation.Description; }
public ActionResult Carousel() { #if SavvyCarousel var data = new SlideShowViewModel(); data.Slides = Models.HomepageSlideList.LoadActive(); return(View("SavvyCarousel", data)); #elif CarouselBootstrap var data = new SlideShowViewModel(); data.Slides = Models.HomepageSlideList.LoadActive(); return(View("CarouselBootstrap", data)); #elif DumbCarousel var data = new SlideShowViewModel(); data.Slides = Models.HomepageSlideList.LoadActive(); return(View("Carousel", data)); #else return(Content("")); #endif }
private void ImageHandler(SlideShowViewModel model) { if (model.Image != null && model.Image.ContentLength > 0) { var folderName = CommonHelper.FolderName(model.Title); var fileExtension = Path.GetExtension(model.Image.FileName); var fileNameOriginal = Path.GetFileNameWithoutExtension(model.Image.FileName); var fileName = fileNameOriginal.FileNameFormat(fileExtension); var sizeWidthBg = _settingService.GetSetting("SlideShow.WidthBigSize", ImageSize.WidthDefaultSize); var sizeHeighthBg = _settingService.GetSetting("SlideShow.HeightBigSize", ImageSize.HeightDefaultSize); _imageService.CropAndResizeImage(model.Image, $"{Constant.SlideShowFolder}{folderName}/", fileName, sizeWidthBg, sizeHeighthBg); model.ImgPath = $"{Constant.SlideShowFolder}{folderName}/{fileName}"; } }
public IActionResult SaveEntity(SlideShowViewModel slideShow) { if (!ModelState.IsValid) { IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors); return(new BadRequestObjectResult(allErrors)); } if (slideShow.Id == 0) { _slideShowService.Create(slideShow); } else { _slideShowService.Update(slideShow); } _slideShowService.Save(); return(new OkObjectResult(slideShow)); }
public LandscapeView() { InitializeComponent(); this.BindingContext = viewModel = ViewModelLocator.SlideshowViewModel; density = Xamarin.Essentials.DeviceDisplay.MainDisplayInfo.Density; buttonSize = (float)(30 * density); buttonTop = (float)(150 * density) + buttonSize; // set initial values currentHeading = Heading1; currentBody = Body1; offscreenHeading = Heading2; offscreenBody = Body2; // set initial onscreen text currentHeading.Text = viewModel.CurrentLocation.Title; currentBody.Text = viewModel.CurrentLocation.Description; }
public async Task <bool> InsertAsync(SlideShowViewModel viewModel) { var entity = new SlideShow() { Id = viewModel.Id, Title = viewModel.Title, BriefDescription = viewModel.BriefDescription, Description = viewModel.Description, Image = viewModel.Image, Link1 = viewModel.Link1, Link2 = viewModel.Link2, Order = viewModel.Order, IsShow = viewModel.IsShow, }; await _slideShows.AddAsync(entity); var result = await _unitOfWork.SaveChangesAsync(); return(result != 0); }
public JsonResult GetSlideShow(string userId, string code, string parentCode) { return(ExecuteFunctionRun(() => { ActionResult result = new ActionResult(true); var parentNode = this.Engine.FunctionAclManager.GetFunctionNodeByCode(parentCode); var slideShow = this.Engine.HybridAppManager.GetSlideShow(code); if (string.IsNullOrEmpty(code)) { result.Extend = new SlideShowViewModel(); } else if (null == parentNode) { result.Message = "HybridApp.ParentNodeNotExist"; result.Success = false; } else if (null == slideShow) { result.Message = "HybridApp.SlideNotExits"; result.Success = false; } else { SlideShowViewModel model = new SlideShowViewModel() { ObjectID = slideShow.ObjectID, ParentCode = slideShow.ParentCode, Code = slideShow.SlideCode, Description = slideShow.Description, IsDisplay = slideShow.IsDisplay, Url = slideShow.Url, SortKey = slideShow.SortKey, Image = GetImageUrl(userId, SlideShow.TableName, slideShow) }; result.Extend = model; } return Json(result, JsonRequestBehavior.AllowGet); })); }
public async Task <bool> UpdateAsync(SlideShowViewModel viewModel) { var entity = await _slideShows.FirstOrDefaultAsync(p => p.Id == viewModel.Id); if (entity != null) { entity.Title = viewModel.Title; entity.BriefDescription = viewModel.BriefDescription; entity.Description = viewModel.Description; entity.Image = viewModel.Image; entity.Link1 = viewModel.Link1; entity.Link2 = viewModel.Link2; entity.Order = viewModel.Order; entity.IsShow = viewModel.IsShow; var result = await _unitOfWork.SaveChangesAsync(); return(result != 0); } return(await Task.FromResult(false)); }
public async Task <IActionResult> Create(SlideShowViewModel viewModel) { if (ModelState.IsValid) { if (await _slideShowService.CheckExistTitleAsync(viewModel.Id, viewModel.Title)) { ModelState.AddModelError(nameof(viewModel.Title), "عنوان وارد شده تکراری است"); return(View(viewModel)); } var result = await _slideShowService.InsertAsync(viewModel); if (result) { return(RedirectToAction("Index", "SlideShow")); } return(View(viewModel)); } return(View(viewModel)); }
public async Task <IActionResult> Delete(SlideShowViewModel viewModel) { var slideShowViewModel = await _slideShowService.GetByIdAsync(viewModel.Id); if (slideShowViewModel == null) { ModelState.AddModelError("", RequestNotFound); } else { var result = await _slideShowService.DeleteAsync(slideShowViewModel.Id); if (result) { return(Json(new { success = true })); } ModelState.AddModelError("", RequestNotFound); } return(PartialView("_Delete", model: viewModel)); }
public LandscapeView() { InitializeComponent(); this.BindingContext = viewModel = ViewModelLocator.SlideshowViewModel; currentBitmap = BitmapExtensions.LoadBitmapResource(this.GetType(), viewModel.CurrentLocation.ImageResource); }
public void Update(SlideShowViewModel slideVM) { var slide = slideVM.AddModel(); _SlideRepository.Update(slide); }
public SlideShowSample() { InitializeComponent(); DataContext = new SlideShowViewModel(); }
public ActionResult Create(SlideShowViewModel model, string returnUrl) { ActionResult action; try { if (!ModelState.IsValid) { var messages = String.Join(Environment.NewLine, ModelState.Values.SelectMany(v => v.Errors) .Select(v => v.ErrorMessage + " " + v.Exception)); ModelState.AddModelError("", messages); return(View(model)); } if (model.Image != null && model.Image.ContentLength > 0) { var folderName = Utils.FolderName(model.Title); var fileExtension = Path.GetExtension(model.Image.FileName); var fileNameOriginal = Path.GetFileNameWithoutExtension(model.Image.FileName); var fileName = fileNameOriginal.FileNameFormat(fileExtension); _imagePlugin.CropAndResizeImage(model.Image, $"{Contains.SlideShowFolder}{folderName}/", fileName, ImageSize.SlideShowWithBigSize, ImageSize.SlideShowHeightBigSize, true); model.ImgPath = $"{Contains.SlideShowFolder}{folderName}/{fileName}"; //var fileExtension = Path.GetExtension(model.Image.FileName); //var fileName = model.Title.NonAccent().FileNameFormat(fileExtension); //var imageServerPath = Path.Combine(Server.MapPath(string.Concat("~/", Contains.AdsFolder)), fileName); //model.ImgPath = $"{Contains.AdsFolder}/{fileName}"; //model.Image.SaveAs(imageServerPath); } var modelMap = Mapper.Map <SlideShowViewModel, SlideShow>(model); _slideShowService.Create(modelMap); //Update Localized foreach (var localized in model.Locales) { _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Title, localized.Title, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Description, localized.Description, localized.LanguageId); } Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.CreateSuccess, FormUI.SlideShow))); if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\")) { action = RedirectToAction("Index"); } else { action = Redirect(returnUrl); } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); ExtentionUtils.Log(string.Concat("SlideShow.Edit: ", ex.Message)); return(View(model)); } return(action); }
public JsonResult SaveSlideShow(SlideShowViewModel model) { return(ExecuteFunctionRun(() => { System.Web.HttpFileCollectionBase files = HttpContext.Request.Files; var parentNode = this.Engine.FunctionAclManager.GetFunctionNodeByCode(model.ParentCode); ActionResult result = SlideShowValidate(model); // 检查文件大小 if (files.Count > 0 && files[0].ContentLength > 1024 * 1024) { result.Success = false; result.Message = "msgGlobalString.ImageMaxLength"; return Json(result, "text/html"); } else if (null == parentNode) { result.Message = "HybridApp.ParentNodeNotExist"; result.Success = false; return Json(result, "text/html"); } else if (result.Success == false) { return Json(result, JsonRequestBehavior.AllowGet); } SlideShow slideShow; //新建 if (string.IsNullOrEmpty(model.ObjectID)) { string guid = Guid.NewGuid().ToString(); this.SaveImage(files, guid, parentNode.Code); slideShow = new SlideShow() { SlideCode = model.Code, SortKey = model.SortKey, IsDisplay = model.IsDisplay, Description = model.Description, Url = model.Url, ObjectID = guid, ParentCode = model.ParentCode, }; if (!this.Engine.HybridAppManager.AddSlideShow(slideShow)) { result.Success = false; result.Message = "msgGlobalString.SaveFailed"; } } else { //编辑 slideShow = this.Engine.HybridAppManager.GetSlideShow(model.Code); slideShow.IsDisplay = model.IsDisplay; slideShow.SortKey = model.SortKey; slideShow.Url = model.Url; slideShow.Description = model.Description; if (this.Engine.HybridAppManager.UpdateSlideShow(slideShow)) { this.SaveImage(files, slideShow.ObjectID, parentNode.ObjectID); } else { result.Success = false; result.Message = "msgGlobalString.SaveFailed"; } } return Json(result, "text/html", JsonRequestBehavior.AllowGet); })); }