Beispiel #1
0
        public async Task <DataWithMarkerResult> GetDataWithDeterminationsAsync(DataWithMarkerRequestArgs request)
        {
            var result = new DataWithMarkerResult();

            DbContext.CommandTimeout = 120;
            var data = await DbContext.ExecuteDataSetAsync(DataConstants.PR_GET_DATA_WITH_MARKERS, CommandType.StoredProcedure, args =>
            {
                args.Add("@TestID", request.TestID);
                //args.Add("@User", userContext.GetContext().FullName);
                args.Add("@Page", request.PageNumber);
                args.Add("@PageSize", request.PageSize);
                args.Add("@Filter", request.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);
        }
Beispiel #2
0
        public DeterminationServiceUnitTests()
        {
            builder = new ContainerBuilder();
            builder.RegisterModule <AutofacModule>();
            IEnumerable <DeterminationResult> determinationlists = new List <DeterminationResult>()
            {
                new DeterminationResult {
                    DeterminationID = 1, DeterminationName = "Test1", DeterminationAlias = "T1", ColumnLabel = "Col1"
                },
                new DeterminationResult {
                    DeterminationID = 2, DeterminationName = "Test2", DeterminationAlias = "T2", ColumnLabel = "Col2"
                }
            };

            determinationRequestArgs = new DeterminationRequestArgs
            {
                CropCode   = "TO",
                TestID     = 1,
                TestTypeID = 1
            };

            dataWithMarkerRequestArgs = new Entities.Args.DataWithMarkerRequestArgs
            {
                TestID     = 1,
                PageNumber = 1,
                PageSize   = 100
            };

            materialsWithMarkerRequestArgs = new Entities.Args.MaterialsWithMarkerRequestArgs
            {
                TestID     = 1,
                PageNumber = 1,
                PageSize   = 100
            };
            externalDeterminationRequestArgs = new Entities.Args.ExternalDeterminationRequestArgs
            {
                CropCode   = "TO",
                TestTypeID = 1
            };

            var dataWithMarker = new DataWithMarkerResult
            {
                Data  = new DataTable(),
                Total = 5
            };
            var materialWithMarker = new MaterialsWithMarkerResult
            {
                Total = 5,
                Data  = new DataTable()
            };

            var determinationRepo = A.Fake <IDeterminationRepository>();

            A.CallTo(() => determinationRepo.GetDeterminationsAsync(determinationRequestArgs)).Returns(determinationlists);
            A.CallTo(() => determinationRepo.GetDataWithDeterminationsAsync(dataWithMarkerRequestArgs)).Returns(dataWithMarker);
            A.CallTo(() => determinationRepo.GetMaterialsWithDeterminationsAsync(materialsWithMarkerRequestArgs)).Returns(materialWithMarker);
            A.CallTo(() => determinationRepo.GetDeterminationsForExternalTestsAsync(externalDeterminationRequestArgs)).Returns(determinationlists);
            A.CallTo(() => determinationRepo.GetMaterialsWithDeterminationsForExternalTestAsync(materialsWithMarkerRequestArgs)).Returns(materialWithMarker);

            builder.RegisterInstance(determinationRepo).As <IDeterminationRepository>().SingleInstance();

            var container = builder.Build();

            _determinationService = container.Resolve <IDeterminationService>();
        }
Beispiel #3
0
        public async Task <IHttpActionResult> GetDataWithDeterminations([FromBody] DataWithMarkerRequestArgs args)
        {
            var determminations = await determinationService.GetDataWithDeterminationsAsync(args);

            return(Ok(determminations));
        }
Beispiel #4
0
 public async Task <DataWithMarkerResult> GetDataWithDeterminationsAsync(DataWithMarkerRequestArgs request)
 {
     request.Validate();
     return(await repository.GetDataWithDeterminationsAsync(request));
 }