Exemplo n.º 1
0
        public IActionResult GetPrenotazioni([DataSourceRequest] DataSourceRequest request)
        {
            List <Prenotazioni> prenotazioni = new List <Prenotazioni>();

            try
            {
                Prenotazioni p1 = new Prenotazioni();
                p1.idUtente = "1";
                p1.idCorso  = 1;
                p1.id       = 1;
                prenotazioni.Add(p1);

                Prenotazioni p2 = new Prenotazioni();
                p2.idUtente = "2";
                p2.idCorso  = 2;
                p2.id       = 2;
                prenotazioni.Add(p2);

                Prenotazioni p3 = new Prenotazioni();
                p3.idUtente = "3";
                p3.idCorso  = 3;
                p3.id       = 3;
                prenotazioni.Add(p3);
            }
            catch (Exception e)
            {
                Console.WriteLine("Errore : " + e.Message);
            }

            return(Json(prenotazioni.ToDataSourceResult(request)));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("id,data,ora,idCorso,idUtente")] Prenotazioni prenotazioni)
        {
            if (id != prenotazioni.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(prenotazioni);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PrenotazioniExists(prenotazioni.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(prenotazioni));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("id,data,ora,idCorso,idUtente")] Prenotazioni prenotazioni)
        {
            if (ModelState.IsValid)
            {
                _context.Add(prenotazioni);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(prenotazioni));
        }
Exemplo n.º 4
0
        private void btnAggiungi_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int client = cmbClienti.SelectedIndex;
                if (client == -1)
                {
                    throw new Exception("Devi selezionare un cliente!");
                }
                Cliente  cliente = Clienti[client];
                DateTime data;
                if (dp_Data.SelectedDate != null)
                {
                    data = dp_Data.SelectedDate.Value;
                }
                else
                {
                    throw new Exception("Devi selezionare una data!");
                }
                string ora;
                if (cmbOrari.SelectedIndex != -1)
                {
                    ora = cmbOrari.Text;
                }
                else
                {
                    throw new Exception("Devi selezionare un orario!");
                }
                Prenotazione p = new Prenotazione(cliente, data, ora);
                cliente.Prenotazioni.Add(p);
                Prenotazioni.Add(p);
                lb1.Items.Add(p.Stampa());

                cmbClienti.SelectedIndex = -1;
                dp_Data.SelectedDate     = null;
                cmbOrari.SelectedIndex   = -1;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }