Ejemplo n.º 1
0
        public ActionResult Edit(int id, LawnOwnerEdit model)
        {
            if (!ModelState.IsValid)
            {
                //Populate();

                return(View(model));
            }

            if (model.LocationId != id)
            {
                //Populate();
                ModelState.AddModelError("", "Lawn does not exist");
                return(View(model));
            }

            var service = CreateLawnService();

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

            ModelState.AddModelError("", "Your Lawn could not be updated.");
            return(View());
        }
Ejemplo n.º 2
0
        // Read: LawnOwner/Edit/{id}
        public ActionResult Edit(int id)
        {
            var service = CreateLawnService();
            var detail  = service.GetLawnOwnerById(id);
            var model   =
                new LawnOwnerEdit
            {
                LocationId = detail.LocationId,
                FirstName  = detail.FirstName,
                LastName   = detail.LastName,
                Price      = detail.Price,
                YardWorkId = detail.YardWorkId
            };

            //Populate();
            return(View(model));
        }