예제 #1
0
        public UpdatePacienteOut UpdatePaciente(UpdatePacienteIn input)
        {
            UpdatePacienteOut output = new UpdatePacienteOut()
            {
                result = Result.Error
            };

            try
            {
                DbContextApplication dbContext = new DbContextApplication();
                var paciente = new PruebaNexos.DataLayer.Paciente
                {
                    Id_Paciente        = input.pacienteId,
                    Nombre             = input.Nombre,
                    NumeroSeguroSocial = input.NumeroSeguro,
                    MedicoPreferido    = input.MedicoPreferido
                };
                dbContext.Entry(paciente).State = EntityState.Modified;

                if (dbContext.SaveChanges() > 0)
                {
                    output.pacienteId = paciente.Id_Paciente;
                    output.result     = Result.Success;
                }
                return(output);
            }
            catch (Exception e)
            {
                output.MensajeExcepcion = "Excepción no controlada por favor comuniquese con el administrador enviele el siguiente mensaje: " + e.Message;
                return(output);
            }
        }
예제 #2
0
        public UpdatePacienteOut UpdatePaciente(UpdatePacienteIn input)
        {
            UpdatePacienteOut output = new UpdatePacienteOut()
            {
                result = Result.Error
            };
            UpdatePacienteValidator validador  = new UpdatePacienteValidator();
            ValidationResult        resultado  = validador.Validate(input);
            List <string>           listErrors = new List <string>();

            if (resultado.Errors.Count > 0)
            {
                foreach (ValidationFailure falla in resultado.Errors)
                {
                    listErrors.Add(falla.PropertyName + ": " + falla.ErrorMessage);
                }
                output.Errores = listErrors;
                return(output);
            }
            return(paciente.UpdatePaciente(input));
        }
예제 #3
0
 public UpdatePacienteOut UpdatePaciente([FromBody] UpdatePacienteIn input)
 {
     return(paciente.UpdatePaciente(input));
 }