public void UpdatePackageTest() { var package = Enumerable.First(packageContract.GetAll(), x => x.PackageId == 1); package.PackageId = 500; packageContract.Update(package); }
public void GetPackageByBarcodeTest() { var packageTransaction = packageTransactionsContracts.GetAll().FirstOrDefault(); var package = packageContracts.GetAll().FirstOrDefault(x => x.BarcodeId == packageTransaction.BarcodeId); Assert.IsNotNull(package); }
public ActionResult DCLosses() { AutoMapper.Mapper.CreateMap <Package, PackageViewModel>(); AutoMapper.Mapper.CreateMap <Medicine, MedicineViewModel>(); AutoMapper.Mapper.CreateMap <PackageStatus, PackageStatusViewModel>(); AutoMapper.Mapper.CreateMap <PackageTransactions, PackageTransactionsViewModel>(); AutoMapper.Mapper.CreateMap <DistributionCenter, DistributionCenterViewModel>(); var lstDcReport = new List <DCLossReportViewModel>(); var lstDCLostPerDCReport = new List <DCLossReportViewModel>(); var lstLostDiscardedPerDCReport = new List <DCLossReportViewModel>(); DCLossReportViewModel objDC = new DCLossReportViewModel(); DCLossReportViewModel objDCLostPerDC = new DCLossReportViewModel(); DCLossReportViewModel objDCLostDiscardedPerDC = new DCLossReportViewModel(); var packagesLostPerDC = PackagesContracts.GetAll().Where(x => x.PackageStatus.PackageStatusId == 2 || x.PackageStatus.PackageStatusId == 3) .GroupBy(x => new { x.CurrentLocation.Name }) .Select(y => new { DistID = y.Key.Name, TotalPackages = y.Count(), TotalCost = y.Sum(w => w.Medicine.Value) }); var packagesLostDistrDC = PackagesContracts.GetAll().Where(x => x.PackageStatus.PackageStatusId == 2 || x.PackageStatus.PackageStatusId == 3 || x.PackageStatus.PackageStatusId == 4) .GroupBy(x => new { x.CurrentLocation.Name }) .Select(y => new { DistID = y.Key.Name, TotalPackages = y.Count(), TotalCost = y.Sum(w => w.Medicine.Value) }); foreach (var o in packagesLostPerDC) { objDCLostPerDC.DistributionCenter = o.DistID.ToString(); objDCLostPerDC.TotalLostORDiscardedPackages = o.TotalPackages; objDCLostPerDC.TotalLostORDiscardedValue = o.TotalCost; lstDCLostPerDCReport.Add(objDCLostPerDC); } foreach (var o in packagesLostDistrDC) { objDCLostDiscardedPerDC.DistributionCenter = o.DistID.ToString(); objDCLostDiscardedPerDC.TotalLostORDiscardedORDistributedPackages = o.TotalPackages; objDCLostDiscardedPerDC.TotalLostORDiscardedORDIstributedValue = o.TotalCost; lstLostDiscardedPerDCReport.Add(objDCLostDiscardedPerDC); } objDCLostDiscardedPerDC = null; objDCLostPerDC = null; int i = 0; for (i = 0; i < lstDCLostPerDCReport.Count; i++) { objDC.DistributionCenter = (lstDCLostPerDCReport[i]).DistributionCenter; objDC.TotalLostORDiscardedPackages = (lstDCLostPerDCReport[i]).TotalLostORDiscardedPackages; objDC.TotalLostORDiscardedValue = (lstDCLostPerDCReport[i]).TotalLostORDiscardedValue; objDC.TotalLostORDiscardedORDistributedPackages = (lstLostDiscardedPerDCReport[i]).TotalLostORDiscardedORDistributedPackages; objDC.TotalLostORDiscardedORDIstributedValue = (lstLostDiscardedPerDCReport[i]).TotalLostORDiscardedORDIstributedValue; objDC.LossRatio = lstDCLostPerDCReport[i].TotalLostORDiscardedValue / lstLostDiscardedPerDCReport[i].TotalLostORDiscardedORDIstributedValue; lstDcReport.Add(objDC); } return(PartialView("_DistributionCenterLosses", lstDcReport)); }
public void CreateDistributionTest() { var package = packagesContracts.GetAll().FirstOrDefault(); distribution.PackageId = package.PackageId; distribution.On = new DateTime(2015, 6, 6); distribution.Description = "Testing Distribution"; distribution.UserId = 1; distributionContracts.Add(distribution, "", ""); }
public ActionResult GlobalStock() { AutoMapper.Mapper.CreateMap <Package, PackageViewModel>(); AutoMapper.Mapper.CreateMap <Medicine, MedicineViewModel>(); AutoMapper.Mapper.CreateMap <PackageStatus, PackageStatusViewModel>(); AutoMapper.Mapper.CreateMap <PackageTransactions, PackageTransactionsViewModel>(); var packagesModels = PackagesContracts.GetAll().Where(x => x.PackageStatus.PackageStatusId == 1); var packages = AutoMapper.Mapper.Map <IEnumerable <PackageViewModel> >(packagesModels); foreach (var VARIABLE in packages) { VARIABLE.TransitState = PackagesContracts.GetAllStatus().First(x => x.PackageStatusId == VARIABLE.PackageStatusId).TransitState; } return(PartialView("_GlobalStock", packages)); }
public void DiscardPackageTest() { var package = packageContracts.GetAll().FirstOrDefault(); packageContracts.UpdateStatus(package.BarcodeId, 4); }