public void AddNewPersonToTheDatabase_AddPerson_IsTrue() { // Arrange _persons = new List <PeopleDto>(); PeopleDto person = new PeopleDto() { TmdbId = 9999999 }; // Act _personData.AddPerson(person); _persons = _personData.GetAllPeople(); // Assert Assert.IsTrue(_persons.Last().TmdbId == person.TmdbId); // Cleanup _personData.RemovePerson(person); }
public IActionResult GetPerson(Person person) { _personData.AddPerson(person); return(Created(HttpContext.Request.Scheme + "://" + HttpContext.Request.Host + HttpContext.Request.Path + "/" + person.Id, person)); }
private void AddPerson(PeopleDto person) { _personData.AddPerson(person); }
public ActionResult Index(Person person) { personDb.AddPerson(person); return(RedirectToAction("Index")); }
public IActionResult Create( PersonCreateModel createModel) { // // Validate // // Abort if something is wrong if (!ModelState.IsValid) { return(View(createModel)); } // // Create // var newPerson = new Person(); newPerson.Gender = (PersonGender)createModel.Gender; try { _personData.AddPerson(newPerson); } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log.) ModelState.AddModelError( "", "Unable to add person. " + "Try again, and if the problem persists, " + "see your system administrator."); return(View(createModel)); } // // Update RDF // _rdfData.AddOrUpdatePerson(newPerson); // // Update search index // var persons = new List <PersonDocumentCreateModel> { // When creating a person we only have // PersonGuid and Gender. new PersonDocumentCreateModel { PersonGuid = newPerson.PersonGuid.ToString(), Gender = newPerson.Gender.ToString() } }; // TODO try catch to handle errors _personSearchIndex.UploadDocuments(persons); // // Redirect // return(RedirectToAction( "Details", "Person", new { personGuid = newPerson.PersonGuid })); }