Exemple #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);
        }
Exemple #2
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;
            }
        }