Exemplo n.º 1
0
        public async Task <bool> AddMaterialAsync(AddMaterialRequestArgs requestArgs)
        {
            await DbContext.ExecuteNonQueryAsync(DataConstants.PR_ADD_MATERIAL, CommandType.StoredProcedure, args =>
            {
                args.Add("@TestID", requestArgs.TestID);
                args.Add("@Filter", requestArgs.ToFilterString());
                args.Add("@Columns", requestArgs.ToColumnsString());
                args.Add("@TVP_3GBMaterial", requestArgs.ToTVP());
            });

            return(true);
        }
Exemplo n.º 2
0
        public async Task <DataWithMarkerResult> GetSelectedDataAsync(AddMaterialRequestArgs requestArgs)
        {
            var result = new DataWithMarkerResult();
            var data   = await DbContext.ExecuteDataSetAsync(DataConstants.PR_GET_SELECTED_DATA, CommandType.StoredProcedure, args =>
            {
                args.Add("@TestID", requestArgs.TestID);
                args.Add("@Page", requestArgs.PageNumber);
                args.Add("@PageSize", requestArgs.PageSize);
                args.Add("@FilterQuery", requestArgs.ToFilterString());
            });

            if (data.Tables.Count == 2)
            {
                var table0 = data.Tables[0];
                if (table0.Columns.Contains("TotalRows"))
                {
                    if (table0.Rows.Count > 0)
                    {
                        result.Total = table0.Rows[0]["TotalRows"].ToInt32();
                    }
                    table0.Columns.Remove("TotalRows");
                }
                if (table0.Columns.Contains("Total"))
                {
                    if (table0.Rows.Count > 0)
                    {
                        result.TotalCount = table0.Rows[0]["Total"].ToInt32();
                    }
                    table0.Columns.Remove("Total");
                }
                result.Data = new
                {
                    Columns = data.Tables[1],
                    Data    = table0
                };
            }
            return(result);
        }