public IHttpActionResult BuscarPorCaracteristicas( Documento documento ) { var result = dao.Exist(documento); var guid = Guid.NewGuid(); if (result.IsFailure) { map.Add( guid, documento ); return Ok(guid); } // end if else { map.Add( guid, result.Value ); return ResponseMessage( Request.CreateResponse( HttpStatusCode.Conflict, new HttpErrorMessage<Guid>() { StatusCode = HttpStatusCode.Conflict, ErrorMessage = "Un documento con esa descripcion ya existe", Value = guid })); } // end else }
public Result<Documento> Exist( Documento newDoc ) { try { using (OracleConnection conn = DB.GetOracleConnection()) using (OracleCommand cmd = DB.GetFuncionCommand(conn, "WEB_LEGEM.GET_ID_MATCH")) { var result = DB.AddObjectResult(cmd, UdtTypeName); DB.AddObjectParameter(cmd, "new_d", UdtTypeName, newDoc); cmd.ExecuteNonQuery(); return Result.Ok( (Documento) result.Value); } // end using cmd } catch (OracleException ex) { if (ex.Number == 1403) return Result.Fail<Documento>( "No existe un documento con esas caracteristicas" ); throw ex; } // end method }