Ejemplo n.º 1
0
        public ActionResult Edit(int id)
        {
            using (var db = new ApplicationDbContext())
            {
                var address = db.Properties.FirstOrDefault(x => x.Id == id);

                if (address == null)
                {
                    return(HttpNotFound());
                }

                var model = new MeterEditModel
                {
                    Id      = address.Id,
                    Address = address.Address
                };

                return(View(model));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Edit(int id, MeterEditModel model)
        {
            if (ModelState.IsValid)
            {
                using (var db = new ApplicationDbContext())
                {
                    var meter = db.Properties.FirstOrDefault(x => x.Id == model.Id);

                    if (meter == null)
                    {
                        return(HttpNotFound());
                    }

                    meter.Address = model.Address;

                    db.SaveChanges();
                }

                return(RedirectToAction(nameof(List)));
            }

            return(View());
        }