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); }
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); }
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); }
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); }
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); }
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); }