Exemplo n.º 1
0
        public ActionResult Create( ShowModel model )
        {
            if ( ModelState.IsValid )
            {
                Show showObj = Service.GetShowByName( model.Name );
                if ( showObj != null )
                {
                    ModelState.AddModelError( "Name", "Show Already Exists" );
                    return View( model );
                }
                showObj = new Show { Name = model.Name, Description = model.Description };
                Service.AddShow( showObj );
                return RedirectToAction( "Index", new { show = showObj.Name } );
            }

            return View();
        }
Exemplo n.º 2
0
        public ActionResult Edit( ShowModel model )
        {
            try
            {
                if ( ModelState.IsValid )
                {
                    Show showObj = Service.GetShowByName( model.Name );
                    if ( showObj == null )
                    {
                        ModelState.AddModelError( "Name", "Show does not exist" );
                    }
                    showObj.Name = model.Name;
                    showObj.Description = model.Description;

                    return RedirectToAction( "Index" );
                }
            }
            catch
            {
                return new HttpStatusCodeResult( ( int ) HttpStatusCode.InternalServerError );
            }
            return View( model );
        }