public ActionResult ContadoresLinAddNew([ModelBinder(typeof(DevExpressEditorsBinder))] ContadoresLinModel item) { var model = Session[session] as List <ContadoresLinModel>; try { if (ModelState.IsValid) { if (model.Any(f => f.Id == item.Id)) { ModelState.AddModelError("Id", string.Format(General.ErrorRegistroExistente)); } else { var max = model.Any() ? model.Max(f => f.Id) + 1:1; item.Id = max; model.Add(item); Session[session] = model; } } } catch (ValidationException) { model.Remove(item); throw; } return(PartialView("_Contadoreslin", model)); }
public ActionResult ContadoresLinUpdate([ModelBinder(typeof(DevExpressEditorsBinder))] ContadoresLinModel item) { var model = Session[session] as List <ContadoresLinModel>; try { if (ModelState.IsValid) { var editItem = model.Single(f => f.Id == item.Id); editItem.Longitud = item.Longitud; editItem.Tiposegmento = item.Tiposegmento; editItem.Valor = item.Valor; Session[session] = model; } } catch (ValidationException) { throw; } return(PartialView("_contadoreslin", model)); }