예제 #1
0
 public string consultarEstado(string codigo, string email)
 {
     try
     {
         BLCliente _blC = new BLCliente();
         SCliente  c    = _blC.getClienteByEmail(email);
         SPaquete  p    = _dal.consultaEstado(c.Id, codigo);
         if (p.FechaEntrega == p.FechaIngreso)
         {
             return("El paquete se encuentra en viaje actualmente, para mas detalles: " + Direcciones.Web + "paquete/details/" + p.Id);
         }
         return("El paquete ya fue entregado, para mas detalles: " + Direcciones.Web + "paquete/details/" + p.Id);
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #2
0
 public bool updateEnvioDomicilio(SDomicilio d, string email)
 {
     try
     {
         SPaquete  p    = getPaquete(d.IdPaquete);
         BLCliente _blC = new BLCliente();
         SCliente  c    = _blC.getCliente((int)p.IdDestinatario);
         if (c.Email == email)
         {
             return(_dal.updateEnvioDomicilio(d));
         }
         throw new ECompartida("No tienes permisos para realizar esta accion");
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #3
0
 public List <SPaquete> paquetesRecibidos(string email) // el email es del que realizo la peticion
 {
     try
     {
         BLCliente bl = new BLCliente();
         SCliente  c  = bl.getClienteByEmail(email);
         if (c.Email != null)
         {
             BLPaquete blp = new BLPaquete();
             return(blp.paquetesRecibidos(c.Id));
         }
         throw new ECompartida("No tienes permisos suficientes para realizar esta accion");
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #4
0
 public dynamic detallesPaquete(string email, string role, int idPaquete)
 {
     try
     {
         SPaquete  paquete   = this.getPaquete(idPaquete);
         BLCliente blCliente = new BLCliente();
         if (role != "Admin")
         {
             SCliente cliente = blCliente.getClienteByEmail(email);
             if (cliente != null)
             {
                 if (cliente.Id != paquete.IdDestinatario && cliente.Id != paquete.IdRemitente)
                 {
                     throw new ECompartida("No tienes acceso a la informacion de este paquete");
                 }
             }
             else
             {
                 throw new ECompartida("El email enviado en la solicitud no pertenece a un cliente del sistema");
             }
         }
         SCliente       Remitente      = blCliente.getCliente((int)paquete.IdRemitente);
         SCliente       Destinatario   = blCliente.getCliente((int)paquete.IdDestinatario);
         BLTrayecto     bLTrayecto     = new BLTrayecto();
         STrayecto      Trayecto       = bLTrayecto.getTrayecto((int)paquete.IdTrayecto);
         BLPuntoControl bLPuntoControl = new BLPuntoControl();
         Trayecto.ListaPuntosControl = bLPuntoControl.puntosControlDeUnTrayecto((int)paquete.IdTrayecto);
         BLPaquetePuntoControl       bLPaquetePuntoControl = new BLPaquetePuntoControl();
         List <SPaquetePuntoControl> PaquetePuntosControl  = bLPaquetePuntoControl.puntosControlDeUnPaquete((int)paquete.Id);
         dynamic respuesta = new ExpandoObject();
         respuesta.IdTrayecto          = paquete.Id;
         respuesta.Qr                  = paquete.Codigo;
         respuesta.Trayecto            = Trayecto;
         respuesta.Remitente           = Remitente;
         respuesta.Destinatario        = Destinatario;
         respuesta.PaquetePuntoControl = PaquetePuntosControl;
         return(respuesta);
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #5
0
 public List <SPaquete> filtro(PaqueteFiltroDTO filtro)
 {
     try
     {
         List <SPaquete> todos      = _dal.getAll();
         bool            cambio     = false;
         List <SPaquete> temporal   = new List <SPaquete>();
         List <SPaquete> respuesta  = new List <SPaquete>();
         BLCliente       _blCliente = new BLCliente();
         if (filtro.FechaFinal != null && filtro.FechaInicio != null)
         {
             todos.Where(x => ((x.FechaIngreso >= filtro.FechaInicio) && (x.FechaIngreso <= filtro.FechaFinal)) || ((x.FechaEntrega >= filtro.FechaInicio) && (x.FechaEntrega <= filtro.FechaFinal))).ToList().ForEach(x => {
                 respuesta.Add(x);
             });
             todos     = respuesta;
             respuesta = new List <SPaquete>();
             cambio    = true;
         }
         if (filtro.Remitente != null)
         {
             todos.Where(x => x.IdRemitente == _blCliente.getClienteByEmail(filtro.Remitente).Id).ToList().ForEach(x =>
             {
                 if (respuesta.FirstOrDefault(z => z.Id == x.Id) == null)
                 {
                     respuesta.Add(x);
                 }
             });
             todos     = respuesta;
             respuesta = new List <SPaquete>();
             cambio    = true;
         }
         if (filtro.Destinatario != null)
         {
             todos.Where(x => x.IdDestinatario == _blCliente.getClienteByEmail(filtro.Destinatario).Id).ToList().ForEach(x =>
             {
                 if (respuesta.FirstOrDefault(z => z.Id == x.Id) == null)
                 {
                     respuesta.Add(x);
                 }
             });
             todos     = respuesta;
             respuesta = new List <SPaquete>();
             cambio    = true;
         }
         if (filtro.Estado != null)
         {
             if (filtro.Estado == "En viaje")
             {
                 todos.Where(x => x.FechaIngreso == x.FechaEntrega).ToList().ForEach(x =>
                 {
                     if (respuesta.FirstOrDefault(z => z.Id == x.Id) == null)
                     {
                         respuesta.Add(x);
                     }
                 });
                 todos     = respuesta;
                 respuesta = new List <SPaquete>();
                 cambio    = true;
             }
             else
             {
                 todos.Where(x => x.FechaIngreso != x.FechaEntrega).ToList().ForEach(x =>
                 {
                     if (respuesta.FirstOrDefault(z => z.Id == x.Id) == null)
                     {
                         respuesta.Add(x);
                     }
                 });
                 todos     = respuesta;
                 respuesta = new List <SPaquete>();
                 cambio    = true;
             }
         }
         if (cambio)
         {
             return(todos);
         }
         return(null);
     }
     catch (Exception)
     {
         throw;
     }
 }