예제 #1
0
        public ActionResult Add(Video model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var video = _videoService.Add(model);

            return(RedirectToRoute("ArtistDetails", new { id = model.ArtistId }));
        }
예제 #2
0
        public IActionResult CreateVideo(Video newVid, IFormFile ImageUrl)
        {
            if (ImageUrl != null)
            {
                newVid.ImageUrl = "/images/assets/" + ImageUrl.FileName;
                var fileName = Path.Combine(he.WebRootPath + "/images/assets", Path.GetFileName(ImageUrl.FileName));
                ImageUrl.CopyTo(new FileStream(fileName, FileMode.Create));
            }
            _videos.Add(newVid);

            // return Content(mess);
            return(RedirectToAction("ListVideo"));
        }
예제 #3
0
        public IActionResult Create(VideoEditViewModel 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());
        }
예제 #4
0
 public ActionResult <Video> Post(VideoDTO DTO)
 {
     try
     {
         if (_lesmateriaalRepository.GetBy(DTO.LesMateriaalId) == null)
         {
             return(BadRequest("Het opgegeven lesmateriaal kon niet worden gevonden!"));
         }
         Video a = new Video(DTO.LesMateriaalId, DTO.Adres);
         _videoRepository.Add(a);
         _videoRepository.SaveChanges();
         return(CreatedAtAction(nameof(GetBy), new { id = a.Id }, a));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }