Ejemplo n.º 1
0
 public ActionResult Edit([Bind(Include = "Id,MeterReadings,MeasuredAt")] Consumption consumption)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(consumption).State = EntityState.Modified;
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(consumption));
 }
 public ActionResult Edit([Bind(Include = "Id,From,To,PricePerUnit")] ConsumptionRange range)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(range).State = EntityState.Modified;
         _db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(range));
 }
        public ActionResult Edit([Bind(Include = "Id,Since,Until,Kind,ConsumptionRanges")] TariffViewModel tariffViewModel)
        {
            if (ModelState.IsValid)
            {
                var tariff = tariffViewModel.ToTariff(_db);

                foreach (var range in tariff.Ranges)
                {
                    range.Tariff           = tariff;
                    _db.Entry(range).State = EntityState.Modified;
                }
                _db.SaveChanges();

                _db.Entry(tariff).State = EntityState.Modified;
                _db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            return(View(tariffViewModel));
        }