Ejemplo n.º 1
0
        //Create Cricketer
        public bool CreateCricketer(CricketerCreate model)
        {
            var entity =
                new Cricketer()
            {
                UserId    = _userId,
                Name      = model.Name,
                Country   = model.Country,
                TotalRuns = model.TotalRuns
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Cricketerss.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 2
0
        public ActionResult Create(CricketerCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = CreateCricketService();

            if (service.CreateCricketer(model))
            {
                TempData["SaveResult"] = "Your Cricketer was created.";
                return(RedirectToAction("Index"));
            }
            ;
            ModelState.AddModelError("", "Cricketer could not be created.");

            return(View(model));
        }