public IEnumerable <People> GetPeopleByID([FromRoute] int id)
        {
            CRUDREACTContext context        = HttpContext.RequestServices.GetService(typeof(CRUDREACT.Models.CRUDREACTContext)) as CRUDREACTContext;
            MySqlParameter   mySqlParameter = new MySqlParameter("idPeople", id);

            return(context.GetPeopleById(mySqlParameter));
        }
        public IActionResult UpdatePeople([FromBody] People people)
        {
            CRUDREACTContext context = HttpContext.RequestServices.GetService(typeof(CRUDREACT.Models.CRUDREACTContext)) as CRUDREACTContext;

            context.UpdatePeople(people);

            return(Ok());
        }
        public IActionResult deletePeople([FromRoute] int id)
        {
            CRUDREACTContext context        = HttpContext.RequestServices.GetService(typeof(CRUDREACT.Models.CRUDREACTContext)) as CRUDREACTContext;
            MySqlParameter   mySqlParameter = new MySqlParameter("idPeople", id);

            context.DeletePeople(mySqlParameter);
            return(Ok());
        }
 public IActionResult UpdateAddress([FromBody] Address address)
 {
     context = HttpContext.RequestServices.GetService(typeof(CRUDREACT.Models.CRUDREACTContext)) as CRUDREACTContext;
     try
     {
         context.UpdateAddress(address);
     }
     catch (Exception exception)
     {
         throw exception;
     }
     return(Ok());
 }
        public IActionResult DeleteAddress([FromRoute] int id)
        {
            context = HttpContext.RequestServices.GetService(typeof(CRUDREACT.Models.CRUDREACTContext)) as CRUDREACTContext;

            MySqlParameter mySqlParameter = new MySqlParameter("idAddress", id);

            try
            {
                context.DeleteAddress(mySqlParameter);
            }catch (Exception exception)
            {
                throw exception;
            }
            return(Ok());
        }
        public IEnumerable <Address> GetAddresses([FromRoute] int id)
        {
            context = HttpContext.RequestServices.GetService(typeof(CRUDREACT.Models.CRUDREACTContext)) as CRUDREACTContext;

            List <Address> list = new List <Address>();

            try
            {
                MySqlParameter mySqlParameter = new MySqlParameter("idPeople", id);

                list = context.GetAddresses(mySqlParameter);
            }
            catch (Exception exception)
            {
                throw exception;
            }

            return(list);
        }
        public IEnumerable <People> GetByName([FromRoute] string name)
        {
            context = HttpContext.RequestServices.GetService(typeof(CRUDREACT.Models.CRUDREACTContext)) as CRUDREACTContext;

            List <People> list = new List <People>();

            try
            {
                name = "%" + name + "%";
                MySqlParameter mySqlParameter = new MySqlParameter("searchName", name);

                list = context.GetPeopleBySearch(mySqlParameter);
            }
            catch (Exception exception)
            {
                throw exception;
            }

            return(list);
        }
        public IEnumerable <People> GetPeoples()
        {
            CRUDREACTContext context = getContext();

            return(context.GetPeoples());
        }