public ActionResult ImagesGroupAdd(ImagesGroupAddModel inputImagesGroup) { if (this.ModelState.IsValid) { var ImagesGroupDb = new ImagesGroup(); ImagesGroupDb.Title = inputImagesGroup.Title; ImagesGroupDb.ImagesUrls = inputImagesGroup.ImagesUrls; this.Repo.Insert(this.Context.ImagesGroups, ImagesGroupDb); return(RedirectToAction("Pictures", "Home")); } return(View(inputImagesGroup)); }
public ActionResult ImagesGroupEdit(string id) { var imagesGroupDb = this.Repo.FindOneById(this.Context.ImagesGroups, id); if (imagesGroupDb != null) { var imagesGroupViewModel = new ImagesGroupAddModel() { Id = imagesGroupDb.Id, Title = imagesGroupDb.Title, ImagesUrls = imagesGroupDb.ImagesUrls }; return(View(imagesGroupViewModel)); } return(RedirectToAction("Pictures", "Home")); }
public ActionResult ImagesGroupEdit(ImagesGroupAddModel imagesGroupInput) { if (this.ModelState.IsValid) { var imagesGroupDb = new ImagesGroup(); imagesGroupDb.Title = imagesGroupInput.Title; imagesGroupDb.ImagesUrls = new List <TwoSizeImageUrls>(); foreach (var item in imagesGroupInput.ImagesUrls) { if (item != null && !string.IsNullOrWhiteSpace(item.BigImageUrl) && !string.IsNullOrWhiteSpace(item.SmallImageUrl)) { imagesGroupDb.ImagesUrls.Add(item); } } this.Repo.Update(this.Context.ImagesGroups, imagesGroupDb, imagesGroupInput.Id); return(RedirectToAction("Pictures", "Home")); } return(View(imagesGroupInput)); }