Ejemplo n.º 1
0
 public async Task <RMeasureUnit[]> Search(string unitName, EnumDefine.GiftCodeCampaignStatus unitStatus, RefSqlPaging sqlPaging)
 {
     return(await WithConnection(async (connection) =>
     {
         DynamicParameters parameters = new DynamicParameters();
         parameters.Add("@UnitName", unitName, DbType.String);
         parameters.Add("@UnitStatus", unitStatus.AsEnumToInt(), DbType.String);
         parameters.Add("@OFFSET", sqlPaging.OffSet, DbType.Int32);
         parameters.Add("@FETCH", sqlPaging.PageSize, DbType.Int32);
         var data = (await connection.QueryAsync <RMeasureUnit>(ProcName.Measure_Unit_Search, parameters, commandType: CommandType.StoredProcedure)).ToArray();
         if (data.Length > 0)
         {
             sqlPaging.TotalRow = data[0].TotalRow;
         }
         return data;
     }));
 }
        public async Task <RGiftCodeCampaign[]> Gets(string connectionString, string name, DateTime?beginDate, DateTime?endDate, EnumDefine.GiftCodeCampaignStatus status, RefSqlPaging sqlPaging)
        {
            var data = await WithConnection(connectionString, async (connection) =>
            {
                DynamicParameters parameters = new DynamicParameters();
                parameters.Add("@Name", name, DbType.String);
                parameters.Add("@BeginDate", beginDate, DbType.DateTime);
                parameters.Add("@EndDate", endDate, DbType.DateTime);
                parameters.Add("@Status", status.AsEnumToInt(), DbType.Int64);
                parameters.Add("@OFFSET", sqlPaging.OffSet, DbType.Int32);
                parameters.Add("@FETCH", sqlPaging.PageSize, DbType.Int32);
                var result = await connection.QueryAsync <RGiftCodeCampaign>(ProcName.GiftCodeCampaign_Gets, parameters, commandType: CommandType.StoredProcedure);
                return(result.ToArray());
            });

            if (data.Length > 0)
            {
                sqlPaging.TotalRow = data[0].TotalRow;
            }
            return(data);
        }