Ejemplo n.º 1
0
        public static void TrySaveChanges(ref JustPressPlayDBEntities db)
        {
            try
            {
                db.SaveChanges();
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                    }
                }

                throw dbEx;
            }
        }
Ejemplo n.º 2
0
        public static void LogSingleEntry(LoggerModel loggerModel, JustPressPlayDBEntities _dbContext, bool autoSave = false)
        {
            log newLogEntry = new log()
            {
                action     = loggerModel.Action,
                ip_address = loggerModel.IPAddress,
                id_type_1  = loggerModel.IDType1 == null ? null : loggerModel.IDType1,
                id_type_2  = loggerModel.IDType2 == null ? null : loggerModel.IDType2,
                id_1       = loggerModel.ID1 == null ? null : loggerModel.ID1,
                id_2       = loggerModel.ID2 == null ? null : loggerModel.ID2,
                timestamp  = loggerModel.TimeStamp,
                user_id    = loggerModel.UserID,
                value_1    = loggerModel.Value1 == null? null : loggerModel.Value1,
                value_2    = loggerModel.Value2 == null? null : loggerModel.Value2,
            };

            _dbContext.log.Add(newLogEntry);

            if (autoSave)
            {
                _dbContext.SaveChanges();
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Saves all database changes for this unit of work
 /// </summary>
 /// <returns>The number of objects written to the database</returns>
 public int SaveChanges()
 {
     return(_entityContext.SaveChanges());
 }