示例#1
0
 public bool UpdateAdventurer(AdventurerEdit model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var adventurerEntity = ctx.Adventurers
                                .Single(e => e.AdventurerId == model.AdventurerId && _userId == e.OwnerId);
         adventurerEntity.Name = model.Name;
         return(ctx.SaveChanges() == 1);
     }
 }
示例#2
0
        public ActionResult Edit(int id)
        {
            var service = CreateAdventurerService();
            var edit    = service.GetAdventurerById(id);
            var model   =
                new AdventurerEdit
            {
                Name = edit.Name,
            };

            return(View(model));
        }
        public ActionResult Edit(int id)
        {
            var service = CreateAdventurerService();
            var detail  = service.GetAdventurerById(id);
            var model   =
                new AdventurerEdit
            {
                AdventurerId = detail.AdventurerId,
                Name         = detail.Name,
            };

            return(View(model));
        }
示例#4
0
        public ActionResult Edit(AdventurerEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = CreateAdventurerService();

            if (service.UpdateAdventurer(model))
            {
                TempData["SaveResult"] = "Your Adventurer was Succesfully Updated";
                service.UpdateAdventurer(model);
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Your Adventurer Was Not Updated");
            return(View(model));
        }