Exemplo n.º 1
0
        public ActionResult Delete(int id, Machine machine)
        {
            try
            {
                MachineModel.DeleteMachine(machine);
                return(RedirectToAction("Index"));
            }
            catch (GrException gex)
            {
                ModelState.AddModelError("", gex.UserMessage);

                // get updated data
                Machine machine_ = MachineModel.getMachine(id);

                // update timestamp in case user really wants to delete this
                ModelState.SetModelValue("Timestamp", new ValueProviderResult(machine_.Timestamp, "", CultureInfo.InvariantCulture));

                // show new values before user decided to really delete them
                return(View(machine_));
            }
        }