Exemplo n.º 1
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());
 }
Exemplo n.º 2
0
        public IActionResult Edit(int id, VideoEditViewModel 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 }));
        }
Exemplo n.º 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());
        }
        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());
        }
Exemplo n.º 5
0
        public IActionResult OnPost(int vidId)
        {
            var confirmdelete = deleteVideo.GetVideosById(vidId);

            if (confirmdelete == null)
            {
                return(Page());
            }
            deleteVideo.Delete(vidId);
            deleteVideo.Commit();
            return(RedirectToPage("./VideosList"));
        }
Exemplo n.º 6
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());
 }