Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome")] Gruppo gruppo)
        {
            if (id != gruppo.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(gruppo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GruppoExists(gruppo.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(gruppo));
        }
Beispiel #2
0
        public AggiungiForm(bool edit, Gruppo g2 = null)
        {
            _edit = edit;
            g     = g2;

            InitializeComponent();
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Gruppo gruppo = db.Gruppi.Find(id);

            db.Gruppi.Remove(gruppo);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit(Gruppo gruppo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(gruppo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(gruppo));
 }
Beispiel #5
0
        public async Task <IActionResult> Create([Bind("Id,Nome")] Gruppo gruppo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(gruppo);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(gruppo));
        }
        // GET: Gruppi/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Gruppo gruppo = db.Gruppi.Find(id);

            if (gruppo == null)
            {
                return(HttpNotFound());
            }
            return(View(gruppo));
        }
        public ActionResult Create(Gruppo gruppo)
        {
            if (ModelState.IsValid)
            {
                db.Gruppi.Add(gruppo);
                db.SaveChanges();
                //var elenco = db.Gruppi.ToList();
                //return View("Index", elenco);
                TempData["Messaggio"] = "Creato gruppo " + gruppo.Id;
                return(RedirectToAction("Index"));
            }

            return(View(gruppo));
        }
        public async Task <IActionResult> Create(int gruppoID, List <CreateViewModel> model)
        {
            if (ModelState.IsValid)
            {
                Gruppo gruppo = await _context.Gruppi.FindAsync(gruppoID);

                foreach (var utente in model)
                {
                    if (utente.Selezionato)
                    {
                        await _context.AddAsync(new Assegnazione { Gruppo = gruppo, Utente = await _context.Users.FindAsync(utente.ID) });
                    }
                    else
                    {
                        _context.Assegnazioni.Remove(await _context.Assegnazioni.SingleOrDefaultAsync(a => a.GruppoId == gruppoID && a.UtenteId == utente.ID));
                    }
                }
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
Beispiel #9
0
        private void Button1_Click(object sender, EventArgs e)
        {
            if (t_classe.Text.Length <= 0 || t_degree.Text.Length <= 0 ||
                t_lang.Text.Length <= 0 || t_office.Text.Length <= 0 || t_platform.Text.Length <= 0 ||
                t_school.Text.Length <= 0 || t_type.Text.Length <= 0 || t_year.Text.Length <= 0)
            {
                MessageBox.Show("Non hai compilato qualche campo!");
                return;
            }

            if (t_year.Text == "-")
            {
                t_year.Text = "";
            }

            if (t_degree.Text == "-")
            {
                t_degree.Text = "";
            }

            if (t_school.Text == "-")
            {
                t_school.Text = "";
            }

            if (t_office.Text == "-")
            {
                t_office.Text = "";
            }

            g = new Gruppo
            {
                Classe          = t_classe.Text,
                Degree          = t_degree.Text,
                Id              = t_id.Text,
                Language        = t_lang.Text,
                Office          = new ListaStringhePerJSON(t_office.Text),
                Platform        = t_platform.Text,
                School          = t_school.Text,
                Tipo            = t_type.Text,
                Year            = t_year.Text,
                IdLink          = t_idlink.Text,
                AnnoCorsoStudio = ToInt(t_annocorso.Text),
                CCS             = new ListaStringhePerJSON(t_ccs.Text),
                IDCorsoPolimi   = t_idcorsopolimi.Text,
                PianoDiStudi    = t_pianostudi.Text,
                PermanentId     = textBox_permanent_id.Text
            };

            if (Variabili.L == null)
            {
                Variabili.L = new ListaGruppo();
            }

            g.Aggiusta(true, true);

            if (_edit == false) //new
            {
                Variabili.L.Add(g, true);
            }
            else
            {
                Close();
            }
        }