Пример #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
        //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;
            }
        }