Beispiel #1
0
 public ActionResult <Video> Create([FromBody] Video newVideo)
 {
     try
     {
         return(Ok(_vs.Create(newVideo)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("VideosId,ProfileId,NrLikes,NrDislikes,NrComments,Video,Type")] Videos videos)
        {
            var profileId = userManager.GetUserId(HttpContext.User);

            if (ModelState.IsValid)
            {
                videoService.Create(videos, profileId);
                //videos.
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProfileId"] = new SelectList(videoService.GetAllProfiles(), "ProfileId", "ProfileId");
            return(View(videos));
        }
Beispiel #3
0
        public async Task DeleteShouldBeSuccessfull()
        {
            var options = new DbContextOptionsBuilder <SportsNewsContext>()
                          .UseInMemoryDatabase(databaseName: "VideosTests2")
                          .Options;

            var dbContext = new SportsNewsContext(options);

            var repository    = new DbRepository <Video>(dbContext);
            var videosService = new VideosService(repository);

            await videosService.Create(1, "dasasd");

            await videosService.Create(1, "dasasd");

            var id = repository.All().FirstOrDefault().Id;
            await videosService.Delete(id);

            var count = repository.All().Count();

            Assert.Equal(1, count);
        }
Beispiel #4
0
        public async Task CreateArticleShouldBeSuccessfull()
        {
            var options = new DbContextOptionsBuilder <SportsNewsContext>()
                          .UseInMemoryDatabase(databaseName: "VideosTests")
                          .Options;

            var dbContext = new SportsNewsContext(options);

            var repository    = new DbRepository <Video>(dbContext);
            var videosService = new VideosService(repository);

            await videosService.Create(1, "test");

            var count = repository.All().Count();

            Assert.Equal(1, count);
        }