예제 #1
0
 [HttpGet("{id:int}", Name = "GetFiveById")] // 이름 추가
 public IActionResult Get(int id)
 {
     try
     {
         var model = _repository.GetById(id);
         if (model == null)
         {
             return(NotFound($"{id}번 데이터가 없습니다."));
         }
         return(Ok(model));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
 [HttpGet("{id:int}", Name = "GetById")]   // GetById Web API 이름추가 (post에서 (GetById로) 호출 가능)
 public IActionResult Get(int id)
 {
     ////https://localhost:44367/api/FiveService/1111
     ////https://localhost:44367/api/GetById
     try
     {
         FiveViewModel model = _repository.GetById(id);
         if (model == null)
         {
             return(NotFound($"아무런 데이터가 없습니다. ({id}번)"));
         }
         return(Ok(model));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }