Exemple #1
0
        public async Task <IActionResult> putPaciente([FromBody] Paciente pacientemodificado)
        {
            var user_uuid = User.Claims.Where(x => x.Type == ClaimTypes.Sid).First().Value;

            Paciente paciente = _context.Pacientes
                                .Where(p => p.UUID == pacientemodificado.UUID)
                                .FirstOrDefault();

            if (pacientemodificado != null)
            {
                nuevoRegistro(pacientemodificado);
            }

            _context.Entry(paciente).State           = EntityState.Detached;
            _context.Entry(pacientemodificado).State = EntityState.Modified;

            try {
                await _context.SaveChangesAsync();
            } catch (DbUpdateConcurrencyException) {
                if (pacientemodificado == null)
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok("Usuario Modificado"));
        }
Exemple #2
0
        public async Task <IActionResult> modificarAlergia(putAlergia alergia)
        {
            var user_uuid = User.Claims.Where(x => x.Type == ClaimTypes.Sid).First().Value;

            Alergia alergiaGuardada = _context.Alergias
                                      .Where(a => a.UUID == alergia.UUID)
                                      .FirstOrDefault();

            if (alergiaGuardada != null)
            {
                Alergeno nuevoAlergeno = new Alergeno {
                    UUID   = Guid.NewGuid(),
                    nombre = alergia.nombreAlergeno
                };
                _context.Alergenos.Add(nuevoAlergeno);
                _context.SaveChanges();

                Alergia alergiaModificada = new Alergia {
                    UUID     = alergiaGuardada.UUID,
                    alergeno = nuevoAlergeno
                };

                _context.Entry(alergiaGuardada).State   = EntityState.Detached;
                _context.Entry(alergiaModificada).State = EntityState.Modified;

                await _context.SaveChangesAsync();

                return(Ok("alergia actualizada"));
            }
            ;
            return(BadRequest("la alergia no existe"));
        }
Exemple #3
0
        public async Task <IActionResult> PutEmpleado([FromBody] Empleado empleadoModificado)
        {
            var user_uuid = User.Claims.Where(x => x.Type == ClaimTypes.Sid).First().Value;

            Empleado empleado = _context.Empleados
                                .Where(p => p.UUID == empleadoModificado.UUID)
                                .FirstOrDefault();

            _context.Entry(empleado).State           = EntityState.Detached;
            _context.Entry(empleadoModificado).State = EntityState.Modified;

            try {
                await _context.SaveChangesAsync();
            } catch (DbUpdateConcurrencyException) {
                if (empleadoModificado == null)
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok("empleado Modificado"));
        }
Exemple #4
0
            public async Task <Unit> Handle(Ejecuta request, CancellationToken cancellationToken)
            {
                var doctor = await _context.Doctor.FindAsync(request.Id);

                if (doctor == null)
                {
                    throw new ExceptionHandler(HttpStatusCode.NotFound, new { doctor = "No se encontro al doctor" });
                }
                _context.Remove(doctor);

                var resultado = await _context.SaveChangesAsync();

                if (resultado > 0)
                {
                    return(Unit.Value);
                }

                throw new Exception("No se pudo guardar los cambios");
            }
        public async Task <IActionResult> putRegistro([FromBody] Huella huella)
        {
            var user_uuid = User.Claims.Where(x => x.Type == ClaimTypes.Sid).First().Value;

            //el correo es el user en el registro aqui se usa para localizar al paciente
            Paciente paciente = _context.Pacientes
                                .Where(p => p.correoElectronico == huella.user)
                                .FirstOrDefault();

            Registro registro = _context.registros
                                .Where(r => r.pacienteId.UUID == paciente.UUID)
                                .FirstOrDefault();

            registro.passwordHuella = huella.huellaId;

            await _context.SaveChangesAsync();

            return(Ok("Huella registrada"));
        }
Exemple #6
0
            public async Task <Unit> Handle(Ejecuta request, CancellationToken cancellationToken)
            {
                var especialidad = new Especialidad {
                    EspecialidadId   = Guid.NewGuid(),
                    Descripcion      = request.Descripcion,
                    Titulo           = request.Titulo,
                    FechaPublicacion = request.FechaPublicacion
                };

                _context.Especialidad.Add(especialidad);
                var valor = await _context.SaveChangesAsync();

                if (valor > 0)
                {
                    return(Unit.Value);
                }

                throw new Exception("No se pudo insertar la Especialidad");
            }
Exemple #7
0
            public async Task <Unit> Handle(Ejecuta request, CancellationToken cancellationToken)
            {
                var horario = new Horario {
                    HorarioId   = Guid.NewGuid(),
                    Titulo      = request.Titulo,
                    FechaInicio = request.FechaInicio,
                    FechaFin    = request.FechaFin
                };

                _context.Horario.Add(horario);

                var resultado = await _context.SaveChangesAsync();

                if (resultado > 0)
                {
                    return(Unit.Value);
                }

                throw new Exception("No se pudo insertar el Horario");
            }
Exemple #8
0
            public async Task <Unit> Handle(Ejecuta request, CancellationToken cancellationToken)
            {
                var doctor = new Doctor {
                    DoctorId  = Guid.NewGuid(),
                    Nombres   = request.Nombres,
                    Apellidos = request.Apellidos,
                    Dni       = request.Dni,
                    Direccion = request.Direccion,
                    Celular   = request.Celular
                };

                _context.Doctor.Add(doctor);

                var valor = await _context.SaveChangesAsync();

                if (valor > 0)
                {
                    return(Unit.Value);
                }

                throw new Exception("No se pudo insertar el doctor");
            }
Exemple #9
0
            public async Task <Unit> Handle(Ejecuta request, CancellationToken cancellationToken)
            {
                var doctor = await _context.Doctor.FindAsync(request.DoctorId);

                if (doctor == null)
                {
                    throw new ExceptionHandler(HttpStatusCode.NotFound, new { doctor = "No se encontro doctor a editar" });
                }

                doctor.Nombres   = request.Nombres ?? doctor.Nombres;
                doctor.Apellidos = request.Apellidos ?? doctor.Apellidos;
                doctor.Dni       = request.Dni ?? doctor.Apellidos;
                doctor.Direccion = request.Direccion ?? doctor.Direccion;
                doctor.Celular   = request.Celular ?? doctor.Celular;

                var resultado = await _context.SaveChangesAsync();

                if (resultado > 0)
                {
                    return(Unit.Value);
                }
                throw new Exception("No se pudo completar la edicion");
            }
        public async Task AddAsync(Cliente cliente)
        {
            await context.Clientes.AddAsync(cliente);

            await context.SaveChangesAsync();
        }
Exemple #11
0
 public async Task <bool> SaveChangesAsync()
 {
     return((await Db.SaveChangesAsync()) > 0);
 }