コード例 #1
0
        public IActionResult Create(VideoEditViewModel model)
        {
            var video = new Video
            {
                Title = model.Title,
                Genre = model.Genre
            };

            _videos.Add(video);
            return(RedirectToAction("Details", new { id = video.Id }));
        }
コード例 #2
0
 public IActionResult Create(VideoEditViewModel model)
 {
     if (ModelState.IsValid)
     {
         var video = new Video
         {
             Title = model.Title,
             Genre = model.Genre
         };
         _videos.Add(video);
         _videos.Commit();
         return(RedirectToAction("Details", new { Id = video.Id }));
     }
     return(View());
 }
コード例 #3
0
        public IActionResult Create(VideoEditViewModel model) // using VideoEditViewModel as the model to base the fields for the form on
        {
            if (ModelState.IsValid)
            {
                var video = new Video // Here we match the form inputs to the respective properties in the ViewModel
                {
                    Title = model.Title,
                    Genre = model.Genre
                };
                _videos.Add(video);
                _videos.Commit();
                return(RedirectToAction("Details", new { id = video.Id }));
            }

            return(View());
        }
コード例 #4
0
 public IActionResult OnPost(Videos VideoDetails)
 {
     if (VidImage != null)
     {
         VideoDetails.VideoImage = UploadedImage(VidImage);
     }
     if (ModelState.IsValid)
     {
         Message = addVideo.Add(VideoDetails);
         if (Message == "New Video Added")
         {
             addVideo.Commit();
             return(RedirectToPage("./VideosList"));
         }
     }
     return(Page());
 }
コード例 #5
0
        public IActionResult Create(VideoEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                var video = new Video
                {
                    Title = model.Title,
                    Genre = model.Genre
                };

                _videos.Add(video); // Add is the method from IVideoData  ---  void Add(Video newVideo);
                _videos.Commit();   // ???

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