コード例 #1
0
        public ActionResult Edit(int id, TitleEdit model)
        {
            if (!ModelState.IsValid)
            {
                var wrestlerList = new WrestlerRepo();
                model.Wrestlers = wrestlerList.GetWrestlers();

                return(View(model));
            }

            if (model.TitleId != id)
            {
                ModelState.AddModelError("", "ID Mismatch");
                return(View(model));
            }

            var service = CreateTitleService();

            if (service.UpdateTitle(model))
            {
                TempData["SaveResult"] = "The title has been updated!";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "The title could not be updated.");
            return(View(model));
        }
コード例 #2
0
        //GET: Create
        public ActionResult Create()
        {
            var model         = new TitleCreate();
            var promotionList = new PromotionRepo();
            var wrestlerList  = new WrestlerRepo();

            model.Promotions = promotionList.GetPromotions();
            model.Wrestlers  = wrestlerList.GetWrestlers();
            return(View(model));
        }
コード例 #3
0
        //GET: Edit
        public ActionResult Edit(int id)
        {
            var service = CreateTitleService();
            var detail  = service.GetTitleById(id);

            var wrestlerList = new WrestlerRepo();
            var model        = new TitleEdit
            {
                TitleId   = detail.TitleId,
                TitleName = detail.TitleName,
                //IsStarred = detail.IsStarred,
                DateEstablished = detail.DateEstablished,
                WrestlerId      = detail.WrestlerId
            };

            model.Wrestlers = wrestlerList.GetWrestlers();

            return(View(model));
        }
コード例 #4
0
        public ActionResult Create(TitleCreate model)
        {
            if (!ModelState.IsValid)
            {
                var promotionList = new PromotionRepo();
                var wrestlerList  = new WrestlerRepo();
                model.Promotions = promotionList.GetPromotions();
                model.Wrestlers  = wrestlerList.GetWrestlers();
                return(View(model));
            }
            var service = CreateTitleService();

            if (service.CreateTitle(model))
            {
                TempData["SaveResult"] = "Your title has been created!";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", "Title could not be created.");

            return(View(model));
        }