Web service in C #

0

I'm trying to do a web service but I get this error in the repository with the return and I do not understand why

The summary error message says that as it returns void, a keyword return must not be followed by an object expression.

           public bool PuntoEntrega TarjetahabientePuntoEntregaModificar(TarjetaHabiente tarjetaHabiente, int puntoEntregaID, int idcliente,  DbTransaction transaction)
      {
         var resultado = true;

               try
               {
                   var parametros = new Dictionary<string, object>
                          {
                              { "Nacionalidad", (int)tarjetaHabiente.Nacionalidad },
                              {"Cedula", tarjetaHabiente.Cedula},
                              {"Cliente", tarjetaHabiente.Cliente.ID},
                              {"IDPuntoEntrega", puntoEntregaID},
                              {"IDPuntoEntregaNuevo", tarjetaHabiente.PtoEntrega.ID},
                              {"IDDepartamento", tarjetaHabiente.Departamento.ID}
                          };


                   if (transaction == null)
                   {
                       ExecuteNonQueryFromStoredProcedure("[Operaciones].[TarjetahabientePuntoEntregaModificar]", parametros);
                   }
                   else
                   {
                       ExecuteNonQueryFromStoredProcedure("[Operaciones].[TarjetahabientePuntoEntregaModificar]", transaction, parametros);
                   }
               }
               catch (Exception ex)
               {
                   resultado = false;
                   Notificador.LogError(ErrorTipo.ErrorEnRepositorio, ex, Excepciones.MsjUIErrorGeneral);
               }

               return resultado;
         }
    
asked by keiver vasquez 30.11.2018 в 02:39
source

1 answer

0

You must correctly define the signature of the function

public bool TarjetahabientePuntoEntregaModificar(TarjetaHabiente tarjetaHabiente, int puntoEntregaID, int idcliente,  DbTransaction transaction)
{
    var resultado = true;

     //resto codigo

    return resultado;
}

In this case, delete PuntoEntrega and only leave bool

If you wanted to return both then you should create a third class, something like being

public class Result
{
    public bool success {get;set;}
    public PuntoEntrega data {get;set;}
}

then the signature would be

public Result TarjetahabientePuntoEntregaModificar(...){...

In this way you compose two values using classes

What I do see is rather weird is that you define as parameter a DbTransaction of a web service, that is not correct.

    
answered by 30.11.2018 / 05:31
source