Beispiel #1
0
        [HttpPost] //aby nikdo nemohl to udělat přes url
        public ActionResult delete(String _id, int?_page, int?_itemsOnPage, bool?vse)
        {
            int     id      = int.Parse(_id);
            GameDao gameDao = new GameDao();
            Hra     hra     = gameDao.GetById(id);

            if (hra.Ikona != null)
            {
                try
                {
                    System.IO.File.SetAttributes(Server.MapPath("~/uploads/hry/" + hra.Ikona), FileAttributes.Normal);
                    System.IO.File.Delete(Server.MapPath("~/uploads/hry/" + hra.Ikona));
                }
                catch (Exception e)
                {
                }
            }

            PlatformaDao platformaDao = new PlatformaDao();

            VydavatelDao vydavateleDao = new VydavatelDao();

            TempData["message-success"] = "Hra " + hra.Nazev + "byla upravena.";
            Vydavatel vydavatel = hra.Vydavatel;
            Platforma platforma = hra.Platforma;

            platforma.Pocet--;
            vydavatel.Pocet--;
            platformaDao.Update(platforma);
            vydavateleDao.Update(vydavatel);
            gameDao.Delete(hra);
            return(RedirectToAction("Hra"));
        }
Beispiel #2
0
        public ActionResult Delete(int id)
        {
            try
            {
                GameDao gameDao = new GameDao();
                Game    game    = gameDao.GetById(id);


                gameDao.Delete(game);

                TempData["message-success"] = "Hra " + game.Name + " byla smazána";
            }
            catch (Exception exception)
            {
                throw;
            }

            return(RedirectToAction("Index"));
        }