public IActionResult AddUpdateGllery(ModelGallery MG) { if (!ModelState.IsValid) { TempData["Action"] = Constants.FAILED; return(View(MG)); } try { if (MG.GalleryId > 0) { MG.DateUpdated = DateTime.Now; OurdbContext.Gallery.Update(CopyMGToG(MG)); OurdbContext.SaveChanges(); } else { OurdbContext.Gallery.Add(CopyMGToG(MG)); OurdbContext.SaveChanges(); } } catch (Exception) { TempData["action"] = Constants.FAILED; } return(RedirectToAction(nameof(AdministratorController.GalleryList))); }
public IActionResult AddUpdateGllery() { ModelGallery G = new ModelGallery(); G.DateCreated = DateTime.Now; return(View(G)); }
public ActionResult Albums(int id) { var model = new ModelGallery() { Album = MainServices.Albums.GetAlbumInfo(CurrentLang, id), Photos = MainServices.Albums.GetAlbumPhotos(id) }; return(View(model)); }
// GET: Gallery public ActionResult Index(TableFilterModel data) { var model = new ModelGallery() { Seo = MainServices.Modules.GetCurrentPageSeo(CurrentLang.Id, EnumSitePage.Gallery), //Albums = MainServices.Albums.GetAlbumList(data,CurrentLang), Videos = MainServices.Albums.GetGalleryVideos(CurrentLang) }; return(View(model)); }
public ActionResult DeleteAImage(Guid id, ModelGallery Image) { var p = imageRepo.GetAllImages().FirstOrDefault(x => x.Id == id); string fullPath = Request.MapPath("~/Images/" + p.Name); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); imageRepo.Delete(id); } return(RedirectToAction("Gallery")); }
private ModelGallery CopyGToMG(Gallery G) { ModelGallery MG = new ModelGallery { GalleryId = G.GalleryId, GalleryImageName = G.GalleryImageName, GalleryImageDescription = G.GalleryImageDescription, DateCreated = G.DateCreated, DateUpdated = G.DateUpdated, }; return(MG); }
private Gallery CopyMGToG(ModelGallery MG) { Gallery G = new Gallery { GalleryId = MG.GalleryId, GalleryImageName = MG.GalleryImageName, GalleryImageDescription = MG.GalleryImageDescription, DateCreated = MG.DateCreated, DateUpdated = MG.DateUpdated, }; return(G); }
public void Add(ModelGallery image) { using (var ctx = new Labb1Context()) { var newImage = new ModelGallery { Id = Guid.NewGuid(), Name = image.Name, dateAdded = DateTime.Now }; ctx.image.Add(newImage); ctx.SaveChanges(); } }
public ActionResult Upload(ModelGallery Image, HttpPostedFileBase file) { if (!ModelState.IsValid) { return(View(Image)); } if (file == null) { ModelState.AddModelError("Error", "Det finns ingen bild att ladda upp?"); return(View(Image)); } file.SaveAs(Path.Combine(Server.MapPath("~/Images"), file.FileName)); Image.Name = file.FileName; imageRepo.Add(Image); return(View()); }
public void AddComment(ModelGallery image, string ImageComment) { using (var ctx = new Labb1Context()) { var CommentImage = ctx.image.First(a => a.Id == image.Id); if (CommentImage != null) { var MYCOMMENT = new Comments() { CommentsImages = ImageComment, ModelGallery_Id = CommentImage }; ctx.comment.Add(MYCOMMENT); ctx.SaveChanges(); } } }
public NewGalleryController() { _modelGallery = new ModelGallery(); _galleriesContext = new FashionSiteContext(); }