Beispiel #1
0
        public ActionResult GetNextLevel(int id)
        {
            var      thisLevel     = DataBase.GeopoliticalStructures.Get(p => p.GeopoliticalStructureId == id).FirstOrDefault();
            var      nextLevel     = DataBase.GeopoliticalStructures.Get(p => p.ParentGeopoliticalStructureId == id).ToSelectList(null, "GeopoliticalStructureId", "Name", false);
            var      nextLevelType = DataBase.GeopoliticalStructures.Get(p => p.ParentGeopoliticalStructureId == id, includeProperties: "GeopoliticalStructureType").FirstOrDefault();
            ZonaView zonaView      = new ZonaView();

            zonaView.TypeId     = nextLevelType.GeopoliticalStructureType.LevelStructure;
            zonaView.lista      = nextLevel;
            zonaView.ParentName = thisLevel.DescriptionName;
            zonaView.Id         = thisLevel.GeopoliticalStructureId;
            int firstId = int.Parse(nextLevel.FirstOrDefault().Value);

            if (DataBase.GeopoliticalStructures.Get(p => p.ParentGeopoliticalStructureId == firstId).ToList().Count == 0)
            {
                zonaView.EsUltimo = true;
            }
            else
            {
                zonaView.EsUltimo = false;
            }
            zonaView.label = nextLevelType.GeopoliticalStructureType.Name;
            var jsonLevels = Json(zonaView);

            return(jsonLevels);
        }
Beispiel #2
0
        public ActionResult Detail(int id)
        {
            InicializarEdit();
            zonaModel          = new ZonaModel();
            zonaModel.Children = new List <ZonaGroup>();
            var zona = GetModel(id);

            zonaModel.Estado       = zona.Estado;
            zonaModel.Name         = zona.Descripcion;
            zonaModel.Id           = zona.IdZona;
            zonaModel.IdRegion     = zona.IdRegion;
            zonaModel.Movilizacion = zona.TiempoMovilizacion + "";

            zonaModel.Tipo             = zona.Tipo;
            zonaModel.TipoGeneralValue = zona.TipoGeneralValue;

            zonaModel.ZonaGeocercas        = zona.ZonaGeocercas;
            zonaModel.ZonaClienteGeocercas = zona.ZonaClienteGeocercas;
            zonaModel.ZonaOther            = DataBase.Zonas.Get(p => p.IdZona != id && p.Estado != Models.Constantes.Estado.Eliminado && p.Tipo == Models.Constantes.TipoZona.Geocerca, includeProperties: "ZonaClienteGeocercas").ToList();

            List <ZonaView> listZonaView = new List <ZonaView>();

            zonaModel.ubicacion                = new Ubicacion();
            zonaModel.ubicacion.Latitud        = zona.LatitudPuntoPartida == null ? 0 : zona.LatitudPuntoPartida;
            zonaModel.ubicacion.Longitud       = zona.LongitudPuntoPartida == null ? 0 : zona.LongitudPuntoPartida;
            zonaModel.ubicacion.Titulo         = "Punto de Partida";
            zonaModel.EstadoGeneralValue       = zona.EstadoGeneralValue;
            zonaModel.Region                   = zona.Region;
            zonaModel.MovilizacionGeneralValue = DataBase.GeneralValues.Get(p => p.Id == Rp3.AgendaComercial.Models.Constantes.Duracion.Tabla && p.Code == zona.TiempoMovilizacion + "").FirstOrDefault();

            var parents = zona.ZonaDetalles.Where(p => p.GeopoliticalStructure.ParentGeopoliticalStructureId.HasValue)
                          .Select(p => p.GeopoliticalStructure.ParentGeopoliticalStructureId.Value).Distinct().ToArray();

            var detalles = zona.ZonaDetalles.Select(p => p.IdGeopoliticalStructure).ToArray();

            string idsParents = "";

            foreach (var parentId in parents)
            {
                ZonaView setter = new ZonaView();
                var      parent = DataBase.GeopoliticalStructures.Get(p => p.GeopoliticalStructureId == parentId).FirstOrDefault();
                setter.Id         = parentId;
                idsParents        = idsParents + parentId + ",";
                setter.label      = parent.DescriptionName;
                setter.ParentName = parent.DescriptionName;
                setter.lista      = DataBase.GeopoliticalStructures.Get(p => p.ParentGeopoliticalStructureId == parentId).
                                    ToMultiSelectList(detalles, "GeopoliticalStructureId", "Name");
                listZonaView.Add(setter);
            }
            ViewBag.ChosenZones = listZonaView;
            ViewBag.Parents     = idsParents;
            ViewBag.ReadOnly    = true;

            return(View(zonaModel));
        }