Esempio n. 1
0
 public void SetSystemFields(VersionLock versionLock, DateTime modified)
 {
     _versionLock = versionLock;
     _versionId = versionLock.Id;
     _modified = modified;
     _modifiedBy = VersionLock.SessionUser;
 }
Esempio n. 2
0
 private Address(Guid id, VersionLock version, Guid customerId, string street, string city, string country, int zipCode)
     : base(id)
 {
     CustomerId = customerId;
     Street = street;
     City = city;
     ZipCode = zipCode;
     this.SetSystemFields(version, DateTime.Now);
 }
Esempio n. 3
0
        public static VersionLock Create(SqlConnection dbConnection, SqlTransaction transaction)
        {
            var selectCommand = new SqlCommand("SELECT IIF(MAX(Id) is NULL, -1, MAX(Id)) + 1 FROM VersionLock", dbConnection, transaction);
            var reader = selectCommand.ExecuteReader();
            reader.Read();
            var newId = reader.GetInt64(0);
            reader.Close();

            VersionLock version = new VersionLock(newId, 0, SessionUser, DateTime.Now);
            version.isNew = true;
            return version;
        }
Esempio n. 4
0
 private static VersionLock Load(long id, SqlConnection dbConnection)
 {
     VersionLock versionLock = null;
     try
     {
         var query = string.Format(LOAD_SQL, id);
         using (var selectCommand = new SqlCommand(query, dbConnection))
         {
             var reader = selectCommand.ExecuteReader();
             if (reader.HasRows)
             {
                 var value = reader.GetInt64(1);
                 var modifiedBy = reader.GetString(2);
                 var modified = reader.GetDateTime(3);
                 versionLock = new VersionLock(id, value, modifiedBy, modified);
                 Versions.Add(versionLock, SessionUser);
             }
             else
             {
                 throw new SystemException(string.Format("Version {0} not found.", id));
             }
             reader.Close();
         }
     }
     catch (SqlException sqlEx)
     {
         throw new SystemException("unexpected sql error loading version", sqlEx);
     }
     return versionLock;
 }
Esempio n. 5
0
 public static Address Create(Guid customerId, VersionLock version, string street, string city, string country, int zipCode)
 {
     return new Address(Guid.NewGuid(), version, customerId, street, city, country, zipCode);
 }