Esempio n. 1
0
        /// <summary>
        /// Deletes the specified EgmMetric entity.
        /// </summary>
        /// <param name="egmMetric">The EgmMetric entity to delete.</param>
        public void Delete(EgmMetric egmMetric)
        {
            using (var context = new HmsDbContext())
            {
                if (!context.EgmMetrics.Any(mr => mr.Id == egmMetric.Id))
                {
                    return;
                }

                // matching PK found, thus we proceed with Delete
                DaoUtilities.DeleteEntity(context, context.EgmMetrics, egmMetric);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Updates the state of the existing entity.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="entityEntry">The entity entry.</param>
        /// <param name="egmMetric">The egm metric.</param>
        private static void UpdateExistingEntityState(HmsDbContext context, DbEntityEntry entityEntry,
                                                      EgmMetric egmMetric)
        {
            var metricEntity = (EgmMetric)entityEntry.Entity;

            if (!metricEntity.SentAt.Equals(egmMetric.SentAt))
            {
                metricEntity.SentAt = egmMetric.SentAt;
            }

            if (!metricEntity.ReportGuid.Equals(egmMetric.ReportGuid))
            {
                metricEntity.ReportGuid = egmMetric.ReportGuid;
            }

            DaoUtilities.UpdateVersion(context, entityEntry);
        }
Esempio n. 3
0
        /// <summary>
        /// Saves the specified EgmMetric.
        /// </summary>
        /// <param name="egmMetric">The EgmMetric to save.</param>
        public void Save(EgmMetric egmMetric)
        {
            using (var context = new HmsDbContext())
            {
                //context.Database.Log = Console.Write;

                if (!context.EgmMetrics.Any(metric => metric.Id == egmMetric.Id))
                {
                    // no matching PK for this EgmMetric in database,
                    // thus we create new entity and add it to db
                    DaoUtilities.SaveCreatedEntity(context, context.EgmMetrics, egmMetric, SetNewEntityState);
                }
                else
                {
                    // matching PK found, thus we update state of existing EgmMetric entity
                    DaoUtilities.SaveUpdatedEntity(context, context.EgmMetrics, egmMetric, UpdateExistingEntityState);
                }
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Sets the new state of the entity.
 /// </summary>
 /// <param name="entity">The entity.</param>
 private static void SetNewEntityState(EgmMetric entity)
 {
     entity.Version = 0;
     entity.Hash    = GenerateHash(entity);
 }
Esempio n. 5
0
 /// <summary>
 /// Generates the hash for an EgmMetric entity.
 /// </summary>
 /// <param name="egmMetric">The EgmMetric to hash.</param>
 /// <returns>System.String.</returns>
 public static string GenerateHash(EgmMetric egmMetric)
 {
     return(GenerateHash(egmMetric.Type.ToString(), egmMetric.Value, egmMetric.EgmSerialNumber, egmMetric.ReadAt,
                         egmMetric.CasinoCode));
 }