Example #1
0
        /// <summary>
        /// Определяем собственный метод фильтрации организаций
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="criteria"></param>
        protected override void CreateFilter <T>(Infrastructure.Repositories.Criteria.ICriteria <T> criteria)
        {
            Infrastructure.Repositories.Criteria.ICriteria <Organization> query = (Infrastructure.Repositories.Criteria.ICriteria <Organization>)criteria;

            ParameterString df = new ParameterString(filter);

            var jQuery = SubQuery <JuridicalPerson>().Select(x => x.Id);
            var pQuery = SubQuery <PhysicalPerson>().Select(x => x.Id);

            if (!String.IsNullOrEmpty(df["Name"].Value as string))
            {
                query.Like(x => x.ShortName, df["Name"].Value as string);
            }

            if (!String.IsNullOrEmpty(df["INN"].Value as string))
            {
                jQuery.Where(x => x.INN == df["INN"].Value as string);
                pQuery.Where(x => x.INN == df["INN"].Value as string);
            }

            if (!String.IsNullOrEmpty(df["Address"].Value as string))
            {
                query.Like(x => x.Address, df["Address"].Value as string);
            }

            if (!String.IsNullOrEmpty(df["OGRN"].Value as string))
            {
                jQuery.Where(x => x.OGRN == df["OGRN"].Value as string);
                pQuery.Where(x => x.OGRNIP == df["OGRN"].Value as string);
            }

            if (!String.IsNullOrEmpty(df["OKPO"].Value as string))
            {
                jQuery.Where(x => x.OKPO == df["OKPO"].Value as string);
                pQuery = null;
            }

            if (!String.IsNullOrEmpty(df["KPP"].Value as string))
            {
                jQuery.Where(x => x.KPP == df["KPP"].Value as string);
                pQuery = null;
            }

            //Выбираем все организации, удовлетворяющие фильтру
            if (pQuery != null)
            {
                query.Or(x => x.PropertyIn(y => y.Id, jQuery), x => x.PropertyIn(y => y.Id, pQuery));
            }
            else
            {
                query.PropertyIn(y => y.Id, jQuery);
            }
        }
Example #2
0
        /// <summary>
        /// Определяем собственный метод фильтрации организаций контрагента
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="criteria"></param>
        protected override void CreateFilter <T>(Infrastructure.Repositories.Criteria.ICriteria <T> criteria)
        {
            Infrastructure.Repositories.Criteria.ICriteria <DealQuota> query = (Infrastructure.Repositories.Criteria.ICriteria <DealQuota>)criteria;

            ParameterString df = parameterString;

            if (df["DealId"] != null && df["DealId"].Value != null)
            {
                string str = df["DealId"].Value is IList <string>?(df["DealId"].Value as IList <string>)[0] : df["DealId"].Value as string;
                if (str.Length > 0)
                {
                    var dealId   = ValidationUtils.TryGetInt(str);
                    var subQuery = SubQuery <Deal>().Where(x => x.Id == dealId);
                    subQuery.Restriction <DealQuota>(x => x.Quotas).Select(x => x.Id);

                    string modeStr = df["Mode"].Value is IList <string>?(df["Mode"].Value as IList <string>)[0] : df["Mode"].Value as string;

                    switch (modeStr)
                    {
                    case "Sale":
                        query.PropertyIn(x => x.Id, subQuery); break;

                    case "Deal":
                        query.PropertyNotIn(x => x.Id, subQuery); break;

                    default:
                        throw new Exception("Неверное значение входного параметра.");
                    }
                }
            }

            df.Delete("DealId");
            df.Delete("Mode");

            base.CreateFilter <T>(criteria);
        }
Example #3
0
        /// <summary>
        /// Определяем собственный метод фильтрации организаций контрагента
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="criteria"></param>
        protected override void CreateFilter <T>(Infrastructure.Repositories.Criteria.ICriteria <T> criteria)
        {
            Infrastructure.Repositories.Criteria.ICriteria <ClientOrganization> query = (Infrastructure.Repositories.Criteria.ICriteria <ClientOrganization>)criteria;

            if (parameterString != null)
            {
                parameterString.MergeWith(new Utils.ParameterString(filter));
            }
            else
            {
                parameterString = new Utils.ParameterString(filter);
            }

            var jQuery = SubQuery <JuridicalPerson>().Select(x => x.Id);
            var pQuery = SubQuery <PhysicalPerson>().Select(x => x.Id);

            if (parameterString["INN"] != null && parameterString["INN"].Value != null)
            {
                var str = parameterString["INN"].Value is IList <string>?(parameterString["INN"].Value as IList <string>)[0] : parameterString["INN"].Value as string;

                jQuery.Where(x => x.INN == str);
                pQuery.Where(x => x.INN == str);
            }
            parameterString.Delete("INN");

            if (parameterString["Address"] != null && parameterString["Address"].Value != null)
            {
                var str = parameterString["Address"].Value is IList <string>?(parameterString["Address"].Value as IList <string>)[0] : parameterString["Address"].Value as string;

                query.Like(x => x.Address, str);
            }
            parameterString.Delete("Address");

            if (parameterString["OGRN"] != null && parameterString["OGRN"].Value != null)
            {
                var str = parameterString["OGRN"].Value is IList <string>?(parameterString["OGRN"].Value as IList <string>)[0] : parameterString["OGRN"].Value as string;

                jQuery.Where(x => x.OGRN == str);
                pQuery.Where(x => x.OGRNIP == str);
            }
            parameterString.Delete("OGRN");

            if (parameterString["OKPO"] != null && parameterString["OKPO"].Value != null)
            {
                var str = parameterString["OKPO"].Value is IList <string>?(parameterString["OKPO"].Value as IList <string>)[0] : parameterString["OKPO"].Value as string;

                jQuery.Where(x => x.OKPO == str);
                pQuery = null;
            }
            parameterString.Delete("OKPO");

            if (parameterString["KPP"] != null && parameterString["KPP"].Value != null)
            {
                var str = parameterString["KPP"].Value is IList <string>?(parameterString["KPP"].Value as IList <string>)[0] : parameterString["KPP"].Value as string;

                jQuery.Where(x => x.KPP == str);
                pQuery = null;
            }
            parameterString.Delete("KPP");

            //Выбираем все организации, удовлетворяющие фильтру
            if (pQuery != null)
            {
                query.Or(x => x.PropertyIn(y => y.EconomicAgent.Id, jQuery), x => x.PropertyIn(y => y.EconomicAgent.Id, pQuery));
            }
            else
            {
                query.PropertyIn(y => y.EconomicAgent.Id, jQuery);
            }

            filter = "";

            base.CreateFilter(query);

            parameterString.Delete("ShortName");
        }