public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Verlag verlag)
        {
            if (id != verlag.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(verlag);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VerlagExists(verlag.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(verlag));
        }
Beispiel #2
0
        protected void Update_Click(object sender, EventArgs e)
        {
            Guid    id             = new Guid(((Button)sender).CommandArgument);
            Verlag  verlag         = _context.Verlag.FirstOrDefault(x => x.ID == id);
            Panel   panel          = (Panel)((Button)sender).Parent;
            TextBox txtNameEdit    = (TextBox)panel.FindControl("txtEditName");
            TextBox txtEditStrasse = (TextBox)panel.FindControl("txtEditStrasse");
            TextBox txtEditPLZ     = (TextBox)panel.FindControl("txtEditPLZ");
            TextBox txtEditOrt     = (TextBox)panel.FindControl("txtEditOrt");

            int plz;

            if (int.TryParse(txtEditPLZ.Text, out plz))
            {
                verlag.Name    = txtNameEdit.Text;
                verlag.Strasse = txtEditStrasse.Text;
                verlag.PLZ     = plz;
                verlag.Ort     = txtEditOrt.Text;

                _context.Entry(verlag).State = EntityState.Modified;
                _context.SaveChanges();

                lstVerlaege.EditIndex = -1;
                BindListView();
            }
        }
Beispiel #3
0
 public Buch(string Autor, string Titel, int Jahr, string ISBNNummer, Verlag Verlag, int Preis)
 {
     this.Autor      = Autor;
     this.Titel      = Titel;
     this.Jahr       = Jahr;
     this.ISBNNummer = ISBNNummer;
     this.Verlag     = Verlag;
     this.Preis      = Preis;
 }
        public async Task <IActionResult> Create([Bind("Id,Name")] Verlag verlag)
        {
            if (ModelState.IsValid)
            {
                _context.Add(verlag);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(verlag));
        }
Beispiel #5
0
        protected void Delete_Clicked(object sender, EventArgs e)
        {
            Guid   id         = new Guid(((Button)sender).CommandArgument);
            Verlag verlag     = _context.Verlag.FirstOrDefault(x => x.ID == id);
            var    spieleList = _context.Spiel.Where(x => x.FK_Verlag_ID == verlag.ID).ToList();

            if (spieleList.Count == 0)
            {
                _context.Verlag.Remove(verlag);
                _context.SaveChanges();

                BindListView();
            }
        }
Beispiel #6
0
        protected void Hinzufügen_Click(object sender, EventArgs e)
        {
            int plz;

            if (int.TryParse(txtPlz.Text, out plz))
            {
                Verlag verlag = new Verlag()
                {
                    ID      = Guid.NewGuid(),
                    Name    = txtName.Text,
                    Strasse = txtStrasse.Text,
                    PLZ     = plz,
                    Ort     = txtOrt.Text
                };

                _context.Verlag.Add(verlag);
                _context.SaveChanges();
                BindListView();
            }
        }