public string UpdateQuickCount(TotalizacionContact contacto, CandidatoValueIncoming[] valores) { var db = new edayRoomEntities(); var user = db.users.Single(u => u.username == User.Identity.Name); QuickCountTimeline oldTimeline = (from pt in db.QuickCountTimelines where pt.id == contacto.TotalizacionTimelineId select pt).Single(); oldTimeline.activa = false; db.SaveChanges(); IQueryable <Totalizacion> totalizaciones = db.Totalizacions.Where(t => t.id_mesa == contacto.MesaId); foreach (CandidatoValueIncoming v in valores) { int idCandidato = int.Parse(v.name.Replace("candidato-", "")); Totalizacion totalizacion = totalizaciones.SingleOrDefault(t => t.id_candidato == idCandidato); if (totalizacion == null) { totalizacion = new Totalizacion { id_candidato = idCandidato, id_mesa = contacto.MesaId, valor = v.value, id_user = user.id }; db.Totalizacions.AddObject(totalizacion); } totalizacion.QuickCountTimelines.Add(oldTimeline); } var centro = db.Centroes.Single(c => c.id == contacto.CentroId); centro.totalizado = true; IQueryable <QuickCountAlerta> alertas = from a in db.QuickCountAlertas where a.activa && !a.Alerta.blocking && a.id_centro == contacto.CentroId select a; foreach (QuickCountAlerta a in alertas) { a.activa = false; } //contacto.CentroId db.SaveChanges(); MatrizDeSustitucion.UpdateMatriz(contacto.CentroId); return(new JavaScriptSerializer().Serialize("")); }
public string UpdateSingleQuickCount(int totalizacionId, int value) { var db = new edayRoomEntities(); Totalizacion totalizacion = (from t in db.Totalizacions where t.ID == totalizacionId select t).Single(); totalizacion.valor = value; db.SaveChanges(); MatrizDeSustitucion.UpdateMatriz(totalizacion.Mesa.Centro.id); return(new JavaScriptSerializer().Serialize("")); }