Exemple #1
0
        /// <summary>
        /// Deletes the specified egm meter reading entity.
        /// </summary>
        /// <param name="egmMeterReading">The egm meter reading.</param>
        public void Delete(EgmMeterReading egmMeterReading)
        {
            using (var context = new HmsDbContext())
            {
                if (!context.EgmMeterReadings.Any(mr => mr.Id == egmMeterReading.Id))
                {
                    return;
                }

                // matching PK found, thus we proceed with Delete
                DaoUtilities.DeleteEntity(context, context.EgmMeterReadings, egmMeterReading);
            }
        }
Exemple #2
0
        /// <summary>
        /// Updates the state of the existing entity.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="entityEntry">The meter reading entity entry.</param>
        /// <param name="egmMeterReading">The egm meter reading.</param>
        private static void UpdateExistingEntityState(HmsDbContext context, DbEntityEntry entityEntry,
                                                      EgmMeterReading egmMeterReading)
        {
            var meterReadingEntity = (EgmMeterReading)entityEntry.Entity;

            if (!meterReadingEntity.SentAt.Equals(egmMeterReading.SentAt))
            {
                meterReadingEntity.SentAt = egmMeterReading.SentAt;
            }

            if (!meterReadingEntity.ReportGuid.Equals(egmMeterReading.ReportGuid))
            {
                meterReadingEntity.ReportGuid = egmMeterReading.ReportGuid;
            }

            DaoUtilities.UpdateVersion(context, entityEntry);
        }
Exemple #3
0
        /// <summary>
        /// Saves the specified egm meter reading.
        /// </summary>
        /// <param name="egmMeterReading">The egm meter reading.</param>
        public void Save(EgmMeterReading egmMeterReading)
        {
            using (var context = new HmsDbContext())
            {
                //context.Database.Log = Console.Write;

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