public ActionResult Details(int id, GameTypeVariant model)
        {
            var variant = GameTypeService.GetVariant(id);
            variant.Title = model.Title;
            variant.ShortDescription = model.ShortDescription;
            variant.Description = model.Description;
            variant.IsStaffPick = model.IsStaffPick;
            if (ModelState.IsValid)
            {
                string path = System.IO.Path.Combine(Server.MapPath("~/Content/Files/GameType/"), variant.File.FileName);
                using (FileStream stream = System.IO.File.Open(path, FileMode.Open))
                {
                    VariantLib.GameVariant game = new VariantLib.GameVariant(stream);

                    game.VariantDescription = variant.ShortDescription;
                    game.VariantName = variant.Title;
                    game.Save();
                }

                GameTypeService.Save();

                this.SetAlert(string.Format("The variant '{0}' has been updated.", variant.Title), AlertType.Success);
                return RedirectToAction("Index");
            }
            return View(variant);
        }
        public ActionResult Delete(int id, GameTypeVariant model)
        {
            var variant = GameTypeService.GetVariant(id);
            variant.IsDeleted = !variant.IsDeleted;
            GameTypeService.Save();

            this.SetAlert(string.Format("The variant '{0}' has been deleted.", variant.Title), AlertType.Success);
            return RedirectToAction("Index");
        }
Esempio n. 3
0
        public ActionResult Delete(int id, GameTypeVariant model)
        {
            var variant = GameTypeService.GetVariant(id);

            if (!(variant.AuthorId == User.Identity.GetUserId<int>() || User.IsInRole("Mod")))
                return new HttpUnauthorizedResult();

            variant.IsDeleted = true;
            GameTypeService.Save();

            SetAlert(string.Format("The game variant {0} is deleted.", variant.Title), AlertType.Success);
            return RedirectToAction("Index");
        }