public virtual RestrictedIp InsertRestrictedIp(RestrictedIp entity)
        {
            RestrictedIp other = new RestrictedIp();

            other = entity;
            if (entity.IsTransient())
            {
                string         sql            = @"Insert into RestrictedIP ( [IPAddress]
				,[DBRecNo]
				,[CreatedOn] )
				Values
				( @IPAddress
				, @DBRecNo
				, @CreatedOn );
				Select scope_identity()"                ;
                SqlParameter[] parameterArray = new SqlParameter[] {
                    new SqlParameter("@IPAddress", entity.IpAddress)
                    , new SqlParameter("@DBRecNo", entity.DbRecNo)
                    , new SqlParameter("@CreatedOn", entity.CreatedOn)
                };
                var identity = SqlHelper.ExecuteScalar(this.ConnectionString, CommandType.Text, sql, parameterArray);
                if (identity == DBNull.Value)
                {
                    throw new DataException("Identity column was null as a result of the insert operation.");
                }
                return(GetRestrictedIp(Convert.ToInt32(identity)));
            }
            return(entity);
        }
        public virtual RestrictedIp RestrictedIpFromDataRow(DataRow dr)
        {
            if (dr == null)
            {
                return(null);
            }
            RestrictedIp entity = new RestrictedIp();

            entity.DbRecNo   = (System.Int32)dr["DBRecNo"];
            entity.IpAddress = dr["IPAddress"].ToString();
            entity.CreatedOn = (System.DateTime)dr["CreatedOn"];
            return(entity);
        }
        public virtual RestrictedIp UpdateRestrictedIp(RestrictedIp entity)
        {
            if (entity.IsTransient())
            {
                return(entity);
            }
            RestrictedIp other = GetRestrictedIp(entity.IpAddress);

            if (entity.Equals(other))
            {
                return(entity);
            }
            string sql = @"Update RestrictedIP set  [DBRecNo]=@DBRecNo
							, [CreatedOn]=@CreatedOn 
							 where IPAddress=@IPAddress"                            ;

            SqlParameter[] parameterArray = new SqlParameter[] {
                new SqlParameter("@IPAddress", entity.IpAddress)
                , new SqlParameter("@DBRecNo", entity.DbRecNo)
                , new SqlParameter("@CreatedOn", entity.CreatedOn)
            };
            SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray);
            return(GetRestrictedIp(entity.IpAddress));
        }
Beispiel #4
0
 public RestrictedIp InsertRestrictedIp(RestrictedIp entity)
 {
     return(_iRestrictedIpRepository.InsertRestrictedIp(entity));
 }
Beispiel #5
0
 public RestrictedIp UpdateRestrictedIp(RestrictedIp entity)
 {
     return(_iRestrictedIpRepository.UpdateRestrictedIp(entity));
 }
 public virtual RestrictedIp DeleteRestrictedIp(RestrictedIp entity)
 {
     this.DeleteRestrictedIp(entity.IpAddress);
     return(entity);
 }