Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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));
        }