public ActionResult Definitivo_OLD(List <string> acquisti) { try { foreach (string acquisto in acquisti) { //string token = acquisto.Trim().Substring(3, acquisto.Trim().Length - 6); int idOfferta = Utility.DecodeToInt(acquisto.Trim().Substring(3, acquisto.Trim().Length - 6)); using (DatabaseContext db = new DatabaseContext()) { PersonaModel utente = Session["utente"] as PersonaModel; System.Data.Entity.Core.Objects.ObjectParameter errore = new System.Data.Entity.Core.Objects.ObjectParameter("Errore", typeof(ErrorePagamento)); errore.Value = ErrorePagamento.Nessuno; Guid portaleWeb = Guid.Parse(System.Configuration.ConfigurationManager.AppSettings["portaleweb"]); // DEVO CAMBIARE E FARMI TORNARE IL TRANSAZIONE EFFETTUATO int?idPagamento = db.BENE_SAVE_PAGAMENTO(idOfferta, utente.Persona.ID_CONTO_CORRENTE, errore).FirstOrDefault(); if ((ErrorePagamento)errore.Value != ErrorePagamento.Nessuno) { return(Json(errore.Value.ToString())); } if (idPagamento == null) { return(Json(Language.ErrorPayment)); } TRANSAZIONE pagamento = db.TRANSAZIONE.Include("CONTO_CORRENTE.PERSONA.PERSONA_EMAIL").Where(p => p.ID == idPagamento).SingleOrDefault(); // aggiorno punti attuali utente Session["utente"] = new PersonaModel(db.PERSONA.Where(u => u.ID == utente.Persona.ID).FirstOrDefault()); PERSONA venditore = pagamento.CONTO_CORRENTE.PERSONA.SingleOrDefault(); // impostare invio email pagamento effettuato EmailModel email = new EmailModel(ControllerContext); email.To.Add(new System.Net.Mail.MailAddress(venditore.PERSONA_EMAIL.SingleOrDefault(e => e.TIPO == (int)TipoEmail.Registrazione).EMAIL)); string nominativo = (Session["utente"] as PersonaModel).Persona.NOME + " " + (Session["utente"] as PersonaModel).Persona.COGNOME; email.Subject = String.Format(Email.PaymentSubject, pagamento.NOME, nominativo) + " - " + WebConfigurationManager.AppSettings["nomeSito"]; email.Body = "Pagamento"; email.DatiEmail = new SchedaPagamentoViewModel() { Nome = pagamento.NOME, Compratore = nominativo, Venditore = venditore.NOME + " " + venditore.COGNOME, Punti = (int)pagamento.PUNTI, Soldi = (int)pagamento.SOLDI, Data = pagamento.DATA_INSERIMENTO, }; new EmailController().SendEmail(email); return(Json(new { Messaggio = Language.CompletedPurchase })); } } } catch (Exception ex) { //Elmah.ErrorSignal.FromCurrentContext().Raise(ex); LoggatoreModel.Errore(ex); // log errore, invio mail Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; return(Json(ex.ToString())); } Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; return(Json(Language.ErrorPayment)); }