Example #1
0
        public ActionResult AggiungiQuota(PartecipanteAggiungiQuotaModel model)
        {
            var partecipante = db.Partecipanti.Find(model.PartecipanteID);

            foreach (var item in model.QuoteDaAcquistare.Where(x => x.Aggiungi))
            {
                var quota = new QuotaAcquistata
                {
                    QuotaPartecipazioneID = item.ID,
                    PartecipanteID        = partecipante.ID,
                };
                partecipante.QuoteAcquistate.Add(quota);
            }
            db.SaveChanges();
            return(RedirectToAction("Quote", new { id = partecipante.ID }));
        }
Example #2
0
        public ActionResult AggiungiQuota(int partecipanteID)
        {
            var partecipante    = db.Partecipanti.Include("QuoteAcquistate").Single(x => x.ID == partecipanteID);
            var quote           = db.QuotePartecipazione.ToList();
            var quoteAcquistate = partecipante.QuoteAcquistate.Select(x => x.QuotaPartecipazione).ToArray();
            var model           = new PartecipanteAggiungiQuotaModel
            {
                PartecipanteID    = partecipanteID,
                QuoteDaAcquistare = quote.Except(quoteAcquistate).Select(x => new QuotaDaAcquistareModel
                {
                    Categoria   = x.Categoria,
                    Descrizione = x.Descrizione,
                    Costo       = x.Costo,
                    ID          = x.ID
                }).ToArray()
            };

            return(View(model));
        }