public IActionResult GetPerson(Guid id) { var person = _personData.GetPerson(id); if (person != null) { return(Ok(_personData.GetPerson(id))); } else { return(NotFound($"Person with ID {id} could not be found")); } }
public async Task <IActionResult> Get(int personId) { var person = await _personData.GetPerson(personId); if (person != null) { return(Ok(person)); } return(NotFound("Person Not found with Id.")); }
public IActionResult Edit(Guid personGuid, PersonEditModel editModel) { if (personGuid == Guid.Empty) { return(BadRequest(ModelState)); } var person = _personData.GetPerson(personGuid); if (person == null) { return(NotFound()); } // Page navigation ViewData["PersonGuid"] = person.PersonGuid; // // Validate // if (!ModelState.IsValid) { return(View(editModel)); } // // Edit // person.Gender = (PersonGender)editModel.GenderType; try { _personData.UpdatePerson(person); } catch (DbUpdateException /* ex */) { // Log the error (uncomment ex variable name and write a log.) ModelState.AddModelError( "", "Unable to save changes. " + "Try again, and if the problem persists, " + "see your system administrator."); return(View(editModel)); } // // Update RDF // var readPerson = _personData.ReadAllPersonData(personGuid); if (readPerson != null) { _rdfData.AddOrUpdatePerson(readPerson); } // // Update search index // // TODO try catch to handle errors _personSearchIndex.MergeGender( person.PersonGuid.ToString(), person.Gender.ToString()); // // Redirect // return(RedirectToAction( "Details", "Person", new { personGuid = person.PersonGuid })); }