// GET: Eier/Delete/5
        public async Task <IActionResult> DeleteEier(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Eier eier = await _context.Eiere
                        .SingleOrDefaultAsync(m => m.Id == id);

            if (eier == null)
            {
                return(NotFound());
            }

            EierViewModel model = new EierViewModel
            {
                StatusMessage = StatusMessage,
                Navn          = eier.Navn,
                Id            = eier.Id
            };


            return(View(model));
        }
        public async Task <IActionResult> DeleteEierConfirmed(int id)
        {
            Eier slettEier = await _context.Eiere.SingleOrDefaultAsync(m => m.Id == id);

            _context.Eiere.Remove(slettEier);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Eier)));
        }
        public async Task <IActionResult> Eier(EierViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            Eier eier = new Eier
            {
                Navn   = model.Navn,
                UserId = model.UserId
            };

            await _context.Eiere.AddAsync(eier);

            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Eier)));
        }
示例#4
0
文件: Produkte.cs 项目: eier/sbc
 public override string ToString()
 {
     return(string.Format("Nest {0} mit ({1}) und {2}", Id, Eier.ToDetailedString(), SchokoHase));
 }