public RPResult Execute(RPCall call) { List <Contact> companies = DatabaseFactory.Factory().GetCompanies(); ContactListConverter conv = new ContactListConverter(); RPResult ret = new RPResult(); ret.dt = (DataTable)conv.ConvertTo(null, null, companies, typeof(DataTable)); ret.dt.TableName = "Companies"; return(ret); }
public RPResult Execute(RPCall call) { if (call.procedureArgs == null || call.procedureArgs.Length < 1) { throw new InvalidOperationException(); } List <Contact> contacts = DatabaseFactory.Factory().SearchContacts(call.procedureArgs[0]); ContactListConverter conv = new ContactListConverter(); RPResult retVal = new RPResult(); retVal.dt = (DataTable)conv.ConvertTo(null, null, contacts, typeof(DataTable)); retVal.dt.TableName = "Contacts"; return(retVal); }
/// <summary> /// Send a Contact object to be updated or Inserted /// into the database if it does not already exist. /// </summary> /// <param name="contact">The contact to be inserted or updated</param> /// <returns> /// A RPResult object its success field determines /// wether the query was successful(1) or not(0). /// </returns> public async Task <RPResult> SendContactAsync(Contact contact) { if (contact == null) { throw new ArgumentNullException(); } RPCall call = new RPCall("CommandUpsert"); List <Contact> temp = new List <Contact>() { contact }; ContactListConverter conv = new ContactListConverter(); call.dt = (DataTable)conv.ConvertTo(null, null, temp, typeof(DataTable)); return(await _client.SendAndReceiveAsync(call)); }
public async override void Execute(object parameter) { int? id = parameter as int?; string company = parameter as string; ContactListConverter con = new ContactListConverter(); Proxy proxy = new Proxy(); EditWindow window = Window as EditWindow; EditViewModel model = Model as EditViewModel; if (!string.IsNullOrWhiteSpace(company)) { RPResult result = await proxy.SearchCompany(model.ID, company); if (result.dt != null && result.dt.Rows.Count == 1) { DataRow row = result.dt.Rows[0]; model.Company = row["Name"] as string; model.CompanyID = (int)row["ID"]; model.Checked = true; } else { window.cmbPersonCompany.Items.Clear(); model.Checked = false; foreach (DataRow row in result.dt.Rows) { window.cmbPersonCompany.Items.Add(new Company(row)); } } } else if (id != null) { RPResult result = await proxy.SetCompany(id); DataRow row = result.dt.Rows[0]; model.Company = row["Name"] as string; model.CompanyID = (int)row["ID"]; model.Checked = true; } }