public IActionResult Get(int id)
        {
            var accomplishment = _accomplishment.GetAccomplisment(id);

            if (accomplishment != null)
            {
                return(Ok(accomplishment));
            }
            return(NotFound());
        }
예제 #2
0
        public void OnActionExecuting(ActionExecutingContext context)
        {
            // convert action argument to  view model
            var model = (PersonDetailAccomplishmentViewModel)context.ActionArguments["model"];


            var person = _service.GetAccomplisment(model.PersonId);

            if (person == null)
            {
                context.Result = new NotFoundObjectResult(context.ModelState);
            }

            if (person.FirstName != model.FirstName)
            {
                //return bad request
                context.ModelState.AddModelError("", "wrong first name");
                context.Result = new BadRequestObjectResult("First Name must match");
            }
        }
 public IActionResult Detail(int id)
 {
     return(View(_accomplishment.GetAccomplisment(id)));
 }