Example #1
0
        public void CountUserLogin(string userid)
        {
            LoginCounts countLogin = this.GetLoginCountById(userid);

            if (countLogin != null)
            {
                countLogin.UserId = userid;
                if (string.IsNullOrEmpty(countLogin.NumberOfTimes.ToString()))
                {
                    countLogin.NumberOfTimes = 1;
                }
                else
                {
                    countLogin.NumberOfTimes = countLogin.NumberOfTimes + 1;
                }
                countLogin.LastLoggedInDate = DateTime.Parse(GenericHelpers.Date());
                this.Update(countLogin);
            }
            else
            {
                LoginCounts newcountLogin = new LoginCounts();
                newcountLogin.UserId = userid;
                if (string.IsNullOrEmpty(newcountLogin.NumberOfTimes.ToString()))
                {
                    newcountLogin.NumberOfTimes = 1;
                }
                else
                {
                    newcountLogin.NumberOfTimes = countLogin.NumberOfTimes + 1;
                }
                newcountLogin.LastLoggedInDate = DateTime.Parse(GenericHelpers.Date());
                this.Insert(newcountLogin);
            }
        }
        public int Insert(LoginAudits userAudit)
        {
            string commandText = "insert into " + fullTableName +
                                 "(" + FieldUserId.Quoted() + ", " +
                                 FieldUserAuditId.Quoted() + ", " +
                                 FieldAuditEvent.Quoted() + ", " +
                                 FieldTimestamp.Quoted() + ", " +
                                 FieldIpAddress.Quoted() + ")" +
                                 " VALUES (@UserId, @AuditId, @AuditEvent, @Timestamp, @IpAddress);";
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("@UserId", userAudit.UserId);
            parameters.Add("@AuditId", userAudit.AuditId);
            parameters.Add("@AuditEvent", userAudit.AuditEvent.ToString());
            parameters.Add("@Timestamp", GenericHelpers.Date());
            parameters.Add("@IpAddress", userAudit.IpAddress);

            return(_database.Execute(commandText, parameters));
        }