public ActionResult AddAgent(AgentResource agentResource) { try { var agent = mapper.Map <Agent>(agentResource); serviceAgent.AddAgent(agent); return(Ok(agent)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public IActionResult Register(AgentRegister agentRegister) { try { if (agentRegister.Fonction != Domain.Models.Types.AgentFunction.Directeur) { var agent = mapper.Map <Agent>(agentRegister); serviceAgent.AddAgent(agent); } var agentToRegister = mapper.Map <ApplicationUser>(agentRegister); serviceAuthentification.Registry(agentToRegister, agentRegister.Password, agentRegister.VehiculeId); return(Ok(agentRegister)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }