// GET:
        public ActionResult Edit(int id)
        {
            var service = CreateBoroughService();
            var detail  = service.GetBoroughById(id);
            var model   =
                new BoroughEdit
            {
                BoroughId = detail.BoroughId,
                Name      = detail.Name,
                Direction = detail.Direction
            };

            return(View(model));
        }
        public bool UpdateBorough(BoroughEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Boroughs
                    .Single(e => e.BoroughId == model.BoroughId && e.CreatorId == _userId);

                entity.Name      = model.Name;
                entity.Direction = model.Direction;

                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Edit(int id, BoroughEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

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

            var service = CreateBoroughService();

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

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