public int GetFeedbackVenditore(DatabaseContext db, TipoVenditore tipoVenditore) { try { List <int> voti = db.ANNUNCIO_FEEDBACK .Where(item => (tipoVenditore == TipoVenditore.Persona && item.ANNUNCIO.ID_PERSONA == Id) || (tipoVenditore == TipoVenditore.Attivita && item.ANNUNCIO.ID_ATTIVITA == Id)).Select(item => item.VOTO).ToList(); int votoMassimo = voti.Count * 10; if (voti.Count <= 0) { return(-1); } else { int x = voti.Sum() / votoMassimo; return(x * 100); } } catch (Exception eccezione) { //Elmah.ErrorSignal.FromCurrentContext().Raise(eccezione); LoggatoreModel.Errore(eccezione); return(-1); } }
private void SetFeedbackVenditore(ANNUNCIO model, TipoVenditore tipoVenditore) { try { List <int> voti = model.ANNUNCIO_FEEDBACK .Where(item => (tipoVenditore == TipoVenditore.Persona && item.ANNUNCIO.ID_PERSONA == Venditore.Id) || (tipoVenditore == TipoVenditore.Attivita && item.ANNUNCIO.ID_ATTIVITA == Venditore.Id)).Select(item => item.VOTO).ToList(); int votoMassimo = voti.Count * 10; if (voti.Count <= 0) { VenditoreFeedback = -1; } else { int x = voti.Sum() / votoMassimo; VenditoreFeedback = x * 100; } } catch (Exception eccezione) { Elmah.ErrorSignal.FromCurrentContext().Raise(eccezione); VenditoreFeedback = -1; } }
private void Load(DatabaseContext db, TipoVenditore tipo) { if (tipo == TipoVenditore.Attivita) { var model = db.ATTIVITA.SingleOrDefault(m => m.ID == Id); LoadAttivita(model); } else { var model = db.PERSONA.SingleOrDefault(m => m.ID == Id); LoadPersona(model); } }
public UtenteVenditaViewModel(DatabaseContext db, int id, TipoVenditore tipo) { Id = id; Load(db, tipo); Tipo = tipo; }