예제 #1
0
        public static bool DislikeVideo(int id)
        {
            using (var db = new YouTubeUMLEntities())
            {
                Video video = db.Videos.FirstOrDefault(el => el.Id == id);
                video.Dislikes = ++video.Dislikes;
                db.SaveChanges();
            }

            return(true);
        }
예제 #2
0
        public static bool AddLog(string action, int uid)
        {
            using (var db = new YouTubeUMLEntities())
            {
                var log = new Log();
                db.Logs.Add(log);
                log.Action = action;
                log.UserId = uid;
                log.Type   = 1;

                db.SaveChanges();
            }
            return(true);
        }
예제 #3
0
        public static bool CreateUser(string username, string password, int type)
        {
            using (var db = new YouTubeUMLEntities())
            {
                var user = new User();
                db.Users.Add(user);
                user.UserName = username;
                user.Password = password;
                user.Type     = type;

                db.SaveChanges();
            }
            return(true);
        }
예제 #4
0
        public static bool DeleteVideo(int id)
        {
            using (var db = new YouTubeUMLEntities())
            {
                Video video = db.Videos.FirstOrDefault(el => el.Id == id);
                if (video != null)
                {
                    db.Videos.Remove(video);
                    db.SaveChanges();
                }
            }

            return(true);
        }
예제 #5
0
        public static bool UploadVideo(string name, int userId, string URL)
        {
            using (var db = new YouTubeUMLEntities())
            {
                var video = new Video();
                db.Videos.Add(video);
                video.Title      = name;
                video.URL        = URL;
                video.UploaderId = userId;

                db.SaveChanges();
            }
            return(true);
        }
예제 #6
0
        public static bool CommentVideo(int vid, string msg, int uid)
        {
            using (var db = new YouTubeUMLEntities())
            {
                if (db.Videos.FirstOrDefault(el => el.Id == vid) != null)
                {
                    Comment comment = new Comment();

                    comment.Message = msg;
                    comment.UserId  = uid;
                    comment.VideoId = vid;

                    db.Comments.Add(comment);
                    db.SaveChanges();
                }
            }

            return(true);
        }