public IActionResult GetXlsSarmut(DateTime?dateFrom, DateTime?dateTo, string divisi, string staff)
        {
            try
            {
                byte[]   xlsInBytes;
                int      offset   = Convert.ToInt32(Request.Headers["x-timezone-offset"]);
                DateTime DateFrom = dateFrom == null ? new DateTime(1970, 1, 1) : Convert.ToDateTime(dateFrom);
                DateTime DateTo   = dateTo == null ? DateTime.Now : Convert.ToDateTime(dateTo);

                var xls = _facade.GenerateExcelSarmut(dateFrom, dateTo, divisi, staff, offset);

                string filename = String.Format("Staff - {0}.xlsx", staff);

                xlsInBytes = xls.ToArray();
                var file = File(xlsInBytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", filename);
                return(file);
            }
            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));
            }
        }
Example #2
0
        public async void Should_Success_Get_Report_Data_Excel_subStaffs_Null_Parameter()
        {
            var dbContext = _dbContext(GetCurrentMethod());
            PurchaseOrderMonitoringAllFacade facade = new PurchaseOrderMonitoringAllFacade(GetServiceProvider(GetCurrentMethod()).Object, dbContext);
            DeliveryOrderFacade doFacade            = new DeliveryOrderFacade(dbContext, GetServiceProvider(GetCurrentMethod()).Object);
            var model = await _dataUtilDO(doFacade, GetCurrentMethod()).GetTestData("Unit test");

            var Response = facade.GenerateExcelSarmut(null, null, null, null, 0);

            Assert.IsType <System.IO.MemoryStream>(Response);
        }