public ActionResult SearchCriteria(SearchClassLabel data) { using (MobileWarehouseEntities db = new MobileWarehouseEntities()) { IQueryable<RisorseLocalizzazioneLabel> x = null; if (data.idModulo.HasValue) { x = db.RisorseLocalizzazioneLabel.Where(l => l.idModulo == data.idModulo); } else { x = db.RisorseLocalizzazioneLabel; } if (data.labelFor != null) { x = x.Where(l => l.labelFor == data.labelFor); } if (data.lingua != null) { x = x.Where(p => p.lingua == data.lingua); } if (data.label != null) { x = x.Where(p => p.label == data.label); } data.ResultList = x.ToList(); } return View("SearchCriteria",data); }
public ActionResult DoUpdate(SearchClassLabel data) { RisorseLocalizzazioneLabel d = null; using (MobileWarehouseEntities db = new MobileWarehouseEntities()) { d = db.RisorseLocalizzazioneLabel.Where(l => l.idModulo == data.idModulo && l.labelFor == data.labelFor && l.lingua == data.lingua).FirstOrDefault(); if(d != null) { d.label = data.label; } else { d = new RisorseLocalizzazioneLabel(); d.idModulo = data.idModulo.Value; d.labelFor = data.labelFor; d.lingua = data.lingua; d.label = data.label; db.RisorseLocalizzazioneLabel.Add(d); } db.SaveChanges(); } return SearchCriteria(new SearchClassLabel()); }