Esempio n. 1
0
        public ActionResult Contatti(int id)
        {
            Partecipante partecipante = db.Partecipanti.Include("Contatti").Single(x => x.ID == id);
            var          model        = partecipante.Contatti;

            return(View(partecipante));
        }
Esempio n. 2
0
 public static Spostamento FromPartecipante(Partecipante part)
 {
     return(new Spostamento()
     {
         PartecipanteObj = part
     });
 }
Esempio n. 3
0
        public ActionResult Quote(int id)
        {
            Partecipante partecipante = db.Partecipanti.Include("QuoteAcquistate").Single(x => x.ID == id);
            var          model        = partecipante.QuoteAcquistate;

            return(View(partecipante));
        }
Esempio n. 4
0
        public ActionResult DeleteConfirmed(int id)
        {
            Partecipante partecipante = db.Partecipanti.Find(id);

            db.Partecipanti.Remove(partecipante);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 5
0
 void pop_Closed(object sender, object e)
 {
     if ((sender as Popup).Tag != null)
     {
         Partecipante part = (sender as Popup).Tag as Partecipante;
         bufferPartecipanti.Add(part);
     }
 }
        public async Task <Punteggio> Read(ApplicationDbContext db, Esame e, Partecipante p)
        {
            var s = await db.Punteggi
                    .Where(d => d.PartecipanteId == p.Id && d.EsameId == e.Id)
                    .FirstOrDefaultAsync();

            return(s);
        }
Esempio n. 7
0
        //    private void Update(Partecipante model) {
        //        var existingParent = db.Partecipanti
        //    .Where(p => p.ID == model.ID)
        //    .Include(p => p.QuoteAcquistate)
        //    .SingleOrDefault();

        //if (existingParent != null)
        //{
        //    // Update parent
        //    db.Entry(existingParent).CurrentValues.SetValues(model);

        //    // Delete children
        //    foreach (var existingChild in existingParent.Children.ToList())
        //    {
        //        if (!model.Children.Any(c => c.Id == existingChild.Id))
        //            _dbContext.Children.Remove(existingChild);
        //    }

        //    // Update and Insert children
        //    foreach (var childModel in model.Children)
        //    {
        //        var existingChild = existingParent.Children
        //            .Where(c => c.Id == childModel.Id)
        //            .SingleOrDefault();

        //        if (existingChild != null)
        //            // Update child
        //            _dbContext.Entry(existingChild).CurrentValues.SetValues(childModel);
        //        else
        //        {
        //            // Insert child
        //            var newChild = new Child
        //            {
        //                Data = childModel.Data,
        //                //...
        //            };
        //existingParent.Children.Add(newChild);
        //        }
        //    }

        //    _dbContext.SaveChanges();
        //}

        // GET: Oratorio/Partecipanti/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Partecipante partecipante = db.Partecipanti.Find(id);

            if (partecipante == null)
            {
                return(HttpNotFound());
            }
            return(View(partecipante));
        }
Esempio n. 8
0
        public ActionResult Edit([Bind(Include = "ID,Nome,Cognome,DataNascita,ClasseFrequentata,Indirizzo,Annotazioni, CodiceIdentificativo, QuoteAcquistate, Recapiti")] Partecipante partecipante)
        {
            if (ModelState.IsValid)
            {
                db.Entry(db.Partecipanti
                         .First(x => x.ID == partecipante.ID))
                .CurrentValues.SetValues(partecipante);
                //db.Partecipanti.Attach(partecipante);

                db.SaveChanges();
                //return RedirectToAction("Index");
            }
            return(View(partecipante));
        }
Esempio n. 9
0
        //[ValidateAntiForgeryToken]
        public ActionResult Create([Bind(Include = "ID,Nome,Cognome,DataNascita,ClasseFrequentata,Indirizzo,Annotazioni")] Partecipante partecipante)
        {
            if (ModelState.IsValid)
            {
                if (db.Partecipanti.Any(x => x.Cognome == partecipante.Cognome && x.Nome == partecipante.Nome && x.DataNascita == partecipante.DataNascita))
                {
                    ModelState.AddModelError("", "Esiste già un partecipante con questi dati");
                    return(View(partecipante));
                }

                db.Partecipanti.Add(partecipante);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(partecipante));
        }
Esempio n. 10
0
        // GET: Oratorio/Partecipanti/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Partecipante partecipante = db.Partecipanti
                                        .Include(p => p.QuoteAcquistate)
                                        .Include(p => p.Contatti)
                                        .First(x => x.ID == id);

            if (partecipante == null)
            {
                return(HttpNotFound());
            }
            return(View(partecipante));
        }
Esempio n. 11
0
 public Corsa(List <Partecipante> l, Partecipante v = null)
 {
     ListaPartecipanti = l;
     Vincitore         = v;
 }
Esempio n. 12
0
        private async Task <bool> DownloadUserData()
        {
            bool toRet = false;


            LoadingMessage = "Caricamento dei dati relativi al dipendente";
            await Task.Delay(TimeSpan.FromSeconds(1));

            Settings.Instance.DipendenteInfo   = Dipendente.ToEntity(await dipAPI.GetDipendenteByUsername(Settings.Instance.Username));
            Settings.Instance.AnagraficaUtente = Anagrafica.ToEntity(await anaAPI.GetAnagrafica(Settings.Instance.DipendenteInfo.FKIDAnagrafica.Value));

            LoadingMessage = "Caricamento dei viaggi pianificati";
            await Task.Delay(TimeSpan.FromSeconds(1));

            var viaggi = await viaAPI.GetViaggiByAutista(Settings.Instance.DipendenteInfo.IDDipendente);

            List <PartecipanteDTO> totParts = new List <PartecipanteDTO>();

            foreach (ViaggioDTO viaggio in viaggi)
            {
                LoadingMessage = String.Format("Caricamento dei dati passeggeri per il viaggio:\n{0}", viaggio.DescrizioneViaggio);
                totParts.AddRange(await parAPI.GetPartecipantiViaggio(viaggio.IDViaggio));
                await Task.Delay(TimeSpan.FromSeconds(1));
            }

            LoadingMessage = "Salvataggio dei dati in corso";

            if (await dbMan.cmDB.Table <Dipendente>().Where(d => d.IDDipendente == Settings.Instance.DipendenteInfo.IDDipendente).CountAsync() > 0)
            {
                await dbMan.cmDB.UpdateAsync(Settings.Instance.DipendenteInfo);
            }
            else
            {
                await dbMan.cmDB.InsertAsync(Settings.Instance.DipendenteInfo);
            }


            if (await dbMan.cmDB.Table <Anagrafica>().Where(a => a.IDAnagrafica == Settings.Instance.AnagraficaUtente.IDAnagrafica).CountAsync() > 0)
            {
                await dbMan.cmDB.UpdateAsync(Settings.Instance.AnagraficaUtente);
            }
            else
            {
                await dbMan.cmDB.InsertAsync(Settings.Instance.AnagraficaUtente);
            }

            List <int> idNuoviViaggi = viaggi.Select(v => v.IDViaggio).ToList();

            List <Viaggio> viaggiPresenti = await dbMan.cmDB.Table <Viaggio>().Where(v => idNuoviViaggi.Contains(v.IDViaggio)).ToListAsync();

            List <int> idViaggiEditabili = viaggiPresenti.Where(x => x.FKIDStato == 1).Select(x => x.IDViaggio).ToList();
            List <int> idViaggiNonEdit   = viaggiPresenti.Select(x => x.IDViaggio).Except(idViaggiEditabili).ToList();

            foreach (Viaggio viag in viaggi.Select(v => Viaggio.ToEntity(v)).ToList())
            {
                if (!idViaggiNonEdit.Contains(viag.IDViaggio))
                {
                    if (idViaggiEditabili.Contains(viag.IDViaggio))
                    {
                        await dbMan.cmDB.UpdateAsync(viag);
                    }
                    else
                    {
                        await dbMan.cmDB.InsertAsync(viag);
                    }
                }
            }


            List <Partecipante> partecipantiPresenti = await dbMan.cmDB.Table <Partecipante>().ToListAsync();

            List <int> idPassEdit = partecipantiPresenti.Where(p => idViaggiEditabili.Contains(p.FKIDViaggio.Value))
                                    .Select(x => x.IDSpostamento).ToList();
            List <int> idPassNonEdit = partecipantiPresenti.Where(p => idViaggiNonEdit.Contains(p.FKIDViaggio.Value))
                                       .Select(x => x.IDSpostamento).ToList();


            foreach (Partecipante part in totParts.Select(p => Partecipante.ToEntity(p)).ToList())
            {
                if (!idPassNonEdit.Contains(part.IDSpostamento))
                {
                    if (idPassEdit.Contains(part.IDSpostamento))
                    {
                        await dbMan.cmDB.UpdateAsync(part);
                    }
                    else
                    {
                        await dbMan.cmDB.InsertAsync(part);
                    }
                }
            }

            ShowLoading = false;
            return(toRet);
        }
 public async Task Delete(ApplicationDbContext db, Partecipante p)
 {
     db.Partecipanti.Remove(p);
     await db.SaveChangesAsync();
 }
 public async Task Update(ApplicationDbContext db, Partecipante p)
 {
     db.Partecipanti.Update(p);
     await db.SaveChangesAsync();
 }