public IActionResult DeleteByPost( int personFluffyDateId) { var fluffyDate = _personData .GetPersonFluffyDateWithNavigation( personFluffyDateId); if (fluffyDate == null) { return(NotFound()); } _personData.DeletePersonFluffyDate(fluffyDate); // // Update RDF // var readPerson = _personData.ReadAllPersonData(fluffyDate.Person.PersonGuid); if (readPerson != null) { _rdfData.AddOrUpdatePerson(readPerson); } // // Update search index // // Update selected year type switch (fluffyDate.Type) { case PersonFluffyDateType.Birth: _personSearchIndex.MergeYearOfBirth( fluffyDate.Person.PersonGuid.ToString(), null); break; case PersonFluffyDateType.Death: _personSearchIndex.MergeYearOfDeath( fluffyDate.Person.PersonGuid.ToString(), null); break; } // Update age // Get updated dates var person = _personData.ReadPersonWithFluffyDates(fluffyDate.Person.PersonGuid); var birthFluffyDate = person.FluffyDates.FirstOrDefault(x => x.Type == PersonFluffyDateType.Birth); if (birthFluffyDate?.Year != null) { var fluffyDateStart = new FluffyDate( birthFluffyDate.Year, birthFluffyDate.Month, birthFluffyDate.Day); var fluffyDateEnd = new FluffyDate( DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); var deathFluffyDate = person.FluffyDates.FirstOrDefault(x => x.Type == PersonFluffyDateType.Death); if (deathFluffyDate?.Year != null) { fluffyDateEnd = new FluffyDate( deathFluffyDate.Year, deathFluffyDate.Month, deathFluffyDate.Day); } var age = new Age( fluffyDateStart, fluffyDateEnd); if (age.InYears != null) { _personSearchIndex.MergeAge( person.PersonGuid.ToString(), age.InYears); } } else { _personSearchIndex.MergeAge( person.PersonGuid.ToString(), null); } // // Redirect // return(RedirectToAction( "Details", "Person", new { personGuid = fluffyDate.Person.PersonGuid })); }