/// <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); }
protected void SaveAndStayButton_Click(object sender, EventArgs e) { if (Page.IsValid) { try { BannedIpNetwork ipNetwork = Save(); Response.Redirect("BlacklistNetworkDetails.aspx?BannedIpNetworkID=" + ipNetwork.BannedIpNetworkId.ToString()); } catch (Exception exc) { ProcessException(exc); } } }
protected void SaveButton_Click(object sender, EventArgs e) { if (Page.IsValid) { try { BannedIpNetwork ipNetwork = Save(); Response.Redirect("Blacklist.aspx"); } catch (Exception exc) { ProcessException(exc); } } }
protected void OnSaveClick(object sender, EventArgs e) { if (Page.IsValid) { try { BannedIpNetwork ipNetwork = ctrlBlacklist.SaveBannedIpNetworkInfo(); Response.Redirect("BlacklistNetworkDetails.aspx?BannedIpNetworkID=" + ipNetwork.BannedIpNetworkID.ToString()); } catch (Exception exc) { ProcessException(exc); } } }
/// <summary> /// Saves a BannedIpNetwork /// </summary> /// <returns>BannedIpNetwork</returns> public BannedIpNetwork SaveBannedIpNetworkInfo() { DateTime nowDT = DateTime.UtcNow; //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 (!this.BlacklistService.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 (!this.BlacklistService.IsValidIp(rangeItems[1].Trim())) { throw new NopException("The following isn't a valid IP address: " + rangeItems[1]); } BannedIpNetwork ipNetwork = this.BlacklistService.GetBannedIpNetworkById(this.BannedIpNetworkId); //if ip network is not null update if (ipNetwork != null) { ipNetwork.StartAddress = rangeItems[0]; ipNetwork.EndAddress = rangeItems[1]; ipNetwork.Comment = txtComment.Text; ipNetwork.IpException = txtIpException.Text; ipNetwork.UpdatedOn = nowDT; this.BlacklistService.UpdateBannedIpNetwork(ipNetwork); } else //insert { ipNetwork = new BannedIpNetwork() { StartAddress = rangeItems[0], EndAddress = rangeItems[1], Comment = txtComment.Text, IpException = txtIpException.Text, CreatedOn = nowDT, UpdatedOn = nowDT }; this.BlacklistService.InsertBannedIpNetwork(ipNetwork); } 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; } }
protected BannedIpNetwork Save() { BannedIpNetwork ipNetwork = ctrlBlacklist.SaveBannedIpNetworkInfo(); return(ipNetwork); }