Ejemplo n.º 1
0
        public IHttpActionResult GetAll()
        {
            IEnumerable <ReferenciaDto>   referencias = _serviceReferencia.GetAll();
            IEnumerable <ReferenciaModel> calzadasVM  = MapDtoToViewModel.Map(referencias);
            Result result = new Result(calzadasVM);

            return(result.CreateResponse(this));
        }
        public IEnumerable <ReferenciaDto> GetAll()
        {
            string cacheKey = string.Format("ServiceReferencia@GetAll");

            return(SimpleCache.GetCache(cacheKey, () =>
            {
                return _service.GetAll();
            }));
        }
        private void NormalizeInfoVM(IEnumerable <TramoDto> tramos, IEnumerable <TramoModel> tramosVM)
        {
            IList <TramoModel> result = new List <TramoModel>();

            IEnumerable <ProvinciaDto>  provincias  = _serviceProvincia.GetAll(false);
            IEnumerable <RutaDto>       rutas       = _serviceRuta.GetAll(false);
            IEnumerable <CalzadaDto>    calzadas    = _serviceCalzada.GetAll(false);
            IEnumerable <ReferenciaDto> referencias = _serviceReferencia.GetAll();

            foreach (var itemTramoVM in tramosVM)
            {
                TramoDto tramoDto = tramos.SingleOrDefault(x => x.IdTramo == itemTramoVM.IdTramo);
                if (tramoDto == null)
                {
                    continue;
                }

                itemTramoVM.Provincia   = provincias.SingleOrDefault(x => x.Id == itemTramoVM.IdProvincia)?.Nombre;
                itemTramoVM.Ruta        = rutas.SingleOrDefault(x => x.Id == itemTramoVM.IdRuta)?.Nombre;
                itemTramoVM.Calzada     = calzadas.SingleOrDefault(x => x.Id == itemTramoVM.IdCalzada)?.Nombre;
                itemTramoVM.Referencias = tramoDto.GetListReferencias(referencias);
            }
        }