Example #1
0
 public IActionResult Delete(int id)
 {
     using (var db = new ConcertDBContext())
     {
         Band bandToDelete = db.Concerts.FirstOrDefault(x => x.Id == id);
         return(View(bandToDelete));
     }
 }
Example #2
0
 public IActionResult Index()
 {
     using (var db = new ConcertDBContext())
     {
         var allBands = db.Concerts.ToList();
         return(View(allBands));
     }
 }
Example #3
0
 public IActionResult Delete(Band band)
 {
     using (var db = new ConcertDBContext())
     {
         Band deletedBand = db.Concerts.FirstOrDefault(x => x.Id == band.Id);
         db.Remove(deletedBand);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
Example #4
0
        public IActionResult Create(Band band)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Index"));
            }

            using (var db = new ConcertDBContext())
            {
                db.Concerts.Add(band);
                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Example #5
0
        public IActionResult Edit(Band band)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Index"));
            }

            using (var db = new ConcertDBContext())
            {
                Band editedBand = db.Concerts.FirstOrDefault(x => x.Id == band.Id);
                editedBand.Genre      = band.Genre;
                editedBand.Honorarium = band.Honorarium;
                editedBand.Members    = band.Members;
                editedBand.Name       = band.Name;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
        }