コード例 #1
0
        public async Task Should_Success_Get_Data_Empty()
        {
            var dbContext       = _dbContext(GetCurrentMethod());
            var serviceProvider = _getServiceProvider(GetCurrentMethod()).Object;

            var unitPaymentOrderFacade = new UnitPaymentOrderFacade(serviceProvider, dbContext);
            var dataUtil = await _dataUtil(unitPaymentOrderFacade, dbContext, GetCurrentMethod()).GetTestImportData();

            var urnId = dataUtil.Items.FirstOrDefault().URNId;
            var urn   = dbContext.UnitReceiptNotes.FirstOrDefault(f => f.Id.Equals(urnId));
            var prId  = urn.Items.FirstOrDefault(f => f.URNId.Equals(urn.Id)).PRId;
            var pr    = dbContext.PurchaseRequests.FirstOrDefault(f => f.Id.Equals(prId));

            var facade = new ImportPurchasingBookReportFacade(serviceProvider, dbContext);

            var result = await facade.GetReport("Invalid URNNo", urn.UnitCode, pr.CategoryCode, DateTime.Now.AddDays(-7), DateTime.Now.AddDays(7));

            Assert.NotNull(result.Reports);
        }
        //public async Task Should_Success_Get_Report_Data()
        //{
        //	ExternalPurchaseOrder externalPurchaseOrder = await EPODataUtil.GetNewData("unit-test");
        //	await EPOFacade.Create(externalPurchaseOrder, "unit-test", 7);
        //	DeliveryOrder deliveryOrder = await DODataUtil.GetNewData("unit-test");
        //	await DOFacade.Create(deliveryOrder, "unit-test");
        //	UnitReceiptNote urn = await DataUtil.GetNewDatas("unit-test");
        //	await Facade.Create(urn, "unit-test");
        //          //UnitPaymentOrder upo = await UPODataUtil.GetTestData();
        //          //await UPOFacade.Create(upo, "unit-test", false, 7);
        //          var DateFrom = DateTime.Now;
        //          DateFrom = DateFrom.Date;
        //          var DateTo = DateTime.Now;
        //          DateTo = DateTo.Date;
        //          var Response = IPRFacade.GetReport(null, null,null ,DateFrom,DateTo);
        //	Assert.NotEqual(Response.Item2, 0);
        //}
        public void Should_Success_Get_Report_Data()
        {
            //ExternalPurchaseOrder externalPurchaseOrder = await EPODataUtil.GetTestData("Unit test");
            //DeliveryOrder deliveryOrder = await DODataUtil.GetTestData("unit-test");
            var dbContext = _dbContext(GetCurrentMethod());
            UnitReceiptNoteFacade facade = new UnitReceiptNoteFacade(_ServiceProvider.Object, dbContext);
            var dataUtil = _dataUtil(facade, dbContext).GetTestData(USERNAME);
            //UnitReceiptNote urn = await _dataUtil.GetTestData2("unit-test");
            var DateFrom = DateTime.Now.AddDays(-1);

            DateFrom = DateFrom.Date;
            var DateTo = DateTime.Now.AddDays(1);

            DateTo = DateTo.Date;
            ImportPurchasingBookReportFacade response = new ImportPurchasingBookReportFacade(_ServiceProvider.Object, dbContext);
            var Response = response.GetReport(null, null, null, DateFrom, DateTo);

            Assert.Equal(Response.Item2, 0);
        }
        public IActionResult Get(string no, string unit, string category, DateTime?dateFrom, DateTime?dateTo)
        {
            try
            {
                var data = importPurchasingBookReportFacade.GetReport(no, unit, category, dateFrom, dateTo);
                //var data = importPurchasingBookReportService.GetReport();

                return(Ok(new
                {
                    apiVersion = ApiVersion,
                    data = data.Item1,
                    info = new { total = data.Item2 },
                    message = General.OK_MESSAGE,
                    statusCode = General.OK_STATUS_CODE
                }));
            }
            catch (Exception e)
            {
                Dictionary <string, object> Result =
                    new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message)
                    .Fail();
                return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, Result));
            }
        }