public void DeleteOneVideo()
        {
            Video videoDelete = new Video
            {
                Id         = 3,
                Name       = "Deporte",
                Author     = "Pepe",
                Hour       = 0,
                MinSeconds = 3.1,
                LinkVideo  = "www.youtube.com/deportePepe"
            };

            listVideo.Add(videoDelete);
            var options = new DbContextOptionsBuilder <BetterCalmContext>()
                          .UseInMemoryDatabase(databaseName: "MSP.BetterCalmDatabase").Options;
            var context = new BetterCalmContext(options);

            listVideo.ForEach(video => context.Add(video));
            context.SaveChanges();
            repository = new VideoRepository(context);
            repository.Delete(videoDelete);
            context.Database.EnsureDeleted();
            Video getVideo = repository.Get(3);

            Assert.AreEqual(null, getVideo);
        }
Exemplo n.º 2
0
        protected void btnDelete_OnClick(object sender, EventArgs e)
        {
            string          videoID         = lblID.Text.Trim();
            VideoRepository videoRepository = new VideoRepository();
            Video           video           = videoRepository.Get(videoID);

            if (video != null)
            {
                try
                {
                    videoRepository.Delete(video);
                    RedirectToVideoList(string.Empty);
                }
                catch (Exception ex)
                {
                    displayError(ex.Message);
                }
            }
        }
Exemplo n.º 3
0
        public ActionResult Delete(Guid id, string confirmButton)
        {
            Video vid = _videoRepository.GetById(id);

            if (null == vid)
            {
                return(View("NotFound"));
            }

            //Should also delete the physical file on the server
            BlobContainer container = AzureUtility.GetAzureContainer(vid.Path);

            container.DeleteBlob(vid.Path.Substring(vid.Path.IndexOf("/") + 1));

            _videoRepository.Delete(vid);
            _videoRepository.Save();

            return(View("Deleted"));
        }