public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(RedirectToPage("/AgentNotFound"));
            }
            Agent = await _repository.GetAgentById(id.Value);

            if (Agent == null)
            {
                return(RedirectToPage("/AgentNotFound"));
            }
            return(Page());
        }
Пример #2
0
        public async Task <ActionResult> GetAgent(int id)
        {
            try
            {
                var result = await _repository.GetAgentById(id);

                if (result != null)
                {
                    return(Ok(result));
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (System.Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  "There were error in retrieving the data from the database!"));
            }
        }