/// <summary> /// Saves a BannedIpNetwork /// </summary> /// <returns>BannedIpNetwork</returns> public BannedIpNetwork SaveBannedIpNetworkInfo() { DateTime nowDT = DateTime.Now; //split the text in the BannedIP to get the current IPs string[] rangeItems = txtBannedIP.Text.ToString().Split("-".ToCharArray()); // Check if the 1st IP is valid if (!IpBlacklistManager.IsValidIp(rangeItems[0].Trim())) { throw new NopException("The following isn't a valid IP address: " + rangeItems[0]); } // Check if the 2nd IP is valid if (!IpBlacklistManager.IsValidIp(rangeItems[1].Trim())) { throw new NopException("The following isn't a valid IP address: " + rangeItems[1]); } BannedIpNetwork ipNetwork = IpBlacklistManager.GetBannedIpNetworkById(BannedIpNetworkID); //if ip network is not null update if (ipNetwork != null) { ipNetwork = IpBlacklistManager.UpdateBannedIpNetwork(BannedIpNetworkID, rangeItems[0], rangeItems[1], txtComment.Text, txtIpException.Text, ipNetwork.CreatedOn, nowDT); } else //insert { ipNetwork = IpBlacklistManager.InsertBannedIpNetwork(rangeItems[0], rangeItems[1], txtComment.Text, txtIpException.Text, nowDT, nowDT); } return(ipNetwork); }
/// <summary> /// Bind controls on the form /// </summary> private void BindData() { BannedIpNetwork ipNetwork = IpBlacklistManager.GetBannedIpNetworkById(BannedIpNetworkID); if (ipNetwork != null) { txtBannedIP.Text = ipNetwork.ToString(); txtComment.Text = ipNetwork.Comment; txtIpException.Text = ipNetwork.IpException; this.pnlCreatedOn.Visible = true; this.pnlUpdatedOn.Visible = true; lblCreatedOn.Text = DateTimeHelper.ConvertToUserTime(ipNetwork.CreatedOn).ToString(); lblUpdatedOn.Text = DateTimeHelper.ConvertToUserTime(ipNetwork.UpdatedOn).ToString(); } else { this.pnlCreatedOn.Visible = false; this.pnlUpdatedOn.Visible = false; } }