protected void ShowResults(List <Intercalado> intercalados, int selectedId) { Monitor1.ClearLayer(LayerEntregas); Monitor1.ClearLayer(LayerRecorrido); lblInstructions.Text = string.Empty; IList <EntregaDistribucion> detalles = null; if (intercalados != null && selectedId > 0) { Intercalado selected = intercalados.FirstOrDefault(i => selectedId == i.Id); var viaje = DAOFactory.ViajeDistribucionDAO.FindById(selectedId); // nueva entrega var nuevoDetalle = new EntregaDistribucion { Viaje = viaje, PuntoEntrega = DAOFactory.PuntoEntregaDAO.FindById(cbPuntoEntrega.Selected) }; nuevoDetalle.Cliente = nuevoDetalle.PuntoEntrega.Cliente; nuevoDetalle.Descripcion = nuevoDetalle.PuntoEntrega.Descripcion; nuevoDetalle.TipoServicio = cbTipoServicio.Selected > 0 ? DAOFactory.TipoServicioCicloDAO.FindById(cbTipoServicio.Selected) : null; // intercalo la nueva entrega en el viaje seleccionado detalles = viaje.Detalles; viaje.InsertarEntrega(selected.Index, nuevoDetalle); if (selected.Index > 0) { viaje.CalcularHorario(selected.Index, selected.ViajeIntercalado); } if (selected.Index < detalles.Count) { viaje.CalcularHorario(selected.Index, selected.ViajeIntercalado); } // muestro todos los viajes en el mapa foreach (var costo in intercalados) { ShowViaje(costo, selectedId); // si el viaje está seleccionado muestro la nueva entrega con el mismo color if (selectedId == costo.Id) { var colorNew = GetColor(costo.Id); var imageUrlNew = GetImageUrl(colorNew, costo.Index + 1, "sq"); AddMarker(nuevoDetalle, imageUrlNew); selected = costo; ShowInstructions(costo); } } Monitor1.SetCenter(nuevoDetalle.ReferenciaGeografica.Latitude, nuevoDetalle.ReferenciaGeografica.Longitude); selectedIndex = selected.Index; } // bindeo los detalles con la nueva entrega intercalada reorderDetalles.DataSource = detalles; reorderDetalles.DataBind(); updResult.Update(); updDetalles.Update(); }