Example #1
0
        public virtual AuditUserHistory Update(AuditUserHistory auditUserHistory)
        {
            if (!auditUserHistory.IsDirty || auditUserHistory.IsNull)
            {
                // Nothing to do - no point hammering the database unnecessarily
                return(auditUserHistory);
            }

            IDbCommand command = CreateCommand();

            if (auditUserHistory.IsNew)
            {
                // Adding
                command.CommandText = "INSERT INTO [AuditUserHistory] ([SessionId], [IpAddress], [AuditUserActionId], [UserId], [Notes], [Date]) VALUES (@sessionId, @ipAddress, @auditUserActionId, @userId, @notes, @date) ; SELECT @@identity AS NewId;";
            }
            else
            {
                // Updating
                command.CommandText = "UPDATE [AuditUserHistory] SET [SessionId] = @sessionId, [IpAddress] = @ipAddress, [AuditUserActionId] = @auditUserActionId, [UserId] = @userId, [Notes] = @notes, [Date] = @date WHERE AuditUserHistoryId = @auditUserHistoryId";
            }

            command.Parameters.Add(CreateParameter("@sessionId", auditUserHistory.SessionId));
            command.Parameters.Add(CreateParameter("@ipAddress", auditUserHistory.IpAddress));
            command.Parameters.Add(CreateParameter("@auditUserActionId", auditUserHistory.AuditUserActionId));
            command.Parameters.Add(CreateParameter("@userId", auditUserHistory.UserId));
            command.Parameters.Add(CreateParameter("@notes", auditUserHistory.Notes));
            command.Parameters.Add(CreateParameter("@date", auditUserHistory.Date));

            if (auditUserHistory.IsNew)
            {
                auditUserHistory.AuditUserHistoryId = Convert.ToInt32(ExecScalar(command));
            }
            else
            {
                command.Parameters.Add(CreateParameter("@auditUserHistoryId", auditUserHistory.AuditUserHistoryId));
                ExecuteCommand(command);
            }

            auditUserHistory.IsDirty = false;
            auditUserHistory.ChangedProperties.Clear();

            return(auditUserHistory);
        }
Example #2
0
        protected override object ReadRow(IRowReader reader)
        {
            AuditUserHistory auditUserHistory = AuditUserHistory.New();

            // Table Fields
            auditUserHistory.AuditUserHistoryId = reader.GetInt32("AuditUserHistoryId");
            auditUserHistory.SessionId          = reader.GetString("SessionId");
            auditUserHistory.IpAddress          = reader.GetString("IpAddress");
            auditUserHistory.AuditUserActionId  = reader.GetInt32("AuditUserActionId");
            auditUserHistory.UserId             = reader.GetInt32("UserId");
            auditUserHistory.Notes = reader.GetString("Notes");
            auditUserHistory.Date  = reader.GetDateTime("Date");

            // View Fields
            auditUserHistory.Description    = reader.GetString("Description");
            auditUserHistory.UserName       = reader.GetString("UserName");
            auditUserHistory.UserEmail      = reader.GetString("UserEmail");
            auditUserHistory.PrimaryBrandId = reader.GetInt32("PrimaryBrandId");

            auditUserHistory.IsDirty = false;
            auditUserHistory.ChangedProperties.Clear();

            return(auditUserHistory);
        }
 public static AuditUserHistory Update(AuditUserHistory auditUserHistory)
 {
     return(AuditUserHistoryMapper.Instance.Update(auditUserHistory));
 }
        public static AuditUserHistory FindOne(AuditUserHistoryFinder finder)
        {
            AuditUserHistory AuditUserHistory = AuditUserHistoryMapper.Instance.FindOne(finder);

            return(AuditUserHistory ?? Empty);
        }
        public static AuditUserHistory Get(Nullable <Int32> AuditUserHistoryId)
        {
            AuditUserHistory AuditUserHistory = AuditUserHistoryMapper.Instance.Get(AuditUserHistoryId);

            return(AuditUserHistory ?? Empty);
        }