示例#1
0
        public IActionResult Create(VideoCreateEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                var video = new Video
                {
                    Title = model.Title,
                    Genre = model.Genre
                };

                _videos.Add(video);

                return(RedirectToAction("Details", new { id = video.Id }));
            }
            return(View());
        }
示例#2
0
        public IActionResult Edit(int id, VideoCreateEditViewModel model)
        {
            var video = _videos.Get(id);

            if (video == null || !ModelState.IsValid)
            {
                return(View(model));
            }

            video.Title = model.Title;
            video.Genre = model.Genre;

            _videos.Commit();

            return(RedirectToAction("Details", new { id = video.Id }));
        }