Ejemplo n.º 1
0
 public ActionResult AddComment(int videoId, string comment)
 {
     using (var db = new MyUtubeDatabaseEntities())
     {
         var commentObj = new Comment
         {
             Content = comment,
             VideoId = videoId,
             UserId  = CurrentSession.CurrentUser.Id,
             //Cr = CurrentSession.CurrentUser.Id,
             //CreatedOn = DateTime.Now,
             //IsActive = true,
         };
         db.Comments.Add(commentObj);
         db.SaveChanges();
         return(Json(new { Success = true }));
     }
 }
Ejemplo n.º 2
0
 public ActionResult CreateNewChannel(ChannelViewModel model)
 {
     using (var db = new MyUtubeDatabaseEntities())
     {
         var newChannel = new Channel
         {
             Name        = model.ChannelName,
             Description = model.ChannelDescription,
             UserId      = CurrentSession.CurrentUser.Id
         };
         db.Channels.Add(newChannel);
         db.SaveChanges();
         return(Json(new
         {
             Success = true,
             ChannelId = newChannel.Id,
             ChannelName = newChannel.Name
         }));
     }
 }
Ejemplo n.º 3
0
 public ActionResult UploadVideo(VideoViewModel model)
 {
     using (var db = new MyUtubeDatabaseEntities())
     {
         var newVideo = new Video
         {
             Name        = model.VideoName,
             Description = model.VideoDescription,
             URL         = model.VideoUrl,
             ChannelId   = model.ChannelDropDown,
             UserId      = CurrentSession.CurrentUser.Id,
             CreatedOn   = DateTime.Now,
             CreatedBy   = CurrentSession.CurrentUser.Id,
             IsActive    = true
         };
         db.Videos.Add(newVideo);
         db.SaveChanges();
         return(Json(new { Success = true, VideoId = newVideo.Id }));
     }
 }
Ejemplo n.º 4
0
        public ActionResult Register(RegisterViewModel model)
        {
            //logic saving register detail in the User table

            using (var db = new MyUtubeDatabaseEntities())
            {
                var newUser = new User
                {
                    Username  = model.Username,
                    Email     = model.Email,
                    Password  = model.Password,
                    CreatedOn = DateTime.Now,
                    IsActive  = true,
                };
                db.Users.Add(newUser);
                db.SaveChanges();
                //save the cookie in browers
                FormsAuthentication.SetAuthCookie(model.Username, true);
                ResetCurrentUserSession(model.Username);

                return(RedirectToAction("Index", "Home"));
            }
        }