private static Clark.Domain.Data.Domain DataRowToDomain(DataRowView row) { Clark.Domain.Data.Domain domain = new Clark.Domain.Data.Domain(); domain.DomainId = DatabaseUtilities.SafeMapToInt32(row["domain_id"], "domain_id"); domain.DomainName = DatabaseUtilities.SafeMapToString(row["domain_name"]); domain.BountyURL = DatabaseUtilities.SafeMapToString(row["bounty_url"]); domain.BountyEndDate = DatabaseUtilities.SafeMapToNullableDateTime(row["bounty_end_date"]); domain.LastScan = DatabaseUtilities.SafeMapToNullableDateTime(row["last_scan"]); domain.Private = DatabaseUtilities.SafeMapToBoolean(row["private"]); domain.Platform = DatabaseUtilities.SafeMapToString(row["platform"]); return(domain); }
private static Clark.Domain.Data.Domain DictionaryToDomain(Dictionary <string, Object> vals) { var domain = new Clark.Domain.Data.Domain(); domain.DomainId = DatabaseUtilities.SafeMapToInt32(vals, "domain_id"); domain.DomainName = DatabaseUtilities.SafeMapToString(vals, "domain_name"); domain.BountyURL = DatabaseUtilities.SafeMapToString(vals, "bounty_url"); domain.BountyEndDate = DatabaseUtilities.SafeMapToNullableDateTime(vals, "bounty_end_date"); domain.LastScan = DatabaseUtilities.SafeMapToNullableDateTime(vals, "last_scan"); domain.Private = DatabaseUtilities.SafeMapToBoolean(vals, "private"); domain.Platform = DatabaseUtilities.SafeMapToString(vals, "platform"); return(domain); }
private static void BindUpdateParameters(Clark.Domain.Data.Domain domain, DbUpdater updater, bool includeId = true) { if (includeId) { updater.BindParameter("domain_id", System.Data.DbType.Int32, domain.DomainId); } updater.BindParameter("domain_name", System.Data.DbType.String, domain.DomainName); updater.BindParameter("bounty_url", System.Data.DbType.String, domain.BountyURL); updater.BindParameter("bounty_end_date", System.Data.DbType.DateTime, domain.BountyEndDate); updater.BindParameter("last_scan", System.Data.DbType.DateTime, domain.LastScan); updater.BindParameter("private", System.Data.DbType.Boolean, domain.Private); updater.BindParameter("platform", System.Data.DbType.String, domain.Platform); }
private void _btnSave_Click(object sender, EventArgs e) { _btnSave.Enabled = false; Clark.Domain.Data.Domain domain = new Clark.Domain.Data.Domain(); domain.DomainName = _txtDomain.Text; domain.BountyURL = _txtPolicy.Text; domain.BountyEndDate = _endBountyChecks.Value; if (_radHackerone.Checked) { domain.Platform = "hackerone"; } else if (_radBugBountyJP.Checked) { domain.Platform = "bugbountyjp"; } else if (_radBugcrowd.Checked) { domain.Platform = "bugcrowd"; } else if (_radSelf.Checked) { domain.Platform = "self"; } else if (_radSynack.Checked) { domain.Platform = "synack"; } domain.Private = _chkPrivate.Checked; var domainController = new DomainController(); UpdateResult res = domainController.Insert(domain); if (res.Error) { MessageBox.Show(res.Message); } else { _txtDomain.Text = ""; _txtPolicy.Text = ""; _endBountyChecks.Value = new DateTime(2999, 12, 21); _chkPrivate.Checked = false; } _btnSave.Enabled = true; }
public UpdateResult Insert(Clark.Domain.Data.Domain domain) { var result = new UpdateResult(); try { DbUpdater updater = new DbUpdater(); BindUpdateParameters(domain, updater, false); result.Id = updater.Insert("domain"); } catch (Exception ex) { result.Error = true; result.Message = ex.Message; if (ex.InnerException != null) { result.Message += " Inner: " + ex.InnerException.Message; } } return(result); }
private DomainFindResult GenericFind(string whereClause, List <DbField> parameters) { DomainFindResult result = new DomainFindResult(); try { DbAccessor connection = new DbAccessor(); AddAccessorSelectors(connection); if (!String.IsNullOrEmpty(whereClause)) { connection.SetWhereClause(whereClause, parameters); } List <string> tables = new List <string>(); tables.Add("domain"); DataView dataView = connection.FindWhere(tables); foreach (DataRowView row in dataView) { Clark.Domain.Data.Domain domain = DataRowToDomain(row); result.Items.Add(domain); } } catch (Exception ex) { result.Error = true; result.Message = ex.Message; if (ex.InnerException != null) { result.Message += " Inner: " + ex.InnerException.Message; } } return(result); }