private static void Get(UserSecurityContext user, HttpContext context, CancellationToken cancel) { try { PersonProvider provider = PersonManager.Instance.GetProvider(user); if (provider != null) { IEnumerable <Person> persons = provider.Get(); JArray jpersons = new JArray(); jpersons = Jsonifier.ToJson(persons); if (jpersons != null) { RestUtils.Push(context.Response, JsonOpStatus.Ok, jpersons.ToString()); } else { RestUtils.Push(context.Response, JsonOpStatus.Ok, "[]"); } return; } RestUtils.Push(context.Response, JsonOpStatus.Failed); } catch { RestUtils.Push(context.Response, JsonOpStatus.Failed); return; } }
static void TestPersons(UserSecurityContext context) { PersonProvider prov = PersonManager.Instance.GetProvider(context); Console.WriteLine("Testing Persons"); Person dev = prov.Create("Grant", "Fuji"); if (dev != null) { Console.WriteLine("Create Person: " + dev.FirstName + " " + dev.LastName); } else { Console.WriteLine("Failed to create Person"); } dev.LastName = "Fujimoto"; bool updated = prov.Update(dev); if (updated) { Console.WriteLine("Updated Person"); } else { Console.WriteLine("Failed to update Person"); } var retrievedPerson = prov.Get(dev.Identity); if (retrievedPerson != null) { Console.WriteLine("Get Person: " + retrievedPerson.FirstName + " " + retrievedPerson.LastName); } else { Console.WriteLine("Failed to retrieve Person"); } bool deleted = prov.Delete(dev); if (deleted) { Console.WriteLine("Deleted Person"); } else { Console.WriteLine("Failed to Delete Person"); } Console.WriteLine("Person Test Complete!"); return; }
protected void gvwParent_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditRow") { int id = Convert.ToInt32(e.CommandArgument); RowID = id; mvwParents.ActiveViewIndex = 1; Person person = personProvider.Get(id); ddlConnection.SelectedValue = person.Connection; ddlConnection.Enabled = false; txtEmail.Text = person.Email; txtName.Text = person.Name; txtPhone1.Text = person.Phone1; txtPhone2.Text = person.Phone2; txtIDCardNo.Text = person.IDCardNo; calDateOfBirth.SelectedDate = person.BirthDate.HasValue ? person.BirthDate.Value : DateTime.Today; chkUnknownBirthDate.Checked = !person.BirthDate.HasValue; if (!String.IsNullOrEmpty(person.Photo)) { FileInfo file = new FileInfo(person.Photo); imgPhoto.ImageUrl = ConfigurationManager.AppSettings[ApplicationSettingKeys.FolderPhotoPersons] + @"\" + file.Name.Substring(0, file.Name.IndexOf(".")) + file.Extension + ".ashx?w=200"; } else { imgPhoto.ImageUrl = ConfigurationManager.AppSettings[ApplicationSettingKeys.FolderPhotoPersons] + @"\default.png"; } chkDeletePhoto.Checked = false; if (Request.QueryString["PickUpPerson"] == null) { btnSave.Enabled = !String.IsNullOrEmpty(Request.QueryString["CustomerCode"]); } else if (ddlConnection.SelectedItem.Text.ToUpper() != "PICK UP PERSON") { btnSave.Enabled = false; } else { btnSave.Enabled = true; } ddlConnection.Focus(); } }