Пример #1
0
        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
 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;
     }
 }
Пример #4
0
 public List <Model.Videos> ListaVideos()
 {
     try
     {
         using (Model.AntiProcrastineEntities db = new Model.AntiProcrastineEntities())
         {
             Lista = db.Videos.Where(x => x.ESTADO == "Listo").ToList();
         }
         return(Lista);
     }
     catch (Exception ex)
     {
         string error = ex.Message;
         throw;
     }
 }
Пример #5
0
        //Metodo para grebar en bd el tiempo de ocio y de Anti Procrastine
        public void SetTime(int OcioTime, int APTime)
        {
            try
            {
                using (Model.AntiProcrastineEntities db = new Model.AntiProcrastineEntities())
                {
                    Model.AntiP AP = db.AntiP.First();

                    AP.OcioTime = OcioTime;
                    AP.APTime   = APTime;

                    db.Entry(AP).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    var e = new AjusteEventArgs();
                    e.OcioTime = OcioTime;
                    e.APTime   = APTime;

                    ChangePreset(this, e);
                }
            }
            //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();
                    }
                }

                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;
            }
        }
Пример #6
0
        public void State()
        {
            string State = "";

            try
            {
                using (Model.AntiProcrastineEntities db = new Model.AntiProcrastineEntities())
                {
                    //Reviso el Estado de ANTI PROCRASTINE
                    // y Lo agrego el StateEventArgs
                    Model.AntiP AP = db.AntiP.First();
                    State = AP.State.ToString();
                    var e = new StateEventArgs();
                    e.State = State;
                    EventState(this, e);
                }
            }
            //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();
                    }
                }

                throw new DbEntityValidationException(
                          "Entity Validation Failed - errors follow:\n" +
                          sb.ToString(), ex

                          ); // Add the original exception as the innerException
            }
            catch (Exception ex)
            {
                State = ex.Message;
            }

            //return State;
        }
Пример #7
0
        public int PorVer()
        {
            int PorVer;

            try
            {
                using (Model.AntiProcrastineEntities db = new Model.AntiProcrastineEntities())
                {
                    PorVer = db.Videos.Where(x => x.ESTADO == "Listo").Count();
                }
            }
            catch (Exception)
            {
                PorVer = 0;
                throw;
            }

            return(PorVer);
        }
Пример #8
0
        public int Vistos()
        {
            int Vistos;

            try
            {
                using (Model.AntiProcrastineEntities db = new Model.AntiProcrastineEntities())
                {
                    Vistos = db.Videos.Where(x => x.ESTADO == "Visto").Count();
                }
            }
            catch (Exception)
            {
                Vistos = 0;
                throw;
            }

            return(Vistos);
        }