view for FreeStockFilter view and Wrapping filtering criteria objects
예제 #1
0
        public List<FreeStockProgram> GetFreeStockGroupedByProgram(int HuBID, FreeStockFilterViewModel freeStockFilterViewModel)
        {
            var dbGetStatusReportBySI = _unitOfWork.ReportRepository.GetStatusReportBySI(HuBID).ToList();
            if (freeStockFilterViewModel.ProgramId.HasValue && freeStockFilterViewModel.ProgramId != 0)
            {
                dbGetStatusReportBySI = dbGetStatusReportBySI.Where(p => p.ProgramID == freeStockFilterViewModel.ProgramId).ToList();
            }

            if (freeStockFilterViewModel.CommodityId.HasValue && freeStockFilterViewModel.CommodityId != 0)
            {
                dbGetStatusReportBySI = dbGetStatusReportBySI.Where(p => p.CommodityID == freeStockFilterViewModel.CommodityId).ToList();
            }

            if (freeStockFilterViewModel.ShippingInstructionId.HasValue && freeStockFilterViewModel.ShippingInstructionId != 0)
            {
                dbGetStatusReportBySI = dbGetStatusReportBySI.Where(p => p.ShippingInstructionID == freeStockFilterViewModel.ShippingInstructionId).ToList();
            }
            if (freeStockFilterViewModel.ProjectCodeId.HasValue && freeStockFilterViewModel.ProjectCodeId != 0)
            {
                dbGetStatusReportBySI = dbGetStatusReportBySI.Where(p => p.ProjectCodeID == freeStockFilterViewModel.ProjectCodeId).ToList();
            }

            return (from t in dbGetStatusReportBySI
                    group t by new { t.ProgramID, t.ProgramName }
                        into b
                        select new FreeStockProgram()
                        {
                            Name = b.Key.ProgramName,
                            Details = b.Select(t1 => new FreeStockStatusRow()
                            {
                                SINumber = t1.SINumber,
                                Vessel = t1.Vessel,
                                Allocation = t1.AllocatedToHub ?? 0,
                                Dispatched =
                                    t1.dispatchedBalance ?? 0,
                                Transported =
                                    t1.fullyCommitedBalance ?? 0,
                                Donor = t1.Donor,
                                FreeStock = t1.UncommitedStock ?? 0,
                                PhysicalStock =
                                    t1.TotalStockOnHand ?? 0,
                                Product = t1.CommodityName,
                                Program = t1.ProgramName,
                                Project = t1.ProjectCode,
                                ReceivedAmount =
                                    t1.ReceivedBalance ?? 0,
                                Remark = ""
                            }).OrderBy(c => c.Product).ToList()
                        }).ToList();
        }
        public void ShoulDisplayFreeStockPartial()
        {
            //Act
            var filter = new FreeStockFilterViewModel();
            var result = _reportsController.FreeStockPartial(filter);

            //Assert

            Assert.IsInstanceOf<PartialViewResult>(result);
        }
        public MasterReportBound GetFreeStock(FreeStockFilterViewModel freeStockFilterViewModel)
        {
            List<DRMFSS.BLL.ViewModels.Report.Data.FreeStockReport> reports = new List<BLL.ViewModels.Report.Data.FreeStockReport>();
            DRMFSS.BLL.ViewModels.Report.Data.FreeStockReport freestockreport = new BLL.ViewModels.Report.Data.FreeStockReport();
            BLL.UserProfile user =_userProfileService.GetUser(User.Identity.Name);

            freestockreport.Programs = _hubService.GetFreeStockGroupedByProgram(user.DefaultHub.HubID, freeStockFilterViewModel);
            freestockreport.PreparedBy = user.GetFullName();
            freestockreport.HubName = user.DefaultHub.HubNameWithOwner;
            freestockreport.ReportDate = System.DateTime.Now;
            freestockreport.ReportName = "FreeStockStatusReport";
            freestockreport.ReportTitle = "Free Stock Status";
            reports.Add(freestockreport);

            DRMFSS.Web.Reports.FreeStockReport rpt = new Web.Reports.FreeStockReport() { DataSource = freestockreport.Programs };
            // XtraReport1 rpt = new XtraReport1() { DataSource = freestockreport.Programs[2].Details };
            MasterReportBound report = new MasterReportBound() { DataSource = reports };
            report.rptSubReport.ReportSource = rpt;
            return report;
        }
 public ActionResult FreeStockReportViewerExportTo(FreeStockFilterViewModel freeStockFilterViewModel)
 {
     MasterReportBound report = GetFreeStock(freeStockFilterViewModel);
     return DevExpress.Web.Mvc.ReportViewerExtension.ExportTo(report);
 }
 public ActionResult FreeStockPartial(FreeStockFilterViewModel freeStockFilterViewModel)
 {
     MasterReportBound report = GetFreeStock(freeStockFilterViewModel);
     ViewBag.ProgramID = freeStockFilterViewModel.ProgramId;
     return PartialView("FreeStockPartial",report);
 }
        public ActionResult FreeStock()
        {
            MasterReportBound report= GetFreeStock(new FreeStockFilterViewModel());
            BLL.UserProfile user = _userProfileService.GetUser(User.Identity.Name);
               var codes=ConstantsService.GetAllCodes();
            var commodityTypes=_commodityTypeService.GetAllCommodityTypeForReprot();
            var programs = _programService.GetAllProgramsForReport();
            var commodities = _commodityService.GetAllCommodityForReprot();
            var areas = _adminUnitService.GetAllAreasForReport();

            FreeStockFilterViewModel ViewModel = new FreeStockFilterViewModel(codes, commodityTypes, programs, commodities, areas);
            ViewBag.Filters = ViewModel;
            return View(report);
        }