Ejemplo n.º 1
0
        public IActionResult Edit(int id, PictureViewModel viewModel)
        {
            _context.Pictures
                .Single(p => p.Id == id)
                .Caption = viewModel.Caption;
            _context.SaveChanges();

            return RedirectToAction("Edit");
        }
Ejemplo n.º 2
0
        public IActionResult Delete(PictureViewModel viewModel)
        {
            var picture = _context.Pictures
                .Single(p => p.Id == viewModel.PictureId);
            _context.Pictures.Remove(picture);

            System.IO.File.Delete(_storage.GetPicturePath(picture.Filename));
            _context.SaveChanges();

            return RedirectToAction("Index");
        }