public async Task <IActionResult> Patch(int id, [FromQuery] string email)
        {
            if (string.IsNullOrWhiteSpace(email))
            {
                return(BadRequest(ErrorsHelp.RespuestaHttp(400, "El campo está vacio.")));
            }


            var infom = await agendactx.DboInfos.FindAsync(id);

            if (infom == null)
            {
                return(NotFound());
            }
            if (await agendactx.DboInfos.Where(x => x.Email == email && x.IdPersona != id).AnyAsync())
            {
                return(BadRequest(ErrorsHelp.RespuestaHttp(400, $"El correo electrónico {email}  ya existe.")));
            }

            infom.Email = email;
            if (!TryValidateModel(infom, nameof(infom)))
            {
                return(BadRequest(ErrorsHelp.ModelStateErrors(ModelState)));
            }
            await agendactx.SaveChangesAsync();

            return(StatusCode(200, infom));
        }
        public async Task <IActionResult> Put(int id, [FromBody] InfoModel info)
        {
            if (info.IdPersona == 0)
            {
                info.IdPersona = id;
            }

            if (info.IdPersona != id)
            {
                return(BadRequest(ErrorsHelp.RespuestaHttp(400, "Error al enviar la petición")));
            }
            if (!await agendactx.DboInfos.Where(x => x.IdPersona == info.IdPersona).AsNoTracking().AnyAsync())
            {
                return(NotFound(ErrorsHelp.RespuestaHttp(404, $"El curso {info.IdPersona} no existe")));
            }
            if (await agendactx.DboInfos.Where(x => x.Email == info.Email && x.IdPersona != info.IdPersona).AsNoTracking().AnyAsync())
            {
                return(BadRequest(ErrorsHelp.RespuestaHttp(400, $"El código {info.Email} ya existe")));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ErrorsHelp.ModelStateErrors(ModelState)));
            }

            agendactx.Entry(info).State = EntityState.Modified;
            await agendactx.SaveChangesAsync();

            return(NoContent());
        }
        public async Task <IActionResult> Get(int id)
        {
            var infoM = await agendactx.DboInfos.FindAsync(id);

            if (infoM == null)
            {
                return(NotFound(ErrorsHelp.RespuestaHttp(404, $"La información con ID {id} no se encuentra registrada.")));
            }
            else
            {
                return(Ok(infoM));
            }
        }
        public async Task <IActionResult> Post([FromBody] InfoModel info)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ErrorsHelp.ModelStateErrors(ModelState)));
            }
            if (await agendactx.DboInfos.Where(x => x.IdPersona == info.IdPersona).AnyAsync())
            {
                return(BadRequest(ErrorsHelp.RespuestaHttp(400, $"El ID: {info.IdPersona} ya existe.")));
            }
            if (await agendactx.DboInfos.Where(x => x.Email == info.Email).AnyAsync())
            {
                return(BadRequest(ErrorsHelp.RespuestaHttp(400, $"El correo electrónico: {info.Email}  ya existe.")));
            }

            await agendactx.DboInfos.AddAsync(info);

            await agendactx.SaveChangesAsync();

            return(CreatedAtAction(nameof(Get), new { id = info.IdPersona }, info));
        }