Ejemplo n.º 1
0
        public IActionResult OnPost(int vidId)
        {
            var confirmdelete = deleteVideo.GetVideosById(vidId);

            if (confirmdelete == null)
            {
                return(Page());
            }
            deleteVideo.Delete(vidId);
            deleteVideo.Commit();
            return(RedirectToPage("./VideosList"));
        }
Ejemplo n.º 2
0
        public IActionResult Delete(int id)
        {
            if (id == 0)
            {
                return(BadRequest());
            }
            User user = _userData.GetById(id);

            if (user == null)
            {
                return(NotFound());
            }
            IEnumerable <Video>   userVideos   = _videoData.GetByOwnerId(user.Id);
            IEnumerable <Comment> userComments = _commentData.GetCommentsByUser(user.Id);

            foreach (var v in userVideos)
            {
                _videoData.Delete(v);
            }
            foreach (var c in userComments)
            {
                _commentData.Delete(c);
            }
            _userData.Delete(user);
            int loggedInUserId = int.Parse(HttpContext.Session.GetString("LoggedInUserId"));

            if (loggedInUserId == id)
            {
                HttpContext.Session.Remove("LoggedInUserId");
                HttpContext.Session.Remove("LoggedInUserRole");
                HttpContext.Session.Remove("LoggedInUserUsername");
            }
            var contentType = Request.ContentType;

            if (contentType != null)
            {
                if (contentType.Equals("application/json"))
                {
                    return(NoContent());
                }
                else if (contentType.Equals("text/html"))
                {
                    return(RedirectToAction(nameof(GetById), id));
                }
                else if (contentType.Equals("application/x-www-form-urlencoded"))
                {
                    return(RedirectToAction(nameof(GetById), id));
                }
                return(StatusCode(415));
            }
            return(Json("Success"));
        }
Ejemplo n.º 3
0
        public IActionResult DeleteVideo(int id)
        {
            Video video = _videoData.GetById(id);

            if (video == null)
            {
                return(NotFound());
            }
            List <Comment> comments = _commentData.GetCommentsByVideo(id).ToList();

            foreach (var c in comments)
            {
                _commentData.Delete(c);
            }
            _videoData.Delete(video);
            var contentType = Request.ContentType;

            if (contentType != null)
            {
                return(NoContent());
            }
            return(Json("Success"));
        }
Ejemplo n.º 4
0
        public void Delete(int id)
        {
            var contenido = _videoData.Get(id);

            _videoData.Delete(contenido);
        }