CreateGallery() public method

public CreateGallery ( string galleryName ) : int
galleryName string
return int
Beispiel #1
0
        public ActionResult New(string Name)
        {
            if (Name.IsEmpty())
                ModelState.AddModelError("Name", "You must specify a gallery name.");

            if (ModelState.IsValid)
            {
                var db = new PhotoGalleryRepository();
                var nameExists = db.GetGalleryCount(Name) > 0;

                if (nameExists)
                {
                    ModelState.AddModelError("Name", "A gallery with the supplied name already exists.");
                }
                else
                {
                    int galleryId = db.CreateGallery(Name);
                    return RedirectToAction("View", new { id = galleryId });
                }
            }

            return View();
        }