public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } await _repository.UpdateAgent(Agent); return(RedirectToPage("Index")); }
public async Task <ActionResult> UpdateAgent(Agent agent) { try { var getAgent = await _repository.GetAgentById(agent.AgentId); if (getAgent != null) { return(Ok(await _repository.UpdateAgent(agent))); } else { return(NotFound($"Agent with Id = {agent.AgentId} not found")); } } catch (System.Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, "There were error in updating the data from the database!")); } }