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

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pille);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PilleExists(pille.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(pille));
        }
Beispiel #2
0
        public async Task <ActionResult <Pille> > PostPille(Pille pille)
        {
            _context.Pille.Add(pille);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPille", new { id = pille.Id }, pille));
        }
Beispiel #3
0
        public async Task <IActionResult> PutPille(int id, Pille pille)
        {
            if (id != pille.Id)
            {
                return(BadRequest());
            }

            _context.Entry(pille).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PilleExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #4
0
        public async Task <IActionResult> Create([Bind("Id,Name,Gewicht")] Pille pille)
        {
            if (ModelState.IsValid)
            {
                _context.Add(pille);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(pille));
        }