protected void ButtonClick(object sender, EventArgs e) { this.HideLabels(); bool returnResult = false; var isstaticip = DDStaticIP.SelectedItem.Text; var joindomain = DDDomainjoined.SelectedItem.Text; var authorize = DDAuthorize.SelectedItem.Text; var hostname = txtHostname.Text.Trim(); var ipaddress = txtIpaddress.Text.Trim(); // DHCP parameters validation if (isstaticip == "--SELECT--") { this.ShowErrorMessage("Please confirm if server has static IP Address"); return; } if (isstaticip == "False") { this.ShowErrorMessage("DHCP Server should have static IP Address"); return; } if (joindomain == "--SELECT--") { this.ShowErrorMessage("Please confirm if server is joined to domain"); return; } if (joindomain == "False") { this.ShowErrorMessage("DHCP Server should should be joined to domain"); return; } if (authorize == "--SELECT--") { this.ShowErrorMessage("Please confirm if DHCP server needs to be authorized"); return; } if (string.IsNullOrWhiteSpace(hostname)) { this.ShowErrorMessage("Please enter Hostname."); return; } if (string.IsNullOrWhiteSpace(ipaddress)) { this.ShowErrorMessage("Please enter IP Address."); return; } try { //Call PSI file creater Method: CreatePSIFile(isstaticip, joindomain, authorize, hostname, ipaddress); if (0 == EditDhcpinstallationId) { var clientUser = new Dhcpinstallation() { CreatedBy = Context.User.Identity.Name, CreatedDate = DateTimeHelper.Now, Staticip = isstaticip, Joindomain = joindomain, Authorize = authorize, Hostname = hostname, Ipaddress = ipaddress }; DhcpinstallationService.Create(clientUser); ShowSuccessMessage("Script Generated. Click to download."); DDStaticIP.SelectedItem.Text = DropdownDefaultText; DDDomainjoined.SelectedItem.Text = DropdownDefaultText; DDAuthorize.SelectedItem.Text = DropdownDefaultText; txtHostname.Text = string.Empty; txtIpaddress.Text = string.Empty; } else { var Dhcpinstallation = DhcpinstallationService.Retrieve(EditDhcpinstallationId); Dhcpinstallation.Staticip = isstaticip; Dhcpinstallation.Joindomain = joindomain; Dhcpinstallation.Authorize = authorize; Dhcpinstallation.Hostname = hostname; Dhcpinstallation.Ipaddress = ipaddress; DhcpinstallationService.Update(Dhcpinstallation); ShowSuccessMessage("Script Generated. Click to download."); } } catch (Exception ex) { this.ShowErrorMessage( ex.Message.Contains( "An error occurred while updating the entries. See the inner exception for details.") ? "Duplicate Entry" : ex.Message); } }
public virtual void Delete(Dhcpinstallation entity) { this.Service.Delete(entity); }