public async Task <IActionResult> GetById(int id) { var item = await _userServiceAsync.GetOne(id); if (item == null) { Log.Error("GetById({ ID}) NOT FOUND", id); return(NotFound()); } return(Ok(item)); }
public async Task <ActionResult <object> > SelectByIdAsync(int id) { try { var item = await _userServiceAsync.GetOne(id); if (item == null) { var toSerialize = new MessageHelpers <UserViewModel>() { Status = 404, Data = null }; return(JsonConvert.SerializeObject(toSerialize)); } else { var toSerialize = new MessageHelpers <UserViewModel>() { Status = 200, Data = new List <UserViewModel> { item } }; return(JsonConvert.SerializeObject(toSerialize)); } } catch { var toSerialize = new MessageHelpers <UserViewModel>() { Status = 502, Data = null }; return(JsonConvert.SerializeObject(toSerialize)); } }