示例#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));
        }
示例#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));
        }
示例#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());
        }
示例#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));
        }