Exemplo n.º 1
0
        public PageResult <v_lhproducts_policyModel> GetPolicyProducts(ICPOBILL_PolicyDTO header,
                                                                       v_lhproducts_policyModel where, int index = 1, int size = 35)
        {
            where = ComputeWhere(header, where);
            var helper = new OracleDBHelper();
            var total  = 0;

            string whereStr = helper.GetWhereStr(where);

            List <v_lhproducts_policyModel> resultList = new List <v_lhproducts_policyModel>();

            if (string.IsNullOrEmpty(header.HeadID))
            {
                List <V_LHPRODUCTS_UNPOLICYHEADID> data =
                    helper.GetWithWhereStrByPage <V_LHPRODUCTS_UNPOLICYHEADID>(whereStr, where, index, size);

                total = helper.Count <V_LHPRODUCTS_UNPOLICYHEADID>(whereStr);

                var t = typeof(V_LHPRODUCTS_UNPOLICYHEADID);

                var pis = t.GetProperties().ToList();

                data.ForEach(p =>
                {
                    var item = new v_lhproducts_policyModel();
                    pis.ForEach(pi =>
                    {
                        var value = pi.GetValue(p, null);
                        pi.SetValue(item, value);
                    });
                    resultList.Add(item);
                });
            }
            else
            {
                List <v_lhproducts_policyModel> data =
                    helper.GetWithWhereStrByPage <v_lhproducts_policyModel>(whereStr, where, index, size);

                total      = helper.Count <v_lhproducts_policyModel>(whereStr);
                resultList = data;
            }

            PageResult <v_lhproducts_policyModel> result = new PageResult <v_lhproducts_policyModel>()
            {
                Total = total, Result = resultList
            };

            return(result);
        }