Exemplo n.º 1
0
 public bool UpdateBadGuy(BadGuyEdit model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var badGuyEntity = ctx.BadGuys
                            .Single(e => e.BadGuyId == model.BadGuyId && _userId == e.UserId);
         badGuyEntity.Name     = model.Name;
         badGuyEntity.Class    = model.Class;
         badGuyEntity.IsBoss   = model.IsBoss;
         badGuyEntity.Level    = model.Level;
         badGuyEntity.PlanetId = model.PlanetId;
         return(ctx.SaveChanges() == 1);
     }
 }
        public ActionResult Edit(int id)
        {
            var service = CreateBadGuyService();
            var detail  = service.GetBadGuyById(id);
            var model   =
                new BadGuyEdit
            {
                BadGuyId  = detail.BadGuyId,
                Name      = detail.Name,
                Level     = detail.Level,
                PlanetId  = detail.PlanetId,
                XpDropped = detail.XpDropped
            };

            return(View(model));
        }
Exemplo n.º 3
0
        public ActionResult Edit(int id)
        {
            var service = CreateBadGuyService();
            var edit    = service.GetBadGuyById(id);
            var model   =
                new BadGuyEdit
            {
                Class  = edit.Class,
                Name   = edit.Name,
                IsBoss = edit.IsBoss,
                Level  = edit.Level,
                Planet = edit.Planet
            };

            return(View(model));
        }
Exemplo n.º 4
0
        public bool UpdateBadGuy(BadGuyEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .BadGuys
                    .Single(e => e.BadGuyId == model.BadGuyId && e.UserId == _ownerId);

                entity.Name      = model.Name;
                entity.Level     = model.Level;
                entity.PlanetId  = model.PlanetId;
                entity.XpDropped = model.XpDropped;

                return(ctx.SaveChanges() == 1);
            }
        }
Exemplo n.º 5
0
        public ActionResult Edit(BadGuyEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = CreateBadGuyService();

            if (service.UpdateBadGuy(model))
            {
                TempData["SaveResult"] = "Your BadGuy was Succesfully Updated";
                service.UpdateBadGuy(model);
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Your BadGuy Was Not Updated");
            return(View(model));
        }
        public ActionResult Edit(int id, BadGuyEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

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

            var service = CreateBadGuyService();

            if (service.UpdateBadGuy(model))
            {
                TempData["SaveResult"] = "Your note was updated.";
                return(RedirectToAction("List"));
            }

            ModelState.AddModelError("", "Your note could not be updated.");
            return(View(model));
        }