Esempio n. 1
0
        public bool CreateWheels(WheelsCreate model)
        {
            var entity =
                new Wheels()
            {
                OwnerID      = _userID,
                WheelsName   = model.WheelsName,
                WheelsColor  = model.WheelsColor,
                WheelsRarity = model.WheelsRarity
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Wheelss.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Create(WheelsCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateWheelsService();

            if (service.CreateWheels(model))
            {
                TempData["SaveResult"] = "Your wheels were created.";
                return(RedirectToAction("Index"));
            }
            ;

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

            return(View(model));
        }