public IActionResult GetPerson([FromRoute] int id)
        {
            PersonAccomplishmentCommand person = _dbHelper.GetPerson(id);

            if (person == null)
            {
                return(NotFound());
            }

            return(Ok(person));
        }
        public void OnActionExecuting(ActionExecutingContext context)
        {
            Person person = (Person)context.ActionArguments["person"];

            PersonAccomplishmentCommand oldPerson = _dBHelper.GetPerson(person.PersonID);

            if (oldPerson == null)
            {
                _log.LogWarning("The following Person ID was not found: {personID}", person.PersonID);
                context.Result = new BadRequestObjectResult("Person not found.");
            }
            else if (!person.FirstName.Equals(oldPerson.FirstName) || !person.LastName.Equals(oldPerson.LastName))
            {
                _log.LogWarning("A user attempted to updated the following name: {lastName}, {firstName}", person.LastName, person.FirstName);
                context.Result = new BadRequestObjectResult("Cannot update a person's name.");
            }
        }
Exemple #3
0
 public ViewResult Details(int id)
 {
     return(View(_helper.GetPerson(id)));
 }