public async Task InsertAsync(PhotoGalleryModel photoGalleryModel) { await CreateTableIfNotExistsAsync(); await WaitForTableWillBeReadyToModifyAsync(); await Context.SaveAsync(photoGalleryModel); }
public PhotoGalleryListModel PrePareGalleryListModel(PhotoGalleryPagingFilteringModel command) { var model = new PhotoGalleryListModel(); if (command.PageSize <= 0) { command.PageSize = 15; } if (command.PageNumber <= 0) { command.PageNumber = 1; } var galeries = _galleryService.GetAllPhotoGalleries(photoGaleryId: 3, pageIndex: command.PageNumber - 1, pageSize: command.PageSize); model.PhotoGalleryPagingFilteringModel.LoadPagedList(galeries); model.PhotoGalleryModels = galeries.Select(x => { var photoGalleriModel = new PhotoGalleryModel(); PreParePhotoGalleryModel(photoGalleriModel, x); return(photoGalleriModel); }).ToList(); var galeri = _galleryService.GetPhotoGalleries().Where(x => x.Id != 3); model.GalleryModels = galeri.Select(x => { var galleryModel = PrePareGalleryModel(x.Id); return(galleryModel); }).ToList(); return(model); }
public async Task DeleteAsync(string id) { await CreateTableIfNotExistsAsync(); await WaitForTableWillBeReadyToModifyAsync(); PhotoGalleryModel photoGalleryModelToDelete = await FindAsync(id); await Context.DeleteAsync <PhotoGalleryModel>(photoGalleryModelToDelete); }
public PhotoGalleryModel PreParePhotoGalleryModel(PhotoGalleryModel model, PhotoGalleryMapping photoGallery) { if (photoGallery == null) { return(new PhotoGalleryModel()); } model.Id = photoGallery.Id; model.DisplayOrder = photoGallery.DisplayOrder; model.Url = photoGallery.Url; model.PictureModels = PreParePictureModel(photoGallery.PictureId); return(model); }
public static PhotoGalleryResponse ToPhotoGalleryResponse(this PhotoGalleryModel photoGalleryModel) { var photoGalleryResponse = new PhotoGalleryResponse(); if (photoGalleryModel == null) { return(photoGalleryResponse); } photoGalleryResponse.Id = photoGalleryModel.Id; photoGalleryResponse.Name = photoGalleryModel.Name; return(photoGalleryResponse); }
public async Task <PhotoGalleryModel> FindAsync(string id) { await CreateTableIfNotExistsAsync(); await WaitForTableWillBeReadyToModifyAsync(); PhotoGalleryModel photoGalleryModel = await Context.LoadAsync <PhotoGalleryModel>(id); if (photoGalleryModel == null) { throw new NotFoundException($"The photo by id {id} not exists"); } return(photoGalleryModel); }
public IActionResult GalleryCreate(PhotoGalleryModel model) { if (!string.IsNullOrEmpty(model.Name)) { PhotoGallery result = new PhotoGallery { Name = model.Name, Id = model.Id, Published = model.Published, DisplayOrder = model.DisplayOrder }; _photoGalleryRepository.Insert(result); } return(new NullJsonResult()); }
public virtual IActionResult Edit(int id) { PhotoGallery galery = _photoGalleryRepository.GetById(id); if (galery == null) { return(RedirectToAction("List")); } PhotoGalleryModel model = new PhotoGalleryModel { Id = galery.Id, Name = galery.Name, Published = galery.Published, }; model.GalleryPictureSearchModel.GaleriId = galery.Id; model.GalleryPictureSearchModel.SetGridPageSize(); return(View(model)); }
public virtual IActionResult GalleryEdit(PhotoGalleryModel model) { if (!ModelState.IsValid) { return(Json(new DataSourceResult { Errors = ModelState.SerializeErrors() })); } PhotoGallery result = _photoGalleryRepository.GetById(model.Id); if (result == null) { return(new NullJsonResult()); } result.Name = model.Name; result.DisplayOrder = model.DisplayOrder; result.Published = model.Published; _photoGalleryRepository.Update(result); return(new NullJsonResult()); }
public static IList <PhotoGalleryModel> GetGalleries(string virtualPath) { var physicalPath = HostingEnvironment.MapPath(virtualPath); var galleries = new SortedList <string, PhotoGalleryModel>(new DescendingComparer()); var dir = new DirectoryInfo(physicalPath); foreach (var subDir in dir.GetDirectories("????-??-??")) { DateTime galleryDate; DateTime.TryParseExact(subDir.Name, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out galleryDate); var gallery = new PhotoGalleryModel(virtualPath + "/" + subDir.Name, galleryDate); galleries.Add(subDir.Name, gallery); foreach (var file in subDir.GetFiles("*.jpg")) { var size = ImageHelper.GetDimensions(file.FullName); gallery.Photos.Add(new PhotoModel(file.Name, size.Orientation())); } } return(galleries.Values); }
public virtual IActionResult GalleryList(PhotoGallerySearchModel searchModel) { IQueryable <PhotoGallery> query = _photoGalleryRepository.Table; if (searchModel.SearchGalleryId != 0) { query = from g in query join m in _photoGalleryMapRepository.Table on g.Id equals m.GalleryId where m.GalleryId == searchModel.SearchGalleryId select g; } if (!string.IsNullOrEmpty(searchModel.SearchName)) { query = query.Where(x => x.Name.Contains(searchModel.SearchName)); } List <PhotoGallery> pagelists = query.ToList(); PagedList <PhotoGallery> pageList = new PagedList <PhotoGallery>(pagelists, searchModel.Page - 1, searchModel.PageSize); PhotoGalleryListModel model = new PhotoGalleryListModel { Data = pageList.PaginationByRequestModel(searchModel).Select(x => { PhotoGalleryModel galerModel = new PhotoGalleryModel { Id = x.Id, Name = x.Name, DisplayOrder = x.DisplayOrder, Published = x.Published }; return(galerModel); }), Total = pageList.Count }; return(Json(model)); }
public MvcPhotoGallery Bind(PhotoGalleryModel model) { Gallery = model; return this; }
public virtual ActionResult PhotoAdded(PhotoGalleryModel gallery) { return(PartialView("EditPhotoGalleryPartial", gallery)); }
public MvcPhotoGallery Bind(PhotoGalleryModel model) { Gallery = model; return(this); }