view model for Receipts view and Wrapping filtering criteria objects
Exemplo n.º 1
0
 public ActionResult ReceiptsReport(ReceiptsViewModel viewModel)
 {
     ViewBag.Program = viewModel.ProgramId == null ? "All" : _programService.GetAllProgram().Where(c => c.ProgramID == viewModel.ProgramId).Select(c => c.Name).Single();
     ViewBag.CommodityTypes = viewModel.CommodityTypeId == 0 ? "All" : _commodityTypeService.GetAllCommodityType().Where(c => c.CommodityTypeID == viewModel.CommodityTypeId).Select(c => c.Name).Single();
     ViewBag.CommoditySources = viewModel.CommoditySourceId == 0 ? "All" : _commoditySourceService.GetAllCommoditySource().Where(c => c.CommoditySourceID == viewModel.CommoditySourceId).Select(c => c.Name).Single();
     return PartialView();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the receive report.
        /// </summary>
        /// <param name="hubID">The hub ID.</param>
        /// <param name="receiptsViewModel">The receipts view model.</param>
        /// <returns></returns>
        public List<ReceiveReport> GetReceiveReport(int hubID, ReceiptsViewModel receiptsViewModel)
        {
            DateTime sTime = DateTime.Now;
            DateTime eTime = DateTime.Now;

            if (!receiptsViewModel.PeriodId.HasValue)
            {
                sTime = new DateTime(1979, 01, 01, 00, 00, 00, 000);
            }
            else
            {
                //start end date filters
                if (receiptsViewModel.PeriodId == 8)
                {
                    sTime = receiptsViewModel.StartDate ?? sTime;
                    eTime = receiptsViewModel.EndDate ?? eTime;
                }
                //allocation round
                else if (receiptsViewModel.PeriodId == 6)
                {
                    //filter it to only the current week
                    // sTime = DateTime.Now.StartOfWeek(DayOfWeek.Monday);
                    eTime = sTime.AddDays(7).Date;
                }
                //allocation year + month
                else if (receiptsViewModel.PeriodId == 9)
                {
                }
            }

            string StartTime = sTime.ToShortDateString();
            string EndTime = eTime.ToShortDateString();
            // string HUbName = repository.Hub.FindById(hubID).HubNameWithOwner;
            var dbGetReceiptReport = _unitOfWork.ReportRepository.RPT_ReceiptReport(hubID, sTime, eTime).ToList();

            if (receiptsViewModel.ProgramId.HasValue && receiptsViewModel.ProgramId != 0)
            {
                dbGetReceiptReport = dbGetReceiptReport.Where(p => p.ProgramID == receiptsViewModel.ProgramId).ToList();
            }
            if (receiptsViewModel.CommodityTypeId.HasValue && receiptsViewModel.CommodityTypeId != 0)
            {
                dbGetReceiptReport = dbGetReceiptReport.Where(p => p.CommodityTypeID == receiptsViewModel.CommodityTypeId).ToList();
            }

            return (from t in dbGetReceiptReport
                    group t by new { t.BudgetYear }
                        into b
                        select new ReceiveReport()
                        {
                            BudgetYear = b.Key.BudgetYear.Value,
                            rows = b.Select(t1 => new ReceiveRow()
                            {
                                Product = t1.CommodityName,
                                Program = t1.ProgramName,
                                Quantity = t1.BalanceInMt.Value,
                                Quarter = t1.Quarter.Value
                                /*MeasurementUnit = t1.BalanceInUnit.Value*/

                            }).ToList()

                        }).ToList();
        }
Exemplo n.º 3
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public ActionResult Receipts()
        {
            var user = _userProfileService.GetUser(User.Identity.Name);
            var commoditySourceViewModels = _commoditySourceService.GetAllCommoditySourceForReport();
            var portViewModels = _receiveService.GetALlPorts();
            var codesViewModels = ConstantsService.GetAllCodes();
            var commodityTypeViewModels = _commodityTypeService.GetAllCommodityTypeForReprot();
            var programViewModels = _programService.GetAllProgramsForReport();
            var storeViewModel = _hubService.GetAllStoreByUser(user);
            var viewModel = new ReceiptsViewModel(codesViewModels, commodityTypeViewModels, programViewModels,
                storeViewModel, commoditySourceViewModels, portViewModels);

            return View(viewModel);
        }
        public void CanReceiptsReport()
        {
            //ACT
            //TODO: Seed data into ReceiptsViewModel before proceding with testing
            var viewModel = new ReceiptsViewModel { };
            var viewResult = _stockManagementController.ReceiptsReport(viewModel) as ViewResult;

            //ASSERT
            Assert.NotNull(viewResult);
            Assert.IsInstanceOf<IEnumerable<Program>>(viewResult.ViewBag.Program);
            Assert.IsInstanceOf<IEnumerable<CommodityType>>(viewResult.ViewBag.CommodityTypes);
            Assert.IsInstanceOf<IEnumerable<CommoditySource>>(viewResult.ViewBag.CommoditySources);
        }