Пример #1
0
        public ActionResult Edit(int id, HookEdit model)
        {
            return(View());

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

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

            var service = CreateHookService();

            if (service.UpdateHook(model))
            {
                TempData["SaveResult"] = "Your hook was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your hook could not be updated.");
            return(View(model));
        }
Пример #2
0
        public ActionResult Edit(int id)
        {
            var service = CreateHookService();
            var detail  = service.GetHookById(id);
            var model   =
                new HookEdit
            {
                // HookId = detail.HookId,
                NumberSize = detail.NumberSize,
                LetterSize = detail.LetterSize,
                Material   = detail.Material,
            };

            return(View(model));
        }
Пример #3
0
        public bool UpdateHook(HookEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Hooks
                    .Single(e => e.HookId == model.HookId && e.UserId == _userId);

                entity.HookId     = model.HookId;
                entity.NumberSize = model.NumberSize;
                entity.LetterSize = model.LetterSize;
                entity.Material   = model.Material;

                return(ctx.SaveChanges() == 1);
            }
        }