private DettaglioCodiceRaccViewModel Traslate(DettaglioRaccomandata dettaglioRaccomandata) { var result = new DettaglioCodiceRaccViewModel() { countRaccomandate = dettaglioRaccomandata.NumeroRaccomandate, countRaccomandatePmr = dettaglioRaccomandata.NumeroRaccomandatePMR, raccomandata = dettaglioRaccomandata.CodiceRaccomandata, numeroDistintaDistpostel = dettaglioRaccomandata.NumeroDistintaDistpostel, dettaglioPrimoEsitofonteEsaRacc = Traslate(dettaglioRaccomandata.Tempstoricocartelle) }; return(result); }
public async Task <IActionResult> DettaglioRaccomandata(string codiceRaccomandata) { // GET /StoricoCartelle/DettaglioRaccomandata/649128546828 try { if (codiceRaccomandata.Length != 12) { return(Content("Codice Raccomandata non corretto")); } // N.B. questa stored va in errore perchè viene fatta una insert nella tabella "temp_storico_cartelle" nel campo "TOT_LETTERE_DISTPOSTEL" che non esiste // ed una update sul campo "DATA_OPERAZIONE_NEWESCORRET" che non esiste // i campi sono stati commentati per testare la action // DA CONTROLLARE PERCHè ALCUNE VOLTE FUNZIONA _logger.LogInformation("execute stored procedure: new_dettaglio_racc_storico_cartelle"); var spReturnValue = new DAL.StoredProcedure.SP_new_dettaglio_racc_storico_cartelle(RepositoryContext); spReturnValue.Set(codiceRaccomandata); _logger.LogInformation("execute stored procedure: SP_temp_storico_cartelle"); var sptempstoricocartelle = new DAL.StoredProcedure.SP_temp_storico_cartelle(RepositoryContext); var presente = sptempstoricocartelle.Get().Result; if (!presente.Any()) { return(Ok(new DettaglioCodiceRaccViewModel() { raccomandata = codiceRaccomandata })); } var sptempstoricocartelleRow = presente.FirstOrDefault <NewTempStoricoCartelle>(); _logger.LogInformation("execute stored procedure: SP_count_code_racc_from_new_immagini"); var spCountCodeRaccFromNewImmagini = new DAL.StoredProcedure.SP_count_code_racc_from_new_immagini(RepositoryContext); var spCountCodeRaccFromNewImmaginiNumero = spCountCodeRaccFromNewImmagini.Get(codiceRaccomandata).Result .FirstOrDefault <NewCountCodeRacc>().numero; _logger.LogInformation("execute stored procedure: SP_count_code_racc_from_new_immagini_pmr "); var spCountCodeRaccFromImmaginiPrm = new DAL.StoredProcedure.SP_count_code_racc_from_new_immagini_pmr(RepositoryContext); var spCountCodeRaccFromImmaginiPrmNumero = spCountCodeRaccFromImmaginiPrm.Get(codiceRaccomandata).Result .FirstOrDefault <NewCountCodeRacc>().numero; // query presente nel progetto originale ma non utilizzata ------------------- // logger.LogInformation("execute query on esa_racc"); // using (var context = new RARContext()) // { // var esaRaccs = context.EsaRacc.FromSql("SELECT * FROM esa_racc WHERE code_racc = {0}", codiceRaccomandata).ToList(); // } //return Content(JsonConvert.SerializeObject(new var dettaglioRaccomandata = new DettaglioRaccomandata() { CodiceRaccomandata = sptempstoricocartelleRow.CodeRaccEsaracc, NumeroRaccomandate = spCountCodeRaccFromNewImmaginiNumero, NumeroRaccomandatePMR = spCountCodeRaccFromImmaginiPrmNumero, Tempstoricocartelle = sptempstoricocartelleRow, NumeroDistintaDistpostel = sptempstoricocartelleRow.NumeroDistintaDistpostel }; var result = Traslate(dettaglioRaccomandata); return(Ok(result)); } catch (Exception ex) { _logger.LogError(ex, ex.Message); return(Content(ex.Message)); } }