コード例 #1
0
ファイル: BL.Curso.cs プロジェクト: aicl/Aicl.Galapago
		public static Response<Curso> Get(this Curso request, Factory factory, IHttpRequest httpRequest)
		{
			long? totalCount=null;

			var paginador= new Paginador(httpRequest);
            var queryString= httpRequest.QueryString;

            var predicate=PredicateBuilder.True<Curso>();

			var qv = queryString["Fecha"];
			if(! qv.IsNullOrEmpty())
			{
				DateTime fecha;
				if (DateTime.TryParse(qv, out fecha) )
				{
					var inicio= fecha.AddDays(-40);
					var fin = fecha.AddDays(40);
					predicate= predicate.AndAlso(q=>q.FechaInicio>=inicio &&
					                             q.FechaInicio<=fin);
				}
			}


			var visitor = ReadExtensions.CreateExpression<Curso>();
			visitor.Where(predicate);

			return factory.Execute(proxy=>{
				if(paginador.PageNumber.HasValue)
	            {
					visitor.Select(r=> Sql.Count(r.Id));
					totalCount= proxy.Count(visitor);
					visitor.Select();
	                int rows= paginador.PageSize.HasValue? paginador.PageSize.Value:BL.PageSize;
	                visitor.Limit(paginador.PageNumber.Value*rows, rows);
	            }
	                                
				visitor.OrderByDescending(r=> r.FechaInicio );

				return new Response<Curso>{
					Data=proxy.Get(visitor),
					TotalCount= totalCount
				};
			});
       
		}
コード例 #2
0
ファイル: BL.Infante.cs プロジェクト: aicl/Aicl.Galapago
		public static Response<Infante> Get(this Infante request, Factory factory, IHttpRequest httpRequest)
        {
			long? totalCount=null;

			var paginador= new Paginador(httpRequest);
            var queryString= httpRequest.QueryString;

            var predicate=PredicateBuilder.True<Infante>();

			var documento = queryString["Documento"];
			if(! documento.IsNullOrEmpty())
			{
				predicate= predicate.AndAlso(q=>q.Documento.StartsWith(documento));
			}

			var nombres= queryString["Nombres"];
			if(!nombres.IsNullOrEmpty())
				predicate= predicate.AndAlso(q=>q.Nombres.Contains(nombres));

			var apellidos= queryString["Apellidos"];
			if(!apellidos.IsNullOrEmpty())
				predicate= predicate.AndAlso(q=>q.Apellidos.Contains(apellidos));

			var visitor = ReadExtensions.CreateExpression<Infante>();
			visitor.Where(predicate);

			return factory.Execute(proxy=>{
				if(paginador.PageNumber.HasValue)
	            {
					visitor.Select(r=> Sql.Count(r.Id));
					totalCount= proxy.Count(visitor);
					visitor.Select();
	                int rows= paginador.PageSize.HasValue? paginador.PageSize.Value:BL.PageSize;
	                visitor.Limit(paginador.PageNumber.Value*rows, rows);
	            }
	                                
				visitor.OrderByDescending(r=> new { r.Nombres, r.Apellidos});

				return new Response<Infante>{
					Data=proxy.Get(visitor),
					TotalCount= totalCount
				};
			});
            
		}
コード例 #3
0
ファイル: BL.Clase.cs プロジェクト: aicl/Aicl.Galapago
		public static Response<Clase> Get(this Clase request, Factory factory, IHttpRequest httpRequest)
		{
			long? totalCount=null;

			var paginador= new Paginador(httpRequest);
            var queryString= httpRequest.QueryString;

            var predicate=PredicateBuilder.True<Clase>();

			var qv = queryString["Activo"];
			if(! qv.IsNullOrEmpty())
			{
				bool activo;
				if (bool.TryParse(qv, out activo) )
					predicate= predicate.AndAlso(q=>q.Activo==activo);
			}


			var visitor = ReadExtensions.CreateExpression<Clase>();
			visitor.Where(predicate);

			return factory.Execute(proxy=>{
				if(paginador.PageNumber.HasValue)
	            {
					visitor.Select(r=> Sql.Count(r.Id));
					totalCount= proxy.Count(visitor);
					visitor.Select();
	                int rows= paginador.PageSize.HasValue? paginador.PageSize.Value:BL.PageSize;
	                visitor.Limit(paginador.PageNumber.Value*rows, rows);
	            }
	                                
				visitor.OrderByDescending(r=> r.Nombre );

				return new Response<Clase>{
					Data=proxy.Get(visitor),
					TotalCount= totalCount
				};
			});
       
		}
コード例 #4
0
ファイル: BL.Tercero.cs プロジェクト: aicl/Aicl.Galapago
        public static Response<Tercero> Get(this Tercero request,
                                           Factory factory,
                                           IHttpRequest httpRequest)
        {
            return factory.Execute(proxy=>{

				var paginador= new Paginador(httpRequest);
            	var queryString= httpRequest.QueryString;

            	long? totalCount=null;

                Expression<Func<Tercero, bool>> predicate;

                int id;
                if(int.TryParse(queryString["Id"], out id))
                    predicate=q=>q.Id== id;                          
                else
                    predicate= PredicateBuilder.True<Tercero>();

                bool activo;
                if (bool.TryParse( queryString["Activo"], out activo))
                    predicate= predicate.AndAlso( q=>q.Activo== activo);                          

                var documento= queryString["Documento"];
                if(!documento.IsNullOrEmpty())
                    predicate= predicate.AndAlso(q=>q.Documento.StartsWith(documento));

                var nombre= queryString["Nombre"];
                if(!nombre.IsNullOrEmpty())
                    predicate= predicate.AndAlso(q=>q.Nombre.Contains(nombre));

                bool esAuto;
                if(bool.TryParse(queryString["EsAutoRetenedor"],out esAuto))
                    predicate=predicate.AndAlso( q=>q.EsAutoRetenedor==esAuto);

                Expression<Func<Tercero, bool>> predicate2=null;

                bool esCliente;
                if(bool.TryParse(queryString["EsCliente"],out esCliente))
                    predicate2= q=>q.EsCliente==esCliente;

                bool esEmpleado;
                if(bool.TryParse(queryString["EsEmpleado"],out esEmpleado))
                {
                    if(predicate2==null) predicate2= q=>q.EsEmpleado==esEmpleado;
                    else predicate2= predicate2.OrElse(q=>q.EsEmpleado==esEmpleado);
                }

                bool esEps;
                if(bool.TryParse(queryString["EsEps"],out esEps))
                {
                    if(predicate2==null) predicate2= q=>q.EsEps==esEps;
                    else predicate2= predicate2.OrElse(q=>q.EsEps==esEps);
                }

                bool esFp;
                if(bool.TryParse(queryString["EsFp"],out esFp))
                {
                    if(predicate2==null) predicate2= q=>q.EsFp==esFp;
                    else predicate2= predicate2.OrElse(q=>q.EsFp==esFp);
                }

                bool esPF;
                if(bool.TryParse(queryString["EsParafiscal"],out esPF))
                {
                    if(predicate2==null) predicate2= q=>q.EsParafiscal==esPF;
                    else predicate2= predicate2.OrElse(q=>q.EsParafiscal==esPF);
                }

                bool esPr;
                if(bool.TryParse(queryString["EsProveedor"],out esPr))
                {
                    if(predicate2==null) predicate2= q=>q.EsProveedor==esPr;
                    else predicate2= predicate2.OrElse(q=>q.EsProveedor==esPr);
                }

                if(predicate2!=null) 
                    predicate= predicate.AndAlso(predicate2);

                var visitor = ReadExtensions.CreateExpression<Tercero>();
				visitor.Where(predicate);

                if(paginador.PageNumber.HasValue)
                {
					visitor.Select(r=> Sql.Count(r.Id));
                    totalCount= proxy.Count(visitor);
					visitor.Select();
                    int rows= paginador.PageSize.HasValue? paginador.PageSize.Value:BL.PageSize;
                    visitor.Limit(paginador.PageNumber.Value*rows, rows);
                }
                                
                visitor.OrderBy(r=>r.Nombre);
                
				return new Response<Tercero>(){
                	Data=proxy.Get(visitor),
                	TotalCount=totalCount
            	};

            });

                        
            

        }
コード例 #5
0
        public static Response<ComprobanteEgreso> Get(this ComprobanteEgreso request,
		                                              Factory factory,
		                                              IHttpRequest httpRequest)
        {
            return factory.Execute(proxy=>{

				long? totalCount=null;

				var paginador= new Paginador(httpRequest);
            	var queryString= httpRequest.QueryString;

                Expression<Func<ComprobanteEgreso, bool>> predicate;

				var periodo= queryString["Periodo"];
				if(periodo.IsNullOrEmpty()) periodo= DateTime.Today.ObtenerPeriodo();
                if (periodo.Length==6)
                    predicate= q=>q.Periodo==periodo;
                else
                    predicate= q=>q.Periodo.StartsWith(periodo) ;

				var nombre= queryString["NombreTercero"];
                if(!nombre.IsNullOrEmpty())
                    predicate= predicate.AndAlso(q=>q.NombreTercero.Contains(nombre));

				var sucursal= queryString["NombreSucursal"];
                if(!sucursal.IsNullOrEmpty())
                    predicate= predicate.AndAlso(q=>q.NombreSucursal.Contains(sucursal));

				string asentado= queryString["Asentado"];
            	if(!asentado.IsNullOrEmpty())
           		{
                	bool tomarSoloAsentado;
	                if( bool.TryParse(asentado,out tomarSoloAsentado))
	                {
						if(tomarSoloAsentado)
							predicate= predicate.AndAlso(q=>q.FechaAsentado!=null);
						else
							predicate= predicate.AndAlso(q=>q.FechaAsentado==null);
	                }
	            }

                var visitor = ReadExtensions.CreateExpression<ComprobanteEgreso>();
				visitor.Where(predicate);

                if(paginador.PageNumber.HasValue)
                {
					visitor.Select(r=> Sql.Count(r.Id));
                    totalCount= proxy.Count(visitor);
					visitor.Select();
                    int rows= paginador.PageSize.HasValue? paginador.PageSize.Value:BL.PageSize;
                    visitor.Limit(paginador.PageNumber.Value*rows, rows);
                }
                                
                visitor.OrderByDescending(r=>r.Numero);      

				return new Response<ComprobanteEgreso>(){
                	Data=proxy.Get(visitor),
                	TotalCount=totalCount
            	};

            });

        }
コード例 #6
0
ファイル: BL.Ingreso.cs プロジェクト: aicl/Aicl.Galapago
        public static Response<Ingreso> Get(this Ingreso request,
		                                              Factory factory,
		                                              IHttpRequest httpRequest)
        {
            return factory.Execute(proxy=>{

				long? totalCount=null;

				var paginador= new Paginador(httpRequest);
            	var queryString= httpRequest.QueryString;

                var predicate=PredicateBuilder.True<Ingreso>();

                var periodo= queryString["Periodo"];
				if(! periodo.IsNullOrEmpty()) //periodo= DateTime.Today.ObtenerPeriodo();
				{
	                if (periodo.Length==6)
	                    predicate= q=>q.Periodo==periodo;
	                else
	                    predicate= q=>q.Periodo.StartsWith(periodo) ;
				}

				var p =queryString["IdSucursal"];
				if(!p.IsNullOrEmpty())
				{
					int idSucursal;
					if(int.TryParse(p,out idSucursal) && idSucursal!=default(int))
						predicate= predicate.AndAlso(q=>q.IdSucursal==idSucursal);
				}

				p=queryString["IdTercero"];
				if(!p.IsNullOrEmpty())
				{
					int idTercero;
					if(int.TryParse(p,out idTercero) && idTercero!=default(int))
						predicate= predicate.AndAlso(q=>q.IdTercero==idTercero);
				}

                var nombre= queryString["NombreTercero"];
                if(!nombre.IsNullOrEmpty())
                    predicate= predicate.AndAlso(q=>q.NombreTercero.Contains(nombre));

				var sucursal= queryString["NombreSucursal"];
                if(!sucursal.IsNullOrEmpty())
                    predicate= predicate.AndAlso(q=>q.NombreSucursal.Contains(sucursal));

				p= queryString["Asentado"];
            	if(!p.IsNullOrEmpty())
           		{
                	bool asentado;
	                if( bool.TryParse(p,out asentado))
	                {
						if(asentado)
							predicate= predicate.AndAlso(q=>q.FechaAsentado!=null);
						else
							predicate= predicate.AndAlso(q=>q.FechaAsentado==null);
	                }
	            }

				p= queryString["ConSaldo"];
            	if(!p.IsNullOrEmpty())
           		{
                	bool saldo;
	                if( bool.TryParse(p,out saldo))
	                {
						if (saldo) predicate= predicate.AndAlso(q=>q.Saldo!=0);
						else predicate= predicate.AndAlso(q=>q.Saldo==0);
	                }
	            }

                var visitor = ReadExtensions.CreateExpression<Ingreso>();
				visitor.Where(predicate);
                if(paginador.PageNumber.HasValue)
                {
					visitor.Select(r=> Sql.Count(r.Id));
					totalCount= proxy.Count(visitor);
					visitor.Select();
                    int rows= paginador.PageSize.HasValue? paginador.PageSize.Value:BL.PageSize;
                    visitor.Limit(paginador.PageNumber.Value*rows, rows);
                }
                                
                visitor.OrderByDescending(r=>r.Numero);
                
				return new Response<Ingreso>(){
                	Data=proxy.Get(visitor),
                	TotalCount=totalCount
            	};
            });  
        }
コード例 #7
0
ファイル: BL.SaldoTercero.cs プロジェクト: aicl/Aicl.Galapago
        public static Response<SaldoTercero> Get(this SaldoTercero request,
		                                              Factory factory,
		                                              IHttpRequest httpRequest)
        {
            return factory.Execute(proxy=>{

				long? totalCount=null;

				var paginador= new Paginador(httpRequest);
            	var queryString= httpRequest.QueryString;

                var predicate = PredicateBuilder.True<SaldoTercero>();

				var nombre= queryString["Nombre"];
                if(!nombre.IsNullOrEmpty())
                    predicate= predicate.AndAlso(q=>q.Nombre.Contains(nombre));

				var sucursal= queryString["NombreSucursal"];
                if(!sucursal.IsNullOrEmpty())
                    predicate= predicate.AndAlso(q=>q.NombreSucursal.Contains(sucursal));

				string p= queryString["IdSucursal"];
            	if(!p.IsNullOrEmpty())
           		{
					int idSucursal;
	                if( int.TryParse(p,out idSucursal))
	                {
						if(idSucursal!=default(int))
							predicate= predicate.AndAlso(q=>q.IdSucursal==idSucursal);
	                }
	            }


				p= queryString["IdTercero"];
            	if(!p.IsNullOrEmpty())
           		{
					int idTercero;
	                if( int.TryParse(p,out idTercero))
	                {
						if(idTercero!=default(int))
							predicate= predicate.AndAlso(q=>q.IdTercero==idTercero);
	                }
	            }

				p= queryString["Grupo"];
				if(!p.IsNullOrEmpty())
           		{
					if(p=="CuentasPorPagar" || p=="CxP")
						predicate=predicate.AndAlso(q=>q.CodigoItem.StartsWith(Definiciones.GrupoCuentasPorPagar));
					else if(p=="CuentasPorCobrar" || p=="CxC")
						predicate=predicate.AndAlso(q=>q.CodigoItem.StartsWith(Definiciones.GrupoCuentasPorCobrar));						
	            }


				predicate= predicate.AndAlso(q=> (q.SaldoInicial+q.Debitos-q.Creditos)!=0);

                var visitor = ReadExtensions.CreateExpression<SaldoTercero>();
				visitor.Where(predicate);

                if(paginador.PageNumber.HasValue)
                {
					visitor.Select(r=> Sql.Count(r.Id));
                    totalCount= proxy.Count(visitor);
					visitor.Select();
                    int rows= paginador.PageSize.HasValue? paginador.PageSize.Value:BL.PageSize;
                    visitor.Limit(paginador.PageNumber.Value*rows, rows);
                }
                                
                visitor.OrderBy(r=>r.Nombre);      

				return new Response<SaldoTercero>(){
                	Data=proxy.Get(visitor),
                	TotalCount=totalCount
            	};

            });

        }