Exemple #1
0
        public IActionResult Upload(CreatePost post)
        {
            MemoryStream stream = new MemoryStream();

            post.MyCSV.CopyTo(stream);
            stream.Seek(0, 0);
            StreamReader fin = new StreamReader(stream);

            if (!fin.EndOfStream)
            {
                PrenotazioneContext db = new PrenotazioneContext();
                string riga            = fin.ReadLine();
                while (!fin.EndOfStream)
                {
                    riga = fin.ReadLine();
                    string[]     colonne = riga.Split(';');
                    Prenotazione p       = new Prenotazione {
                        Nome = colonne[0], Email = colonne[1], DataPrenotazione = Convert.ToDateTime(colonne[2])
                    };
                    db.Prenotazioni.Add(p);
                }
                db.SaveChanges();

                return(View("Grazie", db.Prenotazioni));
            }
            return(View());
        }
Exemple #2
0
        public IActionResult Prenota(Prenotazione p)
        {
            var db = new PrenotazioneContext();

            db.Prenotazioni.Add(p);
            db.SaveChanges();
            return(View("Grazie", db.Prenotazioni));
        }
Exemple #3
0
////////////////////////////////////////////////////////////
        public IActionResult Cancella(int id)
        {
            var          db           = new PrenotazioneContext();
            Prenotazione prenotazione = db.Prenotazioni.Find(id);

            db.Remove(prenotazione);
            db.SaveChanges();
            return(View("Cancella", db));
        }
Exemple #4
0
        public IActionResult Prenota(Prenotazione p)
        {
            //p.Data = DateTime.Now;

            PrenotazioneContext db = new PrenotazioneContext();

            db.Prenotazioni.Add(p);
            db.SaveChanges();

            //Prenotazione.Add(p);
            return(View("Grazie", db.Prenotazioni));
        }
        public IActionResult Index()
        {
            //istanzio un contest
            var db = new PrenotazioneContext();

            // aggiungo un record alla taballa prenotazioni

            db.Prenotazioni.Add(new Prenotazione {
                Nome = "kevin", Email = "*****@*****.**"
            });
            db.SaveChanges();
            return(View());
        }
Exemple #6
0
        //public IActionResult Modifica(int id, [Bind("Nome,Email")] Prenotazione nuovo)
        //{
        public IActionResult Modifica(int id, Prenotazione nuovo)
        {
            var db      = new PrenotazioneContext();
            var vecchio = db.Prenotazioni.Find(id);

            if (vecchio != null)
            {
                vecchio.Nome  = nuovo.Nome;
                vecchio.Email = nuovo.Email;
                db.Prenotazioni.Update(vecchio);
                db.SaveChanges();
                return(View("Grazie", db.Prenotazioni));
            }
            return(NotFound());
        }