public ActionResult Details(PortaleWebProfiloViewModel viewModel) { try { if (base.ModelState.IsValid) { using (DatabaseContext db = new DatabaseContext()) { // da modificare PortaleWebViewModel viewModel2 = (Session["portaleweb"] as List <PortaleWebViewModel>).Where(p => p.Token == viewModel.Token).SingleOrDefault(); int idPartner = Convert.ToInt32(viewModel2.Id); ATTIVITA model = db.ATTIVITA.Where(p => p.ID == idPartner).SingleOrDefault(); model.NOME = viewModel.Nome; model.DOMINIO = viewModel.Dominio; ATTIVITA_EMAIL modelEmail = model.ATTIVITA_EMAIL.SingleOrDefault(item => item.TIPO == (int)TipoEmail.Registrazione); modelEmail.EMAIL = viewModel.Email; db.ATTIVITA_EMAIL.Attach(modelEmail); ATTIVITA_TELEFONO modelTelefono = model.ATTIVITA_TELEFONO.SingleOrDefault(item => item.TIPO == (int)TipoTelefono.Privato); modelTelefono.TELEFONO = viewModel.Telefono; db.ATTIVITA_TELEFONO.Attach(modelTelefono); model.DATA_MODIFICA = DateTime.Now; db.Entry <ATTIVITA>(model).State = System.Data.Entity.EntityState.Modified; if (db.SaveChanges() > 0) { // trovare portaleweb modificato e sostituirlo //Session["portaleweb"] = model; Session["portaleweb"] = (Session["utente"] as PersonaModel).Persona.PERSONA_ATTIVITA .Select(item => new PortaleWebViewModel(item, item.ATTIVITA.ATTIVITA_EMAIL.Where(e => e.ID_ATTIVITA == item.ID_ATTIVITA).ToList(), item.ATTIVITA.ATTIVITA_TELEFONO.Where(t => t.ID_ATTIVITA == item.ID_ATTIVITA).ToList() )).ToList(); TempData["salvato"] = true; } } } } catch (Exception exception) { //Elmah.ErrorSignal.FromCurrentContext().Raise(exception); LoggatoreModel.Errore(exception); } return(View(viewModel)); }
public ActionResult OfferteRifiutate(int pagina = 1) { List <OffertaViewModel> offerte = new List <OffertaViewModel>(); try { using (DatabaseContext db = new DatabaseContext()) { int utente = ((PersonaModel)Session["utente"]).Persona.ID; // verifica stato offerta se attivo o non accettata, identità utente e stato di attivazione, presenza bene o servizio -- vechia // verifica identità utente e stato di attivazione, presenza bene o servizio var query = db.OFFERTA.Where(item => item.PERSONA.ID == utente && item.PERSONA.STATO == (int)Stato.ATTIVO && (item.STATO == (int)StatoOfferta.ANNULLATA) && (item.ANNUNCIO.ID_OGGETTO != null || item.ANNUNCIO.ID_SERVIZIO != null)); int numeroElementi = Convert.ToInt32(WebConfigurationManager.AppSettings["numeroElementi"]); ViewData["TotalePagine"] = (int)Math.Ceiling((decimal)query.Count() / (decimal)numeroElementi); ViewData["Pagina"] = pagina; pagina -= 1; string randomString = Utility.RandomString(3); List <OFFERTA> lista = query .OrderByDescending(item => item.DATA_INSERIMENTO) .Skip(pagina * numeroElementi) .Take(numeroElementi).ToList(); foreach (OFFERTA item in lista) { OffertaViewModel offertaEffettuata = new OffertaViewModel(db, item); offerte.Add(offertaEffettuata); } if (offerte.Count > 0) { RefreshPunteggioUtente(db); } } } catch (Exception eccezione) { //Elmah.ErrorSignal.FromCurrentContext().Raise(ex); LoggatoreModel.Errore(eccezione); } return(View(offerte)); }
public ActionResult Concluse(int pagina = 1) { List <AnnuncioViewModel> vendite = new List <AnnuncioViewModel>(); try { using (DatabaseContext db = new DatabaseContext()) { int utente = ((PersonaModel)Session["utente"]).Persona.ID; var query = db.ANNUNCIO.Where(item => item.ID_PERSONA == utente // commentato perchè voglio vedere qualsiasi annuncio non in vendita o in bozza //&& (item.STATO == (int)StatoVendita.ELIMINATO || item.STATO == (int)StatoVendita.BARATTATO || item.STATO == (int)StatoVendita.VENDUTO) && !(item.STATO == (int)StatoVendita.INATTIVO || item.STATO == (int)StatoVendita.ATTIVO) && (item.ID_OGGETTO != null || item.ID_SERVIZIO != null)); int numeroElementi = Convert.ToInt32(WebConfigurationManager.AppSettings["numeroElementi"]); ViewData["TotalePagine"] = (int)Math.Ceiling((decimal)query.Count() / (decimal)numeroElementi); ViewData["Pagina"] = pagina; pagina -= 1; List <ANNUNCIO> listaAnnunci = query .OrderByDescending(item => item.DATA_INSERIMENTO) .Skip(pagina * numeroElementi) .Take(numeroElementi) .ToList(); foreach (ANNUNCIO annuncio in listaAnnunci) { AnnuncioModel annuncioModel = new AnnuncioModel(); vendite.Add(annuncioModel.GetViewModel(db, annuncio)); } if (vendite.Count > 0) { RefreshPunteggioUtente(db); } } } catch (Exception ex) { //Elmah.ErrorSignal.FromCurrentContext().Raise(ex); LoggatoreModel.Errore(ex); } return(View(vendite)); }
private string SendPostFacebook(string nome, string message, string picture, string link) { try { FacebookClient app = new FacebookClient(ConfigurationManager.AppSettings["FBTokenPermanenteG4G"]); bool visibile = false; if (!HttpContext.IsDebuggingEnabled) { visibile = true; } Dictionary <string, object> feed = new Dictionary <string, object>() { { "published", visibile }, //{ "name", nome }, { "message", message }, //{ "picture", picture }, { "link", link } }; JsonObject response = (JsonObject)app.Post("/v3.2/" + ConfigurationManager.AppSettings["FBPageIDG4G"] + "/feed", feed); TempData["FBINFO"] = "Pubblicato anche su Facebook! Complimenti per i crediti guadagnati!"; return(response["id"].ToString()); } catch (FacebookOAuthException ex) { //ErrorSignal.FromCurrentContext().Raise(ex); LoggatoreModel.Errore(ex); } catch (FacebookApiException ex) { //ErrorSignal.FromCurrentContext().Raise(ex); LoggatoreModel.Errore(ex); } catch (Exception ex) { //ErrorSignal.FromCurrentContext().Raise(ex); LoggatoreModel.Errore(ex); } return(string.Empty); }
public ActionResult Acquisto(string acquisto = null, string baratto = null) { if (String.IsNullOrEmpty(acquisto) && String.IsNullOrEmpty(baratto)) { return(RedirectToAction("", "Home")); } OffertaViewModel viewModel = new OffertaViewModel(); try { using (DatabaseContext db = new DatabaseContext()) { int numeroElementi = Convert.ToInt32(WebConfigurationManager.AppSettings["numeroElementi"]); OFFERTA offerta = new OFFERTA(); int idUtente = (Session["utente"] as PersonaModel).Persona.ID; // fare un if e fare ricerca o per acquisto direttamente o per baratto if (!String.IsNullOrEmpty(acquisto)) { //Guid tokenAcquisto = Guid.Parse(Utility.DecodeToString(acquisto.Trim().Substring(3, acquisto.Trim().Length - 6))); Guid tokenAcquisto = Guid.Parse(acquisto); offerta = db.OFFERTA.SingleOrDefault(c => c.ANNUNCIO.TOKEN == tokenAcquisto && c.ANNUNCIO.ID_PERSONA == idUtente && c.PERSONA.STATO == (int)Stato.ATTIVO); } else { //Guid tokenBaratto = Guid.Parse(Utility.DecodeToString(baratto.Trim().Substring(3, baratto.Trim().Length - 6))); Guid tokenBaratto = Guid.Parse(baratto); offerta = db.OFFERTA.SingleOrDefault(c => c.OFFERTA_BARATTO.Count(b => b.ANNUNCIO.TOKEN == tokenBaratto && b.ANNUNCIO.ID_PERSONA == idUtente) > 0); } viewModel = new OffertaViewModel(db, offerta); } } catch (Exception eccezione) { //Elmah.ErrorSignal.FromCurrentContext().Raise(ex); LoggatoreModel.Errore(eccezione); } return(View(viewModel)); }
public bool SendEmail(EmailModel model) { try { using (MailMessage mail = new MailMessage()) { model.To.ForEach(to => { mail.To.Add(to); }); mail.Subject = model.Subject; mail.Body = RenderRazorViewToString(model.ControllerContext, "Email/" + model.Body, model.Layout, model.DatiEmail); //mail.Body = View("Email/" + model.Body, model.Layout, model.DatiEmail).ToString(); // aggiunge allegati model.Attachments.ForEach(m => { mail.Attachments.Add(new Attachment(m.InputStream, m.FileName)); }); mail.Priority = model.Priority; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); // verifico se inviare in modo asincrono la mail if (model.SendAsync) { smtp.SendMailAsync(mail); } else { smtp.Send(mail); } } return(true); } catch (Exception ex) { //Elmah.ErrorSignal.FromCurrentContext().Raise(ex); LoggatoreModel.Errore(ex); } return(false); }
public ActionResult SavePayment(SchedaPagamentoViewModel scheda) { try { using (DatabaseContext db = new DatabaseContext()) { db.TRANSAZIONE.Add(new TRANSAZIONE() { NOME = scheda.Nome, SOLDI = scheda.Soldi, TIPO = 0, ID_CONTO_DESTINATARIO = ((PersonaModel)Session["utente"]).Persona.ID_CONTO_CORRENTE, ID_CONTO_MITTENTE = db.PERSONA.SingleOrDefault(item => item.ID == scheda.VenditoreId).ID_CONTO_CORRENTE, }); } } catch (Exception ex) { //Elmah.ErrorSignal.FromCurrentContext().Raise(ex); LoggatoreModel.Errore(ex); } return(View()); }
public ActionResult Payment(PayPalIndexViewModel viewModel) { string urlCancel = GetUrlCancel(viewModel.Azione, viewModel.Token); int? id = null; try { //getting the apiContext as earlier APIContext apiContext = Configuration.GetAPIContext(); if ((Session["PayPalCompra"] != null && Session["PayPalAnnuncio"] != null) || Session["PayPalOfferta"] != null) { id = GetIdFromSession(); bool enablePagamento = CanPagamento(viewModel.Azione); if (string.IsNullOrEmpty(viewModel.PayerID) && string.IsNullOrWhiteSpace(viewModel.Guid) && enablePagamento) { //this section will be executed first because PayerID doesn't exist //it is returned by the create function call of the payment class // Creating a payment // baseURL is the url on which paypal sendsback the data. // So we have provided URL of this controller only viewModel.Guid = Convert.ToString((new Random()).Next(100000)); System.Web.Routing.RouteValueDictionary data = new System.Web.Routing.RouteValueDictionary(viewModel); string url = Url.Action("Payment", "PayPal", data, this.Request.Url.Scheme, this.Request.Url.Host); System.Web.Routing.RouteValueDictionary dataCancelPayPal = new System.Web.Routing.RouteValueDictionary(new { azione = viewModel.Azione, id = id }); string urlCancelPaypal = Url.Action("CancelPayment", "PayPal", dataCancelPayPal, this.Request.Url.Scheme, this.Request.Url.Host); //CreatePayment function gives us the payment approval url //on which payer is redirected for paypal account payment var createdPayment = this.CreatePayment(apiContext, url, urlCancelPaypal, GetListTransaction(viewModel.Azione, viewModel.Guid)); //get links returned from paypal in response to Create function call var links = createdPayment.links.GetEnumerator(); string paypalRedirectUrl = null; while (links.MoveNext()) { Links lnk = links.Current; if (lnk.rel.ToLower().Trim().Equals("approval_url")) { //saving the payapalredirect URL to which user will be redirected for payment paypalRedirectUrl = lnk.href; } } // saving the paymentID in the key guid Session.Add(viewModel.Guid, createdPayment.id); return(Redirect(paypalRedirectUrl)); } else if (!string.IsNullOrEmpty(viewModel.PayerID) || !string.IsNullOrWhiteSpace(viewModel.Guid)) { // This section is executed when we have received all the payments parameters // from the previous call to the function Create // Executing a payment var executedPayment = ExecutePayment(apiContext, viewModel.PayerID, Session[viewModel.Guid] as string); if (executedPayment.state.ToLower() != "approved") { // redirect errore nell'acquisto TempData["errore"] = "Errore durante l'acquisto"; } else { if (SavePayment(viewModel, executedPayment)) { TempData["Esito"] = App_GlobalResources.Language.JsonBuyAd; TempData["pagamentoEffettuato"] = true; return(Redirect(_UrlFinePagamento)); } else { TempData["errore"] = App_GlobalResources.ErrorResource.AdBuyFailed; } } } } else { TempData["errore"] = "Sessione pagamento scaduta!"; } } catch (Exception ex) { //Logger.log("Error" + ex.Message); LoggatoreModel.Errore(ex); // redirect errore nell'acquisto TempData["errore"] = "Errore grave durante l'acquisto: " + ex.Message; } // mettere qui l'annullo dell'acquisto in modo da tornare indietro if (id != null) { AnnullaPagamento(viewModel.Azione, (int)id); } return(Redirect(urlCancel)); }
private void AnnullaPagamento(AzionePayPal azione, int id) { try { switch (azione) { case AzionePayPal.Acquisto: using (DatabaseContext db = new DatabaseContext()) { // se non metto la sessione_compratore torno indietro dall'acquisto e annullo tutto. ANNUNCIO model = db.ANNUNCIO.SingleOrDefault(m => m.ID == id && m.SESSIONE_COMPRATORE != null); if (model != null) { if (model.STATO == (int)StatoVendita.SOSPESOPEROFFERTA) { model.STATO = (int)StatoVendita.BARATTOINCORSO; } else { model.STATO = (int)StatoVendita.ATTIVO; } model.SESSIONE_COMPRATORE = null; model.DATA_MODIFICA = DateTime.Now; db.SaveChanges(); } } break; case AzionePayPal.Offerta: using (DatabaseContext db = new DatabaseContext()) { OFFERTA model = db.OFFERTA.SingleOrDefault(m => m.ID == id && m.SESSIONE_COMPRATORE != null); if (model != null) { model.ANNUNCIO.STATO = (int)StatoVendita.ATTIVO; model.SESSIONE_COMPRATORE = null; model.STATO = (int)StatoOfferta.ATTIVA; db.SaveChanges(); } } break; case AzionePayPal.OffertaOK: using (DatabaseContext db = new DatabaseContext()) { ANNUNCIO model = db.ANNUNCIO.SingleOrDefault(m => m.ID == id && m.SESSIONE_COMPRATORE != null); if (model != null) { model.STATO = (int)StatoVendita.BARATTOINCORSO; model.SESSIONE_COMPRATORE = null; model.DATA_MODIFICA = DateTime.Now; db.SaveChanges(); } } break; } } catch (Exception eccezione) { LoggatoreModel.Errore(eccezione); } }
public ActionResult AccettaOfferta(string token) { int idOfferta = Utility.DecodeToInt(token); string messaggio = ""; //OffertaModel offerta = new OffertaModel(idOfferta, (Session["utente"] as PersonaModel).Persona); using (DatabaseContext db = new DatabaseContext()) { using (var transazioneDb = db.Database.BeginTransaction()) { try { PersonaModel utente = ((PersonaModel)System.Web.HttpContext.Current.Session["utente"]); OFFERTA offerta = db.OFFERTA.Include(m => m.PERSONA) .Where(o => o.ID == idOfferta && o.ANNUNCIO.ID_PERSONA == utente.Persona.ID && (o.STATO == (int)StatoOfferta.ATTIVA || o.STATO == (int)StatoOfferta.ACCETTATA_ATTESO_PAGAMENTO)).SingleOrDefault(); OffertaModel offertaModel = new OffertaModel(offerta); Models.Enumerators.VerificaOfferta verifica = offertaModel.CheckAccettaOfferta(utente, offerta); // se bisogna pagare la spedizione reindirizzo su paypal if (verifica == Models.Enumerators.VerificaOfferta.VerificaCartaDiCredito) { // prima setto la sessione per il pagamento offerta.STATO = (int)StatoOfferta.ACCETTATA_ATTESO_PAGAMENTO; offerta.SESSIONE_COMPRATORE = HttpContext.Session.SessionID + "§" + Guid.NewGuid().ToString(); db.OFFERTA.Attach(offerta); db.Entry(offerta).State = EntityState.Modified; if (db.SaveChanges() > 0) { // metto l'annuncio dell'offerta come baratto in corso offertaModel.ANNUNCIO.STATO = (int)StatoVendita.BARATTOINCORSO; db.ANNUNCIO.Attach(offertaModel.ANNUNCIO); db.Entry(offertaModel.ANNUNCIO).State = EntityState.Modified; if (db.SaveChanges() > 0) { transazioneDb.Commit(); //Session["PayPalCompra"] = viewModel; Session["PayPalOfferta"] = new OffertaModel(offertaModel.OffertaOriginale); return(RedirectToAction("Payment", "PayPal", new { Id = offerta.ID, Token = token, Azione = AzionePayPal.Offerta })); } } } else if (verifica == Models.Enumerators.VerificaOfferta.Ok) { if (offertaModel.Accetta(db, utente.Persona, null, ref messaggio)) { // se offerta dev'essere pagata, invio notifica e reindirizzo a pagina pagamento // se venditore annulla pagamento, potrà sempre pagare più avanti, sennò feedback negativo e annullo transazioni if (offertaModel.ANNUNCIO.STATO == (int)StatoVendita.BARATTOINCORSO) { Models.ViewModels.Email.PagamentoOffertaViewModel offertaAccettata = new Models.ViewModels.Email.PagamentoOffertaViewModel(); offertaAccettata.NominativoDestinatario = offertaModel.PERSONA.NOME + " " + offertaModel.PERSONA.COGNOME; offertaAccettata.NomeAnnuncio = offertaModel.ANNUNCIO.NOME; offertaAccettata.Moneta = offertaModel.PUNTI; offertaAccettata.SoldiSpedizione = offertaModel.SOLDI; offertaAccettata.Baratti = offertaModel.OFFERTA_BARATTO.Select(m => m.ANNUNCIO.NOME).ToList(); this.SendNotifica(utente.Persona, offertaModel.PERSONA, TipoNotifica.OffertaAccettata, ControllerContext, "offertaAccettata", offertaAccettata); } transazioneDb.Commit(); ViewBag.Message = Language.AcceptedBid; return(Redirect(System.Web.HttpContext.Current.Request.UrlReferrer.ToString())); } } } catch (Exception eccezione) { //Elmah.ErrorSignal.FromCurrentContext().Raise(eccezione); LoggatoreModel.Errore(eccezione); } transazioneDb.Rollback(); } } TempData["MESSAGGIO"] = Language.ErrorAcceptBid; return(Redirect(System.Web.HttpContext.Current.Request.UrlReferrer.ToString())); }
public ActionResult Compra(AcquistoViewModel viewModel) { AnnuncioModel model = null; using (DatabaseContext db = new DatabaseContext()) { using (DbContextTransaction transaction = db.Database.BeginTransaction()) { try { Guid token = getTokenDecodificato(viewModel.Token); model = new AnnuncioModel(token, db); if (model.TOKEN == null) { throw new System.Web.HttpException(404, ExceptionMessage.AdNotFound); } if (ModelState.IsValid) { if (!Utility.IsUtenteAttivo(1, TempData)) { ModelState.AddModelError("", ErrorResource.UserEnabled); } else { Models.Enumerators.VerificaAcquisto verifica = model.Acquisto(db, viewModel); if (verifica == Models.Enumerators.VerificaAcquisto.Ok) { if (model.CompletaAcquisto(db, viewModel)) { TempData["Esito"] = Language.JsonBuyAd; TempData["pagamentoEffettuato"] = true; transaction.Commit(); this.RefreshPunteggioUtente(db); this.SendNotifica(model.PERSONA, model.PERSONA1, TipoNotifica.AnnuncioAcquistato, ControllerContext, "annuncioAcquistato", model); this.SendNotifica(model.PERSONA1, model.PERSONA, TipoNotifica.AnnuncioVenduto, ControllerContext, "annuncioVenduto", model); return(RedirectToAction("Index", "Annuncio", new { token = viewModel.Token })); } // altrimenti pagamento fallito! } else if (verifica == Models.Enumerators.VerificaAcquisto.VerificaCartaCredito) { string actionPagamento = "Payment"; if (viewModel.TipoCarta != TipoCartaCredito.PayPal) { actionPagamento = "PaymentWithCreditCard"; } transaction.Commit(); Session["PayPalCompra"] = viewModel; Session["PayPalAnnuncio"] = model; return(RedirectToAction(actionPagamento, "PayPal", new { Id = model.ID, Token = viewModel.Token, Azione = AzionePayPal.Acquisto })); } else { Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception(string.Format("Messaggio {0} per l'errore {1}", ErrorResource.AdBuyFailed, verifica.ToString()))); ModelState.AddModelError("", ErrorResource.AdBuyFailed); } } } //transaction.Rollback(); } catch (System.Web.HttpException eccezione) { //Elmah.ErrorSignal.FromCurrentContext().Raise(eccezione); LoggatoreModel.Errore(eccezione); throw new System.Web.HttpException(404, eccezione.Message); } catch (Exception eccezione) { ModelState.AddModelError("", eccezione.Message); //Elmah.ErrorSignal.FromCurrentContext().Raise(eccezione); LoggatoreModel.Errore(eccezione); } finally { if (db.Database.CurrentTransaction != null) { transaction.Rollback(); } } viewModel.Annuncio = model.GetViewModel(db); viewModel.Annuncio.Azione = "compra"; } } ViewData["acquistoViewModel"] = viewModel; return(View("Index", viewModel.Annuncio)); }
public ActionResult Contatti(ContattiViewModel value) { ViewBag.Title = App_GlobalResources.Language.Contacts + " - " + WebConfigurationManager.AppSettings["nomeSito"]; ViewBag.Description = App_GlobalResources.MetaTag.DescriptionContatti; ViewBag.Keywords = App_GlobalResources.MetaTag.KeywordsContatti; if (ModelState.IsValid) { string errore = string.Empty; try { RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper(); if (value.CheckCaptcha(recaptchaHelper, ref errore)) { using (DatabaseContext db = new DatabaseContext()) { value.IP = Request.UserHostAddress; value.SalvaSuDB(db); } value.InviaEmail(); } if (!string.IsNullOrWhiteSpace(errore)) { ViewBag.Message = errore; } else { TempData["MESSAGGIO"] = App_GlobalResources.ViewModel.ContactsSendOK; return(View()); } } catch (SmtpFailedRecipientsException ex) { foreach (SmtpFailedRecipientException t in ex.InnerExceptions) { var status = t.StatusCode; if (status == SmtpStatusCode.MailboxBusy || status == SmtpStatusCode.MailboxUnavailable) { errore = App_GlobalResources.ErrorResource.ContactsAwaitSendMail; } else { errore = string.Format(App_GlobalResources.ErrorResource.ContactsErrorSendMail, t.FailedRecipient); } } } catch (Exception ex) { LoggatoreModel.Errore(ex); ViewBag.Message = App_GlobalResources.ErrorResource.ContactsErrorGeneric; } finally { if (!string.IsNullOrWhiteSpace(errore)) { ViewBag.Message = errore; } } } return(View(value)); }
public ActionResult InviaOfferta(OffertaViewModel viewModel) { AnnuncioModel model = new AnnuncioModel(); string messaggio = ErrorResource.BidAd; if (ModelState.IsValid) { if (!Utility.IsUtenteAttivo(1, TempData)) { Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; return(Json(ErrorResource.UserEnabled)); } using (DatabaseContext db = new DatabaseContext()) { using (DbContextTransaction transaction = db.Database.BeginTransaction()) { try { if (viewModel.Save(db, ref messaggio)) { // aggiungere nella lista dei desideri string tokenDecodificato = HttpContext.Server.UrlDecode(viewModel.Annuncio.Token); Guid tokenGuid = Guid.Parse(tokenDecodificato); PersonaModel utente = (PersonaModel)HttpContext.Session["utente"]; AnnuncioViewModel annuncio = null; addDesiderio(db, tokenGuid, utente.Persona.ID, ref annuncio); // salvare transazione transaction.Commit(); this.RefreshPunteggioUtente(db); // invia e-mail al venditore if (annuncio.Venditore.Persona != null) { this.SendNotifica(utente.Persona, annuncio.Venditore.Persona, TipoNotifica.OffertaRicevuta, ControllerContext, "offerta", viewModel); } return(Json(new { Messaggio = Language.JsonSendBid })); } transaction.Rollback(); } catch (Exception eccezione) { //Elmah.ErrorSignal.FromCurrentContext().Raise(eccezione); transaction.Rollback(); LoggatoreModel.Errore(eccezione); Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; return(Json(eccezione.Message)); } } } } else { var errori = ModelState.Where(m => m.Value.Errors.Count > 0) .Select(m => m.Value.Errors.Select(n => n.ErrorMessage)).SelectMany(m => m).ToList(); if (errori != null && errori.Count > 0) { messaggio = string.Join("<br />", errori); } } // acquisto generico Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest; return(Json(messaggio)); }
public ActionResult Suggeriti(int pagina = 1) { //List<ProposteAnnuncio> viewModel = new List<ProposteAnnuncio>(); List <OffertaViewModel> viewModel = new List <OffertaViewModel>(); try { using (DatabaseContext db = new DatabaseContext()) { db.Database.Connection.Open(); PersonaModel utente = (PersonaModel)Session["utente"]; int idUtente = utente.Persona.ID; int contoAttuale = utente.Punti; /* * var query = db.ANNUNCIO_DESIDERATO.Where(m => m.ID_PERSONA == idUtente && // sugli annunci che desidero * (m.ANNUNCIO.PUNTI <= contoAttuale || // gli annunci che mi posso permettere * m.PERSONA.ANNUNCIO.Count(a => a.ANNUNCIO_DESIDERATO.Count(ad => ad.ID_PERSONA == m.ANNUNCIO.ID_PERSONA) > 0) > 0)); // o di cui desiderano almeno un mio annuncio */ var query = db.ANNUNCIO_DESIDERATO.Where(m => m.ID_PERSONA == idUtente && ( // sugli annunci che desidero (m.ANNUNCIO.STATO != (int)StatoVendita.ELIMINATO && m.ANNUNCIO.STATO != (int)StatoVendita.BARATTATO && m.ANNUNCIO.STATO != (int)StatoVendita.VENDUTO) && m.PERSONA.CONTO_CORRENTE.CONTO_CORRENTE_MONETA.Count() >= m.ANNUNCIO.PUNTI || // se ho abbastanza crediti db.ANNUNCIO_DESIDERATO.Count(ad => ad.ID_PERSONA == m.ANNUNCIO.ID_PERSONA && ad.ANNUNCIO.ID_PERSONA == idUtente && // o di cui desiderano almeno un mio annuncio (ad.ANNUNCIO.STATO != (int)StatoVendita.ELIMINATO && ad.ANNUNCIO.STATO != (int)StatoVendita.BARATTATO && ad.ANNUNCIO.STATO != (int)StatoVendita.VENDUTO) ) > 0) ); int numeroElementi = Convert.ToInt32(WebConfigurationManager.AppSettings["numeroElementi"]); ViewData["TotalePagine"] = (int)Math.Ceiling((decimal)query.Count() / (decimal)numeroElementi); ViewData["Pagina"] = pagina; pagina -= 1; /* * query.OrderByDescending(item => item.ANNUNCIO.DATA_INSERIMENTO).OrderByDescending(item => item.ID) // ordinato per inserimento annuncio e poi per inserimento desiderio * .OrderByDescending(item => item.PERSONA.ANNUNCIO.Count(a => a.ANNUNCIO_DESIDERATO.Count(ad => ad.ID_PERSONA == item.ANNUNCIO.ID_PERSONA) > 0)) // ordinato per numeri annunci desiderati da altri */ query.OrderByDescending(item => item.ID) // ordinato per inserimento annuncio e poi per inserimento desiderio .OrderByDescending(item => db.ANNUNCIO_DESIDERATO.Count(ad => ad.ID_PERSONA == item.ANNUNCIO.ID_PERSONA && ad.ANNUNCIO.ID_PERSONA == idUtente && // o di cui desiderano almeno un mio annuncio (ad.ANNUNCIO.STATO != (int)StatoVendita.ELIMINATO && ad.ANNUNCIO.STATO != (int)StatoVendita.BARATTATO && ad.ANNUNCIO.STATO != (int)StatoVendita.VENDUTO) )) // ordinato per numeri annunci desiderati da altri .Skip(pagina * numeroElementi) .Take(numeroElementi) .ToList().ForEach(m => { /*ProposteAnnuncio proposta = new ProposteAnnuncio(db, m.ANNUNCIO); * db.ANNUNCIO.Where(a => a.ID_PERSONA == idUtente && (a.ANNUNCIO_DESIDERATO.Count(ad => ad.ID_PERSONA == m.ANNUNCIO.ID_PERSONA) > 0)).ToList().ForEach(a => * { * proposta.AnnunciDesiderati.Add(new AnnuncioViewModel(db, a)); * }); * * viewModel.Add(proposta);*/ OffertaViewModel offerta = new OffertaViewModel(); offerta.Annuncio = new AnnuncioViewModel(db, m.ANNUNCIO); db.ANNUNCIO.Where(a => a.ID_PERSONA == idUtente && (a.ANNUNCIO_DESIDERATO.Count(ad => ad.ID_PERSONA == m.ANNUNCIO.ID_PERSONA) > 0)).ToList().ForEach(a => { offerta.Baratti.Add(new AnnuncioViewModel(db, a)); }); viewModel.Add(offerta); }); } } catch (Exception eccezione) { //Elmah.ErrorSignal.FromCurrentContext().Raise(ex); LoggatoreModel.Errore(eccezione); } return(View(viewModel)); }
public ActionResult Index(string token, int pagina = 1) { AnnuncioModel model = null; using (DatabaseContext db = new DatabaseContext()) { using (System.Data.Entity.DbContextTransaction transaction = db.Database.BeginTransaction()) { try { int id = Utility.DecodeToInt(token); OFFERTA offerta = db.OFFERTA.SingleOrDefault(m => m.ID == id); if (offerta == null) { throw new HttpException(404, ExceptionMessage.AdNotFound); } model = new AnnuncioModel(offerta.ANNUNCIO); if (model.TOKEN == null) { throw new HttpException(404, ExceptionMessage.AdNotFound); } AcquistoViewModel viewModel = new AcquistoViewModel(offerta); if (ModelState.IsValid) { if (!Utility.IsUtenteAttivo(1, TempData)) { ModelState.AddModelError("", ErrorResource.UserEnabled); } else { Models.Enumerators.VerificaAcquisto verifica = model.Acquisto(db, viewModel, true); if (verifica == Models.Enumerators.VerificaAcquisto.Ok) { // PENSO CHE QUESTA ACTION SIA USATA SOLO PER OFFERTA E QUINDI CAMBIO CHIAMATA //if (model.CompletaAcquisto(db, viewModel)) if (model.CompletaAcquistoOfferta(db, offerta)) { TempData["Esito"] = Language.JsonBuyAd; TempData["pagamentoEffettuato"] = true; transaction.Commit(); this.RefreshPunteggioUtente(db); return(RedirectToAction("Index", "Annuncio", new { token = viewModel.Token })); } // altrimenti pagamento fallito! } else if (verifica == Models.Enumerators.VerificaAcquisto.VerificaCartaCredito) { string actionPagamento = "Payment"; if (viewModel.TipoCarta != TipoCartaCredito.PayPal) { actionPagamento = "PaymentWithCreditCard"; } transaction.Commit(); Session["PayPalCompra"] = viewModel; Session["PayPalAnnuncio"] = model; return(RedirectToAction(actionPagamento, "PayPal", new { Id = offerta.ID, Token = viewModel.Token, Azione = AzionePayPal.OffertaOK })); } else { Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception(string.Format("Messaggio {0} per l'errore {1}", ErrorResource.AdBuyFailed, verifica.ToString()))); ModelState.AddModelError("", ErrorResource.AdBuyFailed); } } } //transaction.Rollback(); } catch (HttpException eccezione) { //Elmah.ErrorSignal.FromCurrentContext().Raise(eccezione); LoggatoreModel.Errore(eccezione); throw new HttpException(404, eccezione.Message); } catch (Exception eccezione) { ModelState.AddModelError("", eccezione.Message); //Elmah.ErrorSignal.FromCurrentContext().Raise(eccezione); LoggatoreModel.Errore(eccezione); } finally { if (db.Database.CurrentTransaction != null) { transaction.Rollback(); } } } int utente = ((PersonaModel)Session["utente"]).Persona.ID; return(View(GetListaOfferte(db, utente, pagina))); } }
private bool SaveOfferta(Payment payment) { OffertaModel offerta = Session["PayPalOfferta"] as OffertaModel; using (DatabaseContext db = new DatabaseContext()) { db.Database.Connection.Open(); // AGGIUNGERE TRANSAZIONE NELLA TABELLA DEI LOG LOG_PAGAMENTO log = new LOG_PAGAMENTO(); OFFERTA model = db.OFFERTA.Include(m => m.PERSONA) .Include(m => m.ANNUNCIO.ANNUNCIO_TIPO_SCAMBIO) .SingleOrDefault(m => m.ID == offerta.ID); log.ID_ANNUNCIO = model.ID_ANNUNCIO; log.ID_COMPRATORE = model.ID_PERSONA; log.ID_PAGAMENTO = model.ID.ToString(); log.ISTITUTO_PAGAMENTO = "PAYPAL"; log.NOME_ANNUNCIO = "Offerta per l'annuncio " + model.ANNUNCIO.NOME; log.DATA_INSERIMENTO = DateTime.Now; db.LOG_PAGAMENTO.Add(log); db.SaveChanges(); // cambia stato spedizione in pagata OFFERTA_SPEDIZIONE spedizione = model.OFFERTA_SPEDIZIONE.FirstOrDefault(); spedizione.DATA_MODIFICA = DateTime.Now; spedizione.STATO = (int)StatoSpedizione.PAGATA; db.OFFERTA_SPEDIZIONE.Attach(spedizione); db.Entry(spedizione).State = EntityState.Modified; db.SaveChanges(); int idPayPal = SavePayPal(db, payment); using (DbContextTransaction transaction = db.Database.BeginTransaction()) { try { var utente = (Session["utente"] as PersonaModel); string messaggio = string.Empty; // ripopolo classe offerta per calcoli nella funzione ACCETTA offerta.OffertaOriginale = model; offerta.ANNUNCIO.ANNUNCIO_TIPO_SCAMBIO = db.ANNUNCIO_TIPO_SCAMBIO .Include(m => m.ANNUNCIO_TIPO_SCAMBIO_SPEDIZIONE) .Where(m => m.ID_ANNUNCIO == offerta.ID_ANNUNCIO).ToList(); offerta.AnnuncioModel.ANNUNCIO_TIPO_SCAMBIO = offerta.ANNUNCIO.ANNUNCIO_TIPO_SCAMBIO; //if (offerta.Accetta(db, utente.Persona, utente.Credito, ref messaggio)) => non passa compratore nell'offerta if (offerta.Accetta(db, utente.Persona, idPayPal, ref messaggio)) { transaction.Commit(); Models.ViewModels.Email.PagamentoOffertaViewModel offertaAccettata = new Models.ViewModels.Email.PagamentoOffertaViewModel(); offertaAccettata.NominativoDestinatario = offerta.PERSONA.NOME + " " + offerta.PERSONA.COGNOME; offertaAccettata.NomeAnnuncio = offerta.ANNUNCIO.NOME; offertaAccettata.Moneta = offerta.PUNTI; offertaAccettata.SoldiSpedizione = offerta.SOLDI; offertaAccettata.Baratti = offerta.OFFERTA_BARATTO.Select(m => m.ANNUNCIO.NOME).ToList(); this.SendNotifica(utente.Persona, offerta.PERSONA, TipoNotifica.OffertaAccettata, ControllerContext, "offertaAccettata", offertaAccettata); //System.Web.Routing.RouteValueDictionary data = new System.Web.Routing.RouteValueDictionary(new { token = offerta.ID }); _UrlFinePagamento = Url.Action("OfferteRicevute", "Vendite", null, this.Request.Url.Scheme, this.Request.Url.Host); //return (db.SaveChanges() > 0); return(true); } } catch (Exception ex) { transaction.Rollback(); LoggatoreModel.Errore(ex); throw ex; } } } return(false); }
public ActionResult SavePayment() { try { using (DatabaseContext db = new DatabaseContext()) { SalvataggioPagamentoViewModel datiPagamento = (SalvataggioPagamentoViewModel)Session["pagamento"]; if (!ModelState.IsValid) { return(View("Payment", datiPagamento)); } // se esiste una sessione pagamento aperta e la mail ricevente dei soldi corrisponde a quella della login, // allora blocco la login e scatta l'errore if (Session["pagamento"] != null && datiPagamento.EmailReceivent.Equals(((PersonaModel)Session["utente"]).Email.FirstOrDefault(item => item.TIPO == (int)TipoEmail.Registrazione))) { ModelState.AddModelError("Error", string.Format(App_GlobalResources.Language.ErrorPaymentUser, datiPagamento.EmailReceivent)); return(View("Payment", datiPagamento)); } // effettuare il salvataggio TRANSAZIONE pagamento = new TRANSAZIONE(); pagamento.NOME = datiPagamento.DescriptionPayment; //pagamento.ID_ATTIVITA = datiPagamento.PortaleWebID; pagamento.SOLDI = (int)datiPagamento.TotalPrice; pagamento.TIPO = datiPagamento.TypePayment; pagamento.ID_CONTO_DESTINATARIO = (datiPagamento.PortaleWebID != null)? ((ATTIVITA)Session["utente"]).ID_CONTO_CORRENTE : ((PersonaModel)Session["utente"]).Persona.ID_CONTO_CORRENTE; pagamento.ID_CONTO_MITTENTE = datiPagamento.UtentePagatoID; pagamento.TEST = datiPagamento.Test; db.TRANSAZIONE.Add(pagamento); db.SaveChanges(); // impostare invio email pagamento effettuato EmailModel email = new EmailModel(ControllerContext); email.To.Add(new System.Net.Mail.MailAddress(datiPagamento.EmailReceivent, pagamento.CONTO_CORRENTE1.PERSONA.Select(item => item.NOME + ' ' + item.COGNOME).SingleOrDefault())); email.Subject = string.Format(Email.PaymentFromPartnersSubject, pagamento.NOME, (Session["utente"] as PersonaModel).Persona.NOME + ' ' + (Session["utente"] as PersonaModel).Persona.COGNOME, datiPagamento.Nominativo) + " - " + WebConfigurationManager.AppSettings["nomeSito"]; email.Body = "PagamentoDaPartners"; email.DatiEmail = new SchedaPagamentoViewModel() { Nome = pagamento.NOME, Compratore = (Session["utente"] as PersonaModel).Persona.NOME + ' ' + (Session["utente"] as PersonaModel).Persona.COGNOME, Venditore = pagamento.CONTO_CORRENTE1.PERSONA.Select(item => item.NOME + ' ' + item.COGNOME).SingleOrDefault(), Punti = (int)pagamento.PUNTI, Soldi = (int)pagamento.SOLDI, Data = pagamento.DATA_INSERIMENTO, Portale = datiPagamento.Nominativo, }; new EmailController().SendEmail(email); RemoveSessionPayment(); if (String.IsNullOrEmpty(datiPagamento.ReturnUrlForSuccess)) { return(Redirect(datiPagamento.UrlRequest)); } else { return(Redirect(datiPagamento.ReturnUrlForSuccess)); } } } catch (Exception ex) { //Elmah.ErrorSignal.FromCurrentContext().Raise(ex); LoggatoreModel.Errore(ex); ModelState.AddModelError("Error", ex); } return(View("Payment", new PagamentoViewModel((PagamentoAbstractModel)Session["pagamento"]))); }
public string CopiaServizio(PubblicaServizioCopiaViewModel viewModel) { if (ModelState.IsValid) { using (DatabaseContext db = new DatabaseContext()) { using (DbContextTransaction transaction = db.Database.BeginTransaction()) { try { PERSONA persona = (Session["utente"] as PersonaModel).Persona; Guid token = Guid.Parse(viewModel.TokenOK); ANNUNCIO annuncio = db.ANNUNCIO.SingleOrDefault(m => m.TOKEN == token && m.ID_PERSONA != persona.ID); if (annuncio != null) { // controllo se ha già quell'annuncio ANNUNCIO annuncioInPossesso = db.ANNUNCIO.FirstOrDefault(m => m.ID_PERSONA == persona.ID && (m.STATO == (int)StatoVendita.ATTIVO || m.STATO == (int)StatoVendita.INATTIVO) && (m.ID == annuncio.ID || m.ID_ORIGINE == annuncio.ID)); if (annuncioInPossesso == null) { ANNUNCIO_DESIDERATO annuncioDesiderato = db.ANNUNCIO_DESIDERATO.Where(m => m.ANNUNCIO.TOKEN == token && m.ID_PERSONA == persona.ID).SingleOrDefault(); if (annuncioDesiderato != null) { db.ANNUNCIO_DESIDERATO.Remove(annuncioDesiderato); db.SaveChanges(); } // copiare e salvare annuncio PubblicazioneViewModel viewModelAnnuncio = UpdateServizio(annuncio, viewModel); // copia foto List <string> fotoEsistenti = annuncio.ANNUNCIO_FOTO .Where(m => viewModelAnnuncio.Foto.Contains(m.ALLEGATO.NOME) == true) .Select(m => m.ALLEGATO.NOME).ToList(); for (int i = 0; i < fotoEsistenti.Count; i++) { string path = "~/Uploads/Images/"; if (annuncio.ATTIVITA != null) { path += annuncio.ATTIVITA.TOKEN; } else { path += annuncio.PERSONA.TOKEN; } string nomeFileOriginale = Server.MapPath(path + "/" + annuncio.DATA_INSERIMENTO.Year + "/Original/" + fotoEsistenti[i]); HttpFile fileOriginale = new HttpFile(nomeFileOriginale); FileUploadifive fileSalvatato = UploadImmagine("/Temp/Images/" + Session.SessionID + "/" + viewModel.TokenUploadFoto, fileOriginale); if (fileSalvatato != null) { string[] array = viewModelAnnuncio.Foto.ToArray(); int indiceArray = Array.IndexOf(array, fileSalvatato.NomeOriginale); viewModelAnnuncio.Foto[indiceArray] = fileSalvatato.Nome; } } viewModelAnnuncio.DbContext = db; annuncioInPossesso = new ANNUNCIO(); if (viewModelAnnuncio.SalvaAnnuncio(ControllerContext, annuncioInPossesso)) { int?idAnnuncio = annuncioInPossesso.ID; if (idAnnuncio != null) { // ASSEGNAZIONE CREDITI PersonaModel utente = ((PersonaModel)Session["utente"]); viewModelAnnuncio.InviaEmail(ControllerContext, annuncio, utente); decimal numeroCreditiBonus = AddBonus(db, utente, viewModelAnnuncio); TempData["BONUS"] = string.Format(Bonus.YouWin, numeroCreditiBonus, Language.Moneta); annuncioInPossesso.PERSONA = persona; // perchè sennò non riesce a recuperare l'associazione AnnuncioViewModel nuovoAnnuncio = new AnnuncioViewModel(db, annuncioInPossesso); transaction.Commit(); return(RenderRazorViewToString("PartialPages/_Possiedo", nuovoAnnuncio)); } } } } } catch (Exception eccezione) { transaction.Rollback(); //ErrorSignal.FromCurrentContext().Raise(eccezione); LoggatoreModel.Errore(eccezione); } } } } // desiderio non registrato throw new Exception(ExceptionMessage.CopyAdvertising); }
public ActionResult Index(FeedbackViewModel viewModel) { using (DatabaseContext db = new DatabaseContext()) { try { if (ModelState.IsValid) { db.Database.Connection.Open(); //string acquistoDecodificato = Uri.UnescapeDataString(viewModel.AcquistoID); //string acquistoPulito = acquistoDecodificato.Trim().Substring(3, acquistoDecodificato.Trim().Length - 6); //int idAcquisto = Utility.DecodeToInt(acquistoPulito); PersonaModel utente = (Session["utente"] as PersonaModel); ANNUNCIO_FEEDBACK model = db.ANNUNCIO_FEEDBACK.Include("Annuncio.Persona").Where(f => f.ID_VOTANTE == utente.Persona.ID && f.ID_ANNUNCIO == viewModel.AcquistoID).SingleOrDefault(); if (model != null) { TempData["feedback"] = model; TempData["salvato"] = Language.SavedFeedback; return(RedirectToAction("Inviato", new { id = model.ID })); } model = new ANNUNCIO_FEEDBACK(); ANNUNCIO model2 = null; if (viewModel.Tipo == TipoFeedback.Acquirente) { model2 = db.ANNUNCIO.Where(p => p.ID == viewModel.AcquistoID && p.ID_PERSONA != utente.Persona.ID).SingleOrDefault(); } else if (viewModel.Tipo == TipoFeedback.Venditore) { model2 = db.ANNUNCIO.Where(p => p.ID == viewModel.AcquistoID && p.ID_PERSONA == utente.Persona.ID).SingleOrDefault(); } if (model2 != null) { model.ID_ANNUNCIO = model2.ID; model.ID_VOTANTE = utente.Persona.ID; model.VOTO = viewModel.Voto; model.COMMENTO = viewModel.Opinione; model.DATA_INSERIMENTO = DateTime.Now; model.DATA_MODIFICA = model.DATA_INSERIMENTO; model.STATO = (int)Stato.ATTIVO; db.ANNUNCIO_FEEDBACK.Add(model); if (db.SaveChanges() > 0) { // feedback salvato AddBonusFeedback(utente.Persona, db, Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["bonusFeedback"]), model.ID_ANNUNCIO); return(RedirectToAction("Inviato", new { id = model.ID, nuovo = true })); } } ModelState.AddModelError("Errore", Language.ErrorFeedback); } } catch (Exception exception) { //Elmah.ErrorSignal.FromCurrentContext().Raise(exception); LoggatoreModel.Errore(exception); // se ha un errore generico o semplicemente sta cercando di fare un feedback return(Redirect(System.Web.Security.FormsAuthentication.DefaultUrl)); } finally { if (db.Database.Connection.State != System.Data.ConnectionState.Closed) { db.Database.Connection.Close(); db.Database.Connection.Dispose(); } } } return(View()); }
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)); }