Exemple #1
0
 public bool BadGuyCreate(BadGuyCreate model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var newBadGuy = new BadGuy()
         {
             Name     = model.Name,
             Level    = model.Level,
             Class    = model.Class,
             PlanetId = model.PlanetId,
             UserId   = _userId
         };
         ctx.BadGuys.Add(newBadGuy);
         return(ctx.SaveChanges() == 1);
     }
 }
Exemple #2
0
        public bool BadGuyCreate(BadGuyCreate model)
        {
            var newBadGuy = new BadGuy()
            {
                Name      = model.Name,
                Level     = model.Level,
                XpDropped = model.XpDropped,
                PlanetId  = model.PlanetId,
                UserId    = _ownerId
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.BadGuys.Add(newBadGuy);
                return(ctx.SaveChanges() == 1);
            }
        }
Exemple #3
0
        public ActionResult Create(BadGuyCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateBadGuyService();

            if (service.BadGuyCreate(model))
            {
                TempData["SaveResult"] = "Your BadGuy was Succesfully Created";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Your BadGuy could not be " +
                                     "Created");

            return(View(model));
        }
        public ActionResult Create(BadGuyCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateBadGuyService();

            if (service.BadGuyCreate(model))
            {
                TempData["SaveResult"] = "Your Bad Guy was created.";
                return(RedirectToAction("List"));
            }
            ;

            ModelState.AddModelError("", "Your Bad Guy could not be created.");

            return(View(model));
        }