Exemple #1
0
        public static Models.User GetUser()
        {
            YoyoEntities db = new YoyoEntities();

            string username = Membership.GetUser().UserName;

            Models.User u = db.Users.Where(x => x.UserName == username).FirstOrDefault();

            return u;
        }
Exemple #2
0
        public JsonResult GetComments(int videoId)
        {
            YoyoEntities db = new YoyoEntities();

            var comm = from c in db.Comments
                       where c.VideoId == videoId
                       select new CommentDTO
                       {
                           Id = c.Id,
                           Text = c.Text,
                           Username = c.aspnet_Users.UserName,
                           Date = c.Date,
                           Photo=c.aspnet_Users.Picture.Link
                       };

            return Json(comm.ToList());
        }
Exemple #3
0
        public JsonResult GetComment(int id)
        {
            YoyoEntities db = new YoyoEntities();

            var comm = from c in db.Comments
                       where c.Id == id
                       select new CommentDTO
                       {
                           Id = c.Id,
                           Text = c.Text,
                           Username = c.aspnet_Users.UserName,
                           Date = c.Date,
                           Photo = c.aspnet_Users.Picture.Link
                       };

            return Json(new {comment=comm.FirstOrDefault() });
        }
Exemple #4
0
        public JsonResult VideoPlayed(int id)
        {
            string userId = "";

            if (Request.Cookies["userId"] == null)
            {

                if (!User.Identity.IsAuthenticated)
                {
                    userId = Guid.NewGuid().ToString();
                }
                else
                {
                    userId = Membership.GetUser().ProviderUserKey.ToString();
                }

                HttpCookie c = new HttpCookie("userId");
                c.Expires=DateTime.Now.AddDays(60);

                c.Value = userId;
                Response.Cookies.Add(c);
            }
            else{

                userId = Request.Cookies["userId"].Value;
            }

            YoyoEntities db = new YoyoEntities();

            Guid uid = new Guid(userId);

            if (db.Ratings.Where(x => x.UserId == uid & x.VideoId == id).FirstOrDefault() == null)
            {
                Rating r = new Rating();

                r.VideoId = id;
                r.UserId = uid;
                r.Date = DateTime.Now;
                db.Ratings.Add(r);
                db.SaveChanges();
            }

            return Json(1);
        }
Exemple #5
0
        public JsonResult SendComment(string com, int videoId)
        {
            Comment c = new Comment();
            c.Text = com;
            c.VideoId = videoId;
            c.UserId = Helper.GetUser().UserId;
            c.Date = DateTime.Now;

            YoyoEntities db = new YoyoEntities();
            db.Comments.Add(c);
            db.SaveChanges();

            return Json(new { commentId = c.Id });
        }