Esempio n. 1
0
        public async Task <ActionResult> Index()
        {
            List <OrdenEntrega_dto> modelos = new List <OrdenEntrega_dto>();

            IEnumerable <OrdenEntrega> ordenes;

            ordenes = await ordenesService.obtenerOrdenesEntrega();

            IEnumerable <Itinerario> itinerarios;

            itinerarios = await itinerariosService.obtenerItinerarios();

            IEnumerable <Cliente> clientes;

            clientes = await clientesService.obtenerClientes();

            foreach (var orden in ordenes)
            {
                Itinerario i = new Itinerario();
                i = itinerarios.FirstOrDefault(x => x.Id == orden.ItinerarioId);

                Cliente c = new Cliente();
                c = clientes.FirstOrDefault(x => x.Id == orden.ClienteId);


                var model = new OrdenEntrega_dto();

                model.Id           = orden.Id;
                model.FechaEmision = orden.FecharEmision;
                model.NroFactura   = orden.NroFactura;
                model.Estado       = orden.Estado;
                model.Prioridad    = orden.Prioridad;

                model.ItinerarioId          = i.Id;
                model.ItinerarioDescripcion = i.Descripcion;

                model.ClienteId     = c.Id;
                model.ClienteNombre = c.NombreCompleto;

                modelos.Add(model);
            }
            return(View(modelos));
        }
        public async Task <ActionResult> ReporteMotivosNoEntrega()
        {
            string fechaInicio       = Request.QueryString["i"];
            string fechaFinalizacion = Request.QueryString["f"];



            List <ReporteMotivoNoEntrega> modelos = new List <ReporteMotivoNoEntrega>();

            IEnumerable <OrdenEntrega> ordenes;

            ordenes = await ordenesService.obtenerOrdenesEntrega();

            IEnumerable <Itinerario> itinerarios;

            itinerarios = await itinerariosService.obtenerItinerarios();

            IEnumerable <MarcacionEntrega> marcaciones;

            marcaciones = await marcacionesService.obtenerMarcacionesEntrega();

            IEnumerable <MotivoNoEntrega> motivos;

            motivos = await motivosService.obtenerMotivosNoEntrega();

            foreach (var motivo in motivos)
            {
                ReporteMotivoNoEntrega modelo = new ReporteMotivoNoEntrega();

                //buscar marcacionEntrega Asociada
                MarcacionEntrega me = new MarcacionEntrega();
                me = marcaciones.FirstOrDefault(x => x.Id == motivo.MarcacionEntregaId);

                //buscar ordendeEntrega Asociada
                OrdenEntrega o = new OrdenEntrega();
                o = ordenes.FirstOrDefault(x => x.Id == me.OrdenEntregaId);

                //buscar itinerario Asociada
                Itinerario it = new Itinerario();
                it = itinerarios.FirstOrDefault(x => x.Id == o.ItinerarioId);

                modelo.OrdenEntrega = o.Id;
                modelo.Factura      = o.NroFactura;

                modelo.Itinerario = it.Descripcion;
                modelo.Fecha      = me.Hora;
                modelo.Motivo     = motivo.Descripcion;

                modelos.Add(modelo);
            }


            if (fechaInicio != null && fechaFinalizacion != null)
            {
                DateTime FechaInicio       = DateTime.Parse(fechaInicio);
                DateTime FechaFinalizacion = DateTime.Parse(fechaFinalizacion);

                modelos = modelos.Where(x => x.Fecha >= FechaInicio && x.Fecha <= FechaFinalizacion).ToList();
            }


            #region datos prueba

            //List<ReporteMotivoNoEntrega> datos = new List<ReporteMotivoNoEntrega>();
            //datos.Add(new ReporteMotivoNoEntrega {
            //    OrdenEntrega = 15,                                  //id                    OrdenEntrega
            //    Factura = 6854,                                     //nroFactura            OrdenEntrega
            //    Itinerario = "Itinerario Sirari",                   //descripcion           Itinerario
            //    Fecha = new DateTime(2018, 03, 12, 8, 30, 12),      //hora                  MarcacionEntrega
            //    Motivo = "Cliente en vacaciones"                    //descripcion           MotivoNoEntrega
            //});

            //datos.Add(new ReporteMotivoNoEntrega {
            //    OrdenEntrega = 16,
            //    Factura = 6854,
            //    Itinerario = "Itinerario Urbari",
            //    Fecha = new DateTime(2018,03,15,8,45,12),
            //    Motivo = "Cliente desconoce la visita"
            //});

            //datos.Add(new ReporteMotivoNoEntrega
            //{
            //    OrdenEntrega = 16,
            //    Factura = 6854,
            //    Itinerario = "Itinerario Polanco",
            //    Fecha = new DateTime(2018, 03, 19, 8, 45, 12),
            //    Motivo = "Cliente en Reunion"
            //});

            //datos.Add(new ReporteMotivoNoEntrega
            //{
            //    OrdenEntrega = 17,
            //    Factura = 6854,
            //    Itinerario = "Itinerario La Salle",
            //    Fecha = new DateTime(2018, 03, 24, 8, 45, 12),
            //    Motivo = "Cliente no recibe al personal"
            //});

            //datos.Add(new ReporteMotivoNoEntrega
            //{
            //    OrdenEntrega = 18,
            //    Factura = 6854,
            //    Itinerario = "Itinerario Banzer",
            //    Fecha = new DateTime(2018, 03, 25, 9, 4, 4),
            //    Motivo = "Cliente cambio la fecha"
            //});


            //datos.Add(new ReporteMotivoNoEntrega
            //{
            //    OrdenEntrega = 21,
            //    Factura = 6854,
            //    Itinerario = "Itinerario Alemana",
            //    Fecha = new DateTime(2018, 03, 27, 7, 38, 12),
            //    Motivo = "Cliente cambio de direccion"
            //});

            #endregion



            return(View(modelos));
        }