コード例 #1
0
        /// <summary>
        /// Deletes the specified EgmVersion entity.
        /// </summary>
        /// <param name="egmVersion">The EgmVersion entity to delete.</param>
        public void Delete(EgmVersion egmVersion)
        {
            using (var context = new HmsDbContext())
            {
                if (!context.EgmVersions.Any(v => v.Id == egmVersion.Id))
                {
                    return;
                }

                // matching PK found, thus we proceed with Delete
                DaoUtilities.DeleteEntity(context, context.EgmVersions, egmVersion);
            }
        }
コード例 #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="egmVersion">The egm version data.</param>
        private static void UpdateExistingEntityState(HmsDbContext context, DbEntityEntry entityEntry,
                                                      EgmVersion egmVersion)
        {
            var entity = (EgmVersion)entityEntry.Entity;

            if (!entity.SentAt.Equals(egmVersion.SentAt))
            {
                entity.SentAt = egmVersion.SentAt;
            }

            if (!entity.ReportGuid.Equals(egmVersion.ReportGuid))
            {
                entity.ReportGuid = egmVersion.ReportGuid;
            }

            DaoUtilities.UpdateVersion(context, entityEntry);
        }
コード例 #3
0
        /// <summary>
        /// Saves the specified EgmVersion.
        /// </summary>
        /// <param name="egmVersion">The EgmVersion to save.</param>
        public void Save(EgmVersion egmVersion)
        {
            using (var context = new HmsDbContext())
            {
                //context.Database.Log = Console.Write;

                if (!context.EgmVersions.Any(version => version.Id == egmVersion.Id))
                {
                    // no matching PK for this EgmVersion in database,
                    // thus we create new entity and add it to db
                    DaoUtilities.SaveCreatedEntity(context, context.EgmVersions, egmVersion, SetNewEntityState);
                }
                else
                {
                    // matching PK found, thus we update state of existing EgmVersion entity
                    DaoUtilities.SaveUpdatedEntity(context, context.EgmVersions, egmVersion, UpdateExistingEntityState);
                }
            }
        }
コード例 #4
0
 /// <summary>
 /// Generates the hash for the specified EgmVersion entity.
 /// </summary>
 /// <param name="egmVersion">The egm version.</param>
 /// <returns>System.String.</returns>
 public static string GenerateHash(EgmVersion egmVersion)
 {
     return(GenerateHash(egmVersion.ObjectName, egmVersion.VersionInfo, egmVersion.EgmSerialNumber, egmVersion.CasinoCode));
 }
コード例 #5
0
 /// <summary>
 /// Sets the new state of the entity.
 /// </summary>
 /// <param name="entity">The entity.</param>
 private static void SetNewEntityState(EgmVersion entity)
 {
     entity.Version = 0;
     entity.Hash    = GenerateHash(entity);
 }