예제 #1
0
파일: User.cs 프로젝트: pminkevich/Repos
        public bool VideoVisto(Model.Videos Video)
        {
            bool estado = false;

            try
            {
                using (Model.AntiProcrastineEntities db = new Model.AntiProcrastineEntities())
                {
                    Video.ESTADO = "Visto";

                    db.Entry(Video).State = System.Data.Entity.EntityState.Modified;

                    db.SaveChanges();
                }

                estado = true;
            }
            catch (Exception Ex)
            {
                string Error = Ex.Message;
                estado = false;
            }

            return(estado);
        }
예제 #2
0
        private void GuardarChannel(YouTubeAPI obj, int total)
        {
            List <Model.Videos> Videos = new List <Model.Videos>();

            try
            {
                using (Model.AntiProcrastineEntities db = new Model.AntiProcrastineEntities())
                {
                    for (int i = 0; i < total; i++)
                    {
                        Model.Videos Video = new Model.Videos();

                        Video.Id_Video = obj.items[i].id.videoId;
                        Video.Nombre   = obj.items[i].snippet.title;
                        Video.Url      = "https://www.youtube.com/embed/" + obj.items[i].id.videoId;
                        Video.ESTADO   = "Listo";
                        Videos.Add(Video);
                    }
                    if (total > 0)
                    {
                        db.Videos.AddRange(Videos);
                        // db.Entry(Videos).State = System.Data.Entity.EntityState.Added;
                        db.SaveChanges();
                    }
                    //return total;
                }
            }
            //cath para saber sobre error en Entity Framework
            //catch (DbEntityValidationException ex)
            //{
            //    StringBuilder sb = new StringBuilder();

            //    foreach (var failure in ex.EntityValidationErrors)
            //    {
            //        sb.AppendFormat("{0} failed validation\n", failure.Entry.Entity.GetType());
            //        foreach (var error in failure.ValidationErrors)
            //        {
            //            sb.AppendFormat("- {0} : {1}", error.PropertyName, error.ErrorMessage);
            //            sb.AppendLine();
            //        }
            //    }
            //    //return total;
            //    throw new DbEntityValidationException(
            //        "Entity Validation Failed - errors follow:\n" +
            //        sb.ToString(), ex

            //    ); // Add the original exception as the innerException



            //}
            catch (Exception ex)
            {
                string Error = ex.Message;
                // return total;
            }
        }
예제 #3
0
파일: User.cs 프로젝트: pminkevich/Repos
        public YoutubeUser GetInfoVideo(Model.Videos Video)
        {
            string ApiYouTube = "&key=ApiYouTube";

            /*esto es para una futura version que calcule en tiempo del video y pueda estar
             * reproduciendose hasta que finalice*/
            var json = new WebClient().DownloadString("https://www.googleapis.com/youtube/v3/videos?part=contentDetails&id=" + Video.Id_Video.ToString() + ApiYouTube);
            ////Vuelco el Json a YoutubeUser
            YoutubeUser VideoYouTube = JsonConvert.DeserializeObject <YoutubeUser>(json);

            return(VideoYouTube);
        }
예제 #4
0
파일: User.cs 프로젝트: pminkevich/Repos
 public Model.Videos FirstVideo()
 {
     try
     {
         using (Model.AntiProcrastineEntities db = new Model.AntiProcrastineEntities())
         {
             FVideo = db.Videos.First(x => x.ESTADO == "Listo");
         }
         return(FVideo);
     }
     catch (Exception ex)
     {
         string error = ex.Message;
         throw;
     }
 }
예제 #5
0
파일: User.cs 프로젝트: pminkevich/Repos
 public User()
 {
     Lista  = new List <Model.Videos>();
     FVideo = new Model.Videos();
 }