public Task <IViewComponentResult> InvokeAsync() { string thumbnailDirectory = Path.Combine(_env.WebRootPath, "images\\gallery\\derin\\thumbnail"); DirectoryInfo di = new DirectoryInfo(thumbnailDirectory); GalleryVM galleryVM = new GalleryVM(); galleryVM.GalleryList = new List <GalleryItem>(); if (di.Exists) { List <string> ext = new List <string> { ".jpg", ".jpeg", ".png", ".gif", ".tif" }; FileInfo[] rgFiles = di.EnumerateFiles(".", SearchOption.AllDirectories) .Where(path => ext.Contains(Path.GetExtension(path.Name))) .Select(x => new FileInfo(x.FullName)).ToArray(); GalleryItem gallery = null; foreach (FileInfo item in rgFiles.OrderByDescending(x => x.LastWriteTime)) { gallery = new GalleryItem(); gallery.FileName = item.Name; gallery.FilePath = Path.Combine(_env.WebRootPath, "images\\gallery\\derin"); galleryVM.GalleryList.Add(gallery); } } return(Task.FromResult <IViewComponentResult>(View(galleryVM))); }
public ActionResult Create([Bind(Include = "RowID,Title,Description")] GalleryVM mod) { if (ModelState.IsValid) { var file = Request.Files[0]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetExtension(file.FileName); tblGallery tbl = new tblGallery { Description = mod.Description, Title = mod.Title, Status = true, Transdate = DateTime.Now.AddHours(12), UserID = bl.GetUserID(System.Web.HttpContext.Current), ImagePath = fileName }; db.tblGalleries.Add(tbl); db.SaveChanges(); var path = Path.Combine(Server.MapPath("~/Images/"), "gal" + tbl.RowID + fileName); file.SaveAs(path); return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "No Image Found"); } } return(View(mod)); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); var reset = e.NavigationMode == NavigationMode.New; var restore = e.NavigationMode == NavigationMode.Back; if (reset) { this.needResetView = true; } else if (restore) { this.needRestoreView = true; } this.VM = await GalleryVM.GetVMAsync((long)e.Parameter); Control restoreElement = null; var idx = this.VM.CurrentIndex; if (reset) { resetView(); } else if (restore) { var animation = ConnectedAnimationService.GetForCurrentView().GetAnimation("ImageAnimation"); if (animation != null) { var con = this.gv.ContainerFromIndex(idx); if (con != null) { animation.TryStart(con.Descendants <Image>().First()); } else { animation.Cancel(); } } } await Dispatcher.YieldIdle(); if (reset) { this.pv.Focus(FocusState.Programmatic); await Task.Delay(50); this.pv.SelectedIndex = 0; } else if (restore) { if (restoreElement == null) { restoreElement = (Control)this.gv.ContainerFromIndex(this.VM.CurrentIndex); } await Dispatcher.YieldIdle(); restoreElement?.Focus(FocusState.Programmatic); } }
private static IAsyncAction handle(Uri uri) { return(AsyncInfo.Run(async token => { try { var r = await UriLauncher.HandleAsync(uri); switch (r) { case GalleryLaunchResult g: { var page = RootControl.RootController.Frame.Content; var vm = await GalleryVM.GetVMAsync(g.GalleryInfo); if (!(page is GalleryPage gPage && gPage.ViewModel.Gallery.ID == g.GalleryInfo.ID)) { await RootControl.RootController.Navigator.NavigateAsync(typeof(GalleryPage), g.GalleryInfo.ID); await Task.Delay(500); } switch (g.Status) { case GalleryLaunchStatus.Image: vm.View.MoveCurrentToPosition(g.CurrentIndex); await RootControl.RootController.Navigator.NavigateAsync(typeof(ImagePage), g.GalleryInfo.ID); break; case GalleryLaunchStatus.Torrent: (RootControl.RootController.Frame.Content as GalleryPage)?.ChangePivotSelection(2); break; default: (RootControl.RootController.Frame.Content as GalleryPage)?.ChangePivotSelection(0); break; } return; } case SearchLaunchResult sr: switch (sr.Data) { case CategorySearchResult ksr: var vm = SearchVM.GetVM(ksr); await RootControl.RootController.Navigator.NavigateAsync(typeof(SearchPage), vm.SearchQuery); return; case FavoritesSearchResult fsr: var fvm = FavoritesVM.GetVM(fsr); await RootControl.RootController.Navigator.NavigateAsync(typeof(FavoritesPage), fvm.SearchQuery); return; } throw new InvalidOperationException(); } } catch (Exception e) { RootControl.RootController.SendToast(e, null); } })); }
public IActionResult Index() { GalleryVM gallery = new GalleryVM() { Services = _db.Services.Include(s => s.ServiceImages).ToList(), ServiceCategories = _db.ServiceCategories.ToList() }; return(View(gallery)); }
private static void AddtionalInfo(StringBuilder sb, GalleryVM gVM) { var g = gVM.Gallery; if (g == null) { return; } sb.AppendLine($"Gallery: Type={g.GetType()}, ID={g.ID}, Token={g.Token:x10}"); }
public GalleryPage(Fault fault) { InitializeComponent(); ViewModel = new GalleryVM(fault); FaultContext = fault; BindingContext = ViewModel; }
public IActionResult Index() { ViewBag.ContactUs = JsonConvert.DeserializeObject <ContactUsVM>(HttpContext.Session.GetString("ContactUsData")); ViewBag.AboutUs = JsonConvert.DeserializeObject <AboutUsVM>(HttpContext.Session.GetString("AboutUsData")); GalleryVM galleryVM = new GalleryVM(); galleryVM.GalleryList = new List <GalleryItem>(); galleryVM.GalleryList.AddRange(GetImageList()); return(View(galleryVM)); }
public IActionResult Detail(int?id) { if (id == null) { return(NotFound()); } GalleryVM gallery = new GalleryVM() { ServiceImages = _db.ServiceImages.Where(s => s.ServiceId == id).Take(2).ToList(), Servicee = _db.Services.Find(id) }; return(View(gallery)); }
public IActionResult Index() { // заполнил список картинок var imageList = _imageService.GetAll(); // заполнил ViewModel var model = new GalleryVM() { Images = imageList, SearchQuery = "" }; // вернул в представление ViewModel return(View(model)); }
public ActionResult <GalleryVM> GetGalleryById(int id) { IQueryable <Gallery> galleryList = _service.GetAll(s => s.Images); Gallery gallerySearch = galleryList.FirstOrDefault(s => s.Id == id); GalleryVM rtnGallery = null; if (gallerySearch != null) { rtnGallery = _mapper.Map <GalleryVM>(gallerySearch); return(Ok(rtnGallery)); } else { return(NotFound(rtnGallery)); } }
private async Task Refresh() { switch (PivotIndex) { case 0: GalleryVM.Reload(); break; case 2: await SearchVM.Refresh("default"); break; case 3: await AccountVM.Reload(); break; } }
public ActionResult Edit([Bind(Include = "RowID,Title,Description,Status")] GalleryVM mod) { if (ModelState.IsValid) { tblGallery tbl = db.tblGalleries.Find(mod.RowID); tbl.Description = mod.Description; tbl.Title = mod.Title; tbl.Status = true; var file = Request.Files[0]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetExtension(file.FileName); tbl.ImagePath = fileName; var path = Path.Combine(Server.MapPath("~/Images/"), "gal" + tbl.RowID + fileName); file.SaveAs(path); } db.SaveChanges(); return(RedirectToAction("Index")); } return(View(mod)); }
// GET: Galleries/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblGallery tblGallery = db.tblGalleries.Find(id); if (tblGallery == null) { return(HttpNotFound()); } GalleryVM mod = new GalleryVM { Description = tblGallery.Description, Title = tblGallery.Title, ImagePath = tblGallery.ImagePath, RowID = tblGallery.RowID, Status = tblGallery.Status }; return(View(mod)); }
public async Task <IActionResult> Save(GalleryVM galleryVM) { AjaxMessage aMsg = new AjaxMessage(); var files = Request.Form.Files; if (files.Count > 0) { var totalFileSize = 25 * 1024 * 1024; if (files.Sum(m => m.Length) > totalFileSize) { aMsg.Status = 0; aMsg.Message = "25 MB limitiniz aştınız."; } else { string lowresDirectory = Path.Combine(_env.WebRootPath, "images\\gallery\\derin\\lowres"); string thumbnailDirectory = Path.Combine(_env.WebRootPath, "images\\gallery\\derin\\thumbnail"); if (!Directory.Exists(lowresDirectory)) { Directory.CreateDirectory(lowresDirectory); } if (!Directory.Exists(thumbnailDirectory)) { Directory.CreateDirectory(thumbnailDirectory); } foreach (IFormFile image in files) { int fileSizeLimit = 4 * 1024 * 1024; if (image.Length < fileSizeLimit) { string imageName = Guid.NewGuid().ToString(); string imageExtension = Path.GetExtension(image.FileName); try { ConvertLowres(lowresDirectory, image, imageName, imageExtension); } catch (Exception ex) { } try { ConvertThumbnail(thumbnailDirectory, image, imageName, imageExtension); } catch (Exception ex) { } } } aMsg.Status = 1; aMsg.Message = "Fotoğraf ekleme işlemi başarılı"; } } else { aMsg.Status = 0; aMsg.Message = "Lütfen fotoğraf seçiniz."; } return(Json(aMsg)); }
public ActionResult <IEnumerable <AccountVM> > GetAllAccount([FromQuery] AccountSM account, bool withRateScore, bool getNewFirst, int pageSize = 20, int pageIndex = 1) { try { IQueryable <Account> accountList = _accountService.GetAll( s => s.Services, s => s.Gallery.Images, _ => _.Addresses ); if (getNewFirst) { accountList = accountList.Where(_ => _.Role == "WORKER"); if (!string.IsNullOrEmpty(account.DisplayName)) { accountList = accountList.Where(_ => _.DisplayName.Contains(account.DisplayName)); } var result = _pagingSupport.From(accountList) .GetRange(pageIndex, pageSize, s => s.Status) .Paginate <AccountNewFirstVM>(); return(Ok(result)); } if (!string.IsNullOrEmpty(account.Email)) { accountList = accountList.Where(s => s.Email.Contains(account.Email)); } if (!string.IsNullOrEmpty(account.DisplayName)) { accountList = accountList.Where(s => s.DisplayName.Contains(account.DisplayName)); } if (!string.IsNullOrEmpty(account.Phone)) { accountList = accountList.Where(s => s.Phone.Contains(account.Phone)); } if (!string.IsNullOrEmpty(account.Role)) { accountList = accountList.Where(s => s.Role.Contains(account.Role)); } if (!string.IsNullOrEmpty(account.Status)) { accountList = accountList.Where(s => s.Status.Contains(account.Status)); } if (account.GalleryId != 0) { accountList = accountList.Where(s => s.GalleryId == account.GalleryId); } if (account.IsBeautyArtist != false) { accountList = accountList.Where(s => s.IsBeautyArtist == true); } if (pageSize == 0) { pageSize = 20; } if (pageIndex == 0) { pageIndex = 1; } var pagedModel = _pagingSupport.From(accountList) .GetRange(pageIndex, pageSize, s => s.Id) .Paginate <AccountVM>(); if (withRateScore) { pagedModel.Content = pagedModel.Content.AsEnumerable().Select <AccountVM, AccountVM>(_ => { var rating = _feedBackService.GetRateScoreByAccount(_.Id); _.RateScore = rating[0]; _.TotalFeedback = (int)rating[1]; List <ServiceVM> services = new List <ServiceVM>(); foreach (ServiceVM service in _.Services) { Gallery gallery = _galleryService .GetAll(_ => _.Images) .Where(_ => _.Id == service.GalleryId).FirstOrDefault(); GalleryVM galleryVM = _mapper.Map <GalleryVM>(gallery); service.Gallery = galleryVM; services.Add(service); } _.Services = services; return(_); }).AsQueryable(); } return(Ok(pagedModel)); } catch (Exception e) { return(NotFound(e)); } }
protected override async void OnNavigatedTo(NavigationEventArgs e) { Debug.Assert(e.Parameter != null, "e.Parameter != null"); base.OnNavigatedTo(e); var reset = e.NavigationMode == NavigationMode.New; var restore = e.NavigationMode == NavigationMode.Back; this.ViewModel = GalleryVM.GetVM((long)e.Parameter); var idx = this.ViewModel.View.CurrentPosition; this.ViewModel.View.IsCurrentPositionLocked = false; if (reset) { changeViewTo(false, true); this.gv.ScrollIntoView(this.ViewModel.Gallery.First()); if (this.ViewModel.Gallery.Comments.IsLoaded) { this.lv_Comments.ScrollIntoView(this.lv_Comments.Items.FirstOrDefault()); } else { void handler(object s, System.ComponentModel.PropertyChangedEventArgs args) { var sender = (ExClient.Galleries.Commenting.CommentCollection)s; if (string.IsNullOrEmpty(args.PropertyName) || args.PropertyName == nameof(sender.IsLoaded)) { sender.PropertyChanged -= handler; if (!sender.IsEmpty) { this.lv_Comments.ScrollIntoView(sender[0]); } } } this.ViewModel.Gallery.Comments.PropertyChanged += handler; } this.lv_Torrents.ScrollIntoView(this.lv_Torrents.Items.FirstOrDefault()); await Task.Delay(33); this.pv.Focus(FocusState.Programmatic); this.pv.SelectedIndex = 0; } else if (restore) { var animation = ConnectedAnimationService.GetForCurrentView().GetAnimation("ImageAnimation"); changeViewTo(true, true); if (this.ViewModel.View.CurrentItem is null) { this.ViewModel.View.MoveCurrentToFirst(); idx = 0; } this.gv.ScrollIntoView(this.ViewModel.View.CurrentItem, ScrollIntoViewAlignment.Leading); await Dispatcher.Yield(CoreDispatcherPriority.Low); var container = (Control)this.gv.ContainerFromIndex(idx); if (container != null && this.pv.SelectedIndex == 0) { container.Focus(FocusState.Programmatic); } if (animation != null) { if (this.pv.SelectedIndex == 0 && container != null) { await this.gv.TryStartConnectedAnimationAsync(animation, this.ViewModel.View.CurrentItem, "Image"); } else { animation.Cancel(); } } await Dispatcher.YieldIdle(); container = (Control)this.gv.ContainerFromIndex(idx); if (container != null && this.pv.SelectedIndex == 0) { container.Focus(FocusState.Programmatic); } } }