Ejemplo n.º 1
0
        public async Task <IActionResult> Create(VideoWatchedRequest request)
        {
            if (request != null)
            {
                var result = await _videoWatched.Create(request);

                if (result > 0)
                {
                    return(Content("Success"));
                }
            }
            return(Content("Error"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Delete(VideoWatchedRequest resquest)
        {
            if (resquest != null)
            {
                var watched = await _videoWatched.FindAsync(resquest);

                var result = await _videoWatched.Delete(watched.Id);

                if (result > 0)
                {
                    return(Content("Success"));
                }
            }
            return(Content("Error"));
        }
Ejemplo n.º 3
0
        public async Task <int> Create(VideoWatchedRequest request)
        {
            var watched = new VideoWatched();

            if (request != null)
            {
                var checkWatched = _context.VideoWatched.
                                   FirstOrDefault(X => X.VideoId == request.VideoId && X.UserId == request.UserId);
                if (checkWatched == null)
                {
                    watched.UserId  = request.UserId;
                    watched.VideoId = request.VideoId;
                    _context.VideoWatched.Add(watched);
                    return(await _context.SaveChangesAsync());
                }
            }
            return(-1);
        }
Ejemplo n.º 4
0
        public async Task <VideoWatched> FindAsync(VideoWatchedRequest request)
        {
            var watched = _context.VideoWatched.FirstOrDefault(X => X.VideoId == request.VideoId && X.UserId == request.UserId);

            return(watched);
        }