public ActionResult ContadoresLinUpdate([ModelBinder(typeof(DevExpressEditorsBinder))] ContadoresLotesLinModel item) { var model = Session[session] as List <ContadoresLotesLinModel>; try { if (ModelState.IsValid) { var editItem = model.Single(f => f.Id == item.Id); editItem.Longitud = item.Longitud; editItem.Tiposegmento = item.Tiposegmento; if (item.Tiposegmento == TiposLoteSegmentos.Constante) { item.Valor = item.Valor.ToUpper(); } editItem.Valor = item.Valor; Session[session] = model; } } catch (ValidationException) { throw; } return(PartialView("_contadoreslin", model)); }
public ActionResult ContadoresLinAddNew([ModelBinder(typeof(DevExpressEditorsBinder))] ContadoresLotesLinModel item) { var model = Session[session] as List <ContadoresLotesLinModel>; 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; if (item.Tiposegmento == TiposLoteSegmentos.Constante) { item.Valor = item.Valor.ToUpper(); } model.Add(item); Session[session] = model; } } } catch (ValidationException) { model.Remove(item); throw; } return(PartialView("_Contadoreslin", model)); }