Ejemplo n.º 1
0
        // GET: Create
        public ActionResult Create()
        {
            var model         = new WrestlerCreate();
            var promotionList = new PromotionRepo();

            model.Promotions = promotionList.GetPromotions();
            return(View(model));
        }
Ejemplo n.º 2
0
        public bool CreateWrestler(WrestlerCreate model)
        {
            var entity = new Wrestler()
            {
                OwnerId     = _userId,
                RingName    = model.RingName,
                Gender      = model.Gender,
                DateOfBirth = model.DateOfBirth,
                Nationality = model.Nationality,
                PromotionId = model.PromotionId,
                Wins        = model.Wins,
                Losses      = model.Losses,
                CreatedUtc  = DateTimeOffset.Now
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Wrestlers.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 3
0
        public ActionResult Create(WrestlerCreate model)
        {
            if (!ModelState.IsValid)
            {
                var promotionList = new PromotionRepo();
                model.Promotions = promotionList.GetPromotions();

                return(View(model));
            }
            var service = CreateWrestlerService();

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



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

            return(View(model));
        }