public ActionResult Images(Int32 id) { var galeryImages = db.GaleryImagesList.Where(x => x.GaleryId == id).Where(x => !x.IsDeleted).OrderBy(x => x.Order).ToList(); var model = new List <GaleryImageViewModel>(); foreach (var item in galeryImages) { var image = db.ImagesList.Find(item.ImageId); var modelItem = new GaleryImageViewModel() { GaleryImageId = item.GaleryImageId, Image = image, ImageId = image.ImageId, Title = item.Title, Description = item.Description, Order = item.Order }; model.Add(modelItem); } ViewBag.GaleryId = id; ViewBag.ImageId = new SelectList(db.ImagesList.OrderBy(x => x.Title), "ImageId", "Code"); return(View(model)); }
public ActionResult DeleteGaleryImage(GaleryImageViewModel model) { if (!GaleryService.DeleteGaleryImage(model.GaleryImageId)) { SetMessage("Lo sentimos, no hemos podido eliminar la imagen de la galería. Inténtelo de nuevo.", BootstrapAlertTypes.Danger); return(View(model)); } SetMessage("Imagen de la galería eliminada exitosamente.", BootstrapAlertTypes.Success); return(RedirectToAction("Add", new { id = model.GaleryId })); }
public GaleryImageViewModel GetGaleryImageById(Int32 id) { var image = Repository.GaleryImages().SingleOrDefault(x => x.GaleryImageId == id); if (image == null) { return(null); } var model = new GaleryImageViewModel() { GaleryId = image.GaleryId, GaleryImageId = image.GaleryImageId, Image = Repository.Images().SingleOrDefault(x => x.ImageId == image.ImageId), ImageId = Repository.Images().SingleOrDefault(x => x.ImageId == image.ImageId).ImageId }; return(model); }