protected override object ReadRow(IRowReader reader) { AuditAssetHistory auditAssetHistory = AuditAssetHistory.New(); // Table Fields auditAssetHistory.AuditAssetHistoryId = reader.GetInt32("AuditAssetHistoryId"); auditAssetHistory.SessionId = reader.GetString("SessionId"); auditAssetHistory.IpAddress = reader.GetString("IpAddress"); auditAssetHistory.AuditAssetActionId = reader.GetInt32("AuditAssetActionId"); auditAssetHistory.UserId = reader.GetInt32("UserId"); auditAssetHistory.AssetId = reader.GetInt32("AssetId"); auditAssetHistory.Notes = reader.GetString("Notes"); auditAssetHistory.Date = reader.GetDateTime("Date"); // View Fields auditAssetHistory.Description = reader.GetString("Description"); auditAssetHistory.UserPrimaryBrandId = reader.GetInt32("UserPrimaryBrandId"); auditAssetHistory.AssetBrandId = reader.GetInt32("AssetBrandId"); auditAssetHistory.UserName = reader.GetString("UserName"); auditAssetHistory.UserEmail = reader.GetString("UserEmail"); auditAssetHistory.Title = reader.GetString("Title"); auditAssetHistory.IsDirty = false; auditAssetHistory.ChangedProperties.Clear(); return(auditAssetHistory); }
public virtual AuditAssetHistory Update(AuditAssetHistory auditAssetHistory) { if (!auditAssetHistory.IsDirty || auditAssetHistory.IsNull) { // Nothing to do - no point hammering the database unnecessarily return(auditAssetHistory); } IDbCommand command = CreateCommand(); if (auditAssetHistory.IsNew) { // Adding command.CommandText = "INSERT INTO [AuditAssetHistory] ([SessionId], [IpAddress], [AuditAssetActionId], [UserId], [AssetId], [Notes], [Date]) VALUES (@sessionId, @ipAddress, @auditAssetActionId, @userId, @assetId, @notes, @date) ; SELECT @@identity AS NewId;"; } else { // Updating command.CommandText = "UPDATE [AuditAssetHistory] SET [SessionId] = @sessionId, [IpAddress] = @ipAddress, [AuditAssetActionId] = @auditAssetActionId, [UserId] = @userId, [AssetId] = @assetId, [Notes] = @notes, [Date] = @date WHERE AuditAssetHistoryId = @auditAssetHistoryId"; } command.Parameters.Add(CreateParameter("@sessionId", auditAssetHistory.SessionId)); command.Parameters.Add(CreateParameter("@ipAddress", auditAssetHistory.IpAddress)); command.Parameters.Add(CreateParameter("@auditAssetActionId", auditAssetHistory.AuditAssetActionId)); command.Parameters.Add(CreateParameter("@userId", auditAssetHistory.UserId)); command.Parameters.Add(CreateParameter("@assetId", auditAssetHistory.AssetId)); command.Parameters.Add(CreateParameter("@notes", auditAssetHistory.Notes)); command.Parameters.Add(CreateParameter("@date", auditAssetHistory.Date)); if (auditAssetHistory.IsNew) { auditAssetHistory.AuditAssetHistoryId = Convert.ToInt32(ExecScalar(command)); } else { command.Parameters.Add(CreateParameter("@auditAssetHistoryId", auditAssetHistory.AuditAssetHistoryId)); ExecuteCommand(command); } auditAssetHistory.IsDirty = false; auditAssetHistory.ChangedProperties.Clear(); return(auditAssetHistory); }
public static AuditAssetHistory Update(AuditAssetHistory auditAssetHistory) { return(AuditAssetHistoryMapper.Instance.Update(auditAssetHistory)); }
public static AuditAssetHistory FindOne(AuditAssetHistoryFinder finder) { AuditAssetHistory AuditAssetHistory = AuditAssetHistoryMapper.Instance.FindOne(finder); return(AuditAssetHistory ?? Empty); }
public static AuditAssetHistory Get(Nullable <Int32> AuditAssetHistoryId) { AuditAssetHistory AuditAssetHistory = AuditAssetHistoryMapper.Instance.Get(AuditAssetHistoryId); return(AuditAssetHistory ?? Empty); }