예제 #1
0
        public ActionResult Edit(int id, WrestlerEdit model)
        {
            if (!ModelState.IsValid)
            {
                var promotionList = new PromotionRepo();
                model.Promotions = promotionList.GetPromotions();

                return(View(model));
            }

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

            var service = CreateWrestlerService();

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

            ModelState.AddModelError("", "The wrestler could not be updated.");
            return(View(model));
        }
예제 #2
0
        // GET: Create
        public ActionResult Create()
        {
            var model         = new WrestlerCreate();
            var promotionList = new PromotionRepo();

            model.Promotions = promotionList.GetPromotions();
            return(View(model));
        }
예제 #3
0
        //GET: Edit
        //Possible error on Promo ID
        public ActionResult Edit(int id)
        {
            var service = CreateWrestlerService();
            var detail  = service.GetWrestlerById(id);

            var promotionList = new PromotionRepo();
            var model         = new WrestlerEdit
            {
                WrestlerId  = detail.WrestlerId,
                RingName    = detail.RingName,
                Gender      = detail.Gender,
                PromotionId = detail.PromotionId,
                Wins        = detail.Wins,
                Losses      = detail.Losses,
            };

            model.Promotions = promotionList.GetPromotions();

            return(View(model));
        }
        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));
        }