Exemple #1
0
 public IActionResult Get([FromQuery] Hauler parameters = null)
 {
     try
     {
         var model = repository.Get(parameters);
         return(Ok(model));
     }
     catch (Exception ex)
     {
         logger.LogError(ex.GetExceptionMessages());
         return(StatusCode(StatusCodes.Status500InternalServerError, Constants.ErrorMessages.FetchError));
     }
 }
Exemple #2
0
        private void updateRelatedTableColumns(ref SaleTransaction model)
        {
            var vehicleNum = model.VehicleNum;
            var vehicle    = vehicleRepository.Get()
                             .Include(a => a.VehicleType).DefaultIfEmpty()
                             .Where(a => a.VehicleNum == vehicleNum)
                             .Select(a => new { a.VehicleNum, a.VehicleTypeId, VehicleTypeCode = a.VehicleType == null ? "" : a.VehicleType.VehicleTypeCode }).ToList().FirstOrDefault();

            model.VehicleTypeId   = vehicle?.VehicleTypeId ?? 0;
            model.VehicleTypeCode = vehicle?.VehicleTypeCode;

            var customerId = model.CustomerId;

            model.CustomerName = customerRepository.Get()
                                 .Where(a => a.CustomerId == customerId).Select(a => a.CustomerName).FirstOrDefault();

            var haulerId = model.HaulerId;

            model.HaulerName = haulerRepository.Get()
                               .Where(a => a.HaulerId == haulerId).Select(a => a.HaulerName).FirstOrDefault();


            var productId = model.ProductId;
            var product   = productRepository.Get()
                            .Where(a => a.ProductId == productId)
                            .Include(a => a.Category).DefaultIfEmpty()
                            .Select(a => new { a.ProductDesc, a.CategoryId, CategoryDesc = a.Category == null ? null : a.Category.CategoryDesc })
                            .FirstOrDefault();

            model.ProductDesc  = product?.ProductDesc;
            model.CategoryId   = product?.CategoryId ?? 0;
            model.CategoryDesc = product?.CategoryDesc;

            var msId = model.MoistureReaderId;

            model.MoistureReaderDesc = moistureReaderRepository.Get()
                                       .Where(a => a.MoistureReaderId == msId).Select(a => a.Description).FirstOrDefault();

            var userAccountId = model.WeigherOutId;

            model.WeigherOutName = userAccountRepository.Get().Where(a => a.UserAccountId == userAccountId)
                                   .Select(a => a.FullName).FirstOrDefault();
        }
Exemple #3
0
 public bool HaulerExists(long id)
 {
     return(haulerRepository.Get().Count(a => a.HaulerId == id) > 0);
 }
Exemple #4
0
        public Inyard updateRelatedTableColumns(ref Inyard outModifiedInyard)
        {
            var vehicleNum = outModifiedInyard.VehicleNum;
            var vehicle    = vehicleRepository.Get()
                             .Include(a => a.VehicleType).DefaultIfEmpty()
                             .Where(a => a.VehicleNum == vehicleNum)
                             .Select(a => new { a.VehicleNum, a.VehicleTypeId, VehicleTypeCode = a.VehicleType == null ? "" : a.VehicleType.VehicleTypeCode }).ToList().FirstOrDefault();

            outModifiedInyard.VehicleTypeId   = vehicle?.VehicleTypeId ?? 0;
            outModifiedInyard.VehicleTypeCode = vehicle?.VehicleTypeCode;

            if (outModifiedInyard.TransactionTypeCode == "I")
            {
                var clientId = outModifiedInyard.ClientId;
                outModifiedInyard.ClientName = supplierRepository.Get()
                                               .Where(a => a.SupplierId == clientId).Select(a => a.SupplierName).FirstOrDefault();

                var commodityId = outModifiedInyard.CommodityId;
                var material    = rawMaterialRepository.Get()
                                  .Where(a => a.RawMaterialId == commodityId)
                                  .Include(a => a.Category).DefaultIfEmpty()
                                  .Select(a => new { a.RawMaterialDesc, a.Price, a.CategoryId, CategoryDesc = a.Category == null ? null : a.Category.CategoryDesc })
                                  .FirstOrDefault();
                var poNum = outModifiedInyard.PONum;

                outModifiedInyard.CommodityDesc = material?.RawMaterialDesc;
                outModifiedInyard.CategoryId    = material?.CategoryId ?? 0;
                outModifiedInyard.CategoryDesc  = material?.CategoryDesc;
                outModifiedInyard.Price         = material?.Price ?? 0;

                var purchaseOrderId = outModifiedInyard.PurchaseOrderId;
                var poDetails       = purchaseOrderRepository.Get()
                                      .Where(a => a.PurchaseOrderId == purchaseOrderId).Select(a => new { a.PONum, a.Price, a.POType }).FirstOrDefault();

                outModifiedInyard.PONum  = poDetails?.PONum ?? String.Empty;
                outModifiedInyard.Price  = poDetails?.Price ?? 0;
                outModifiedInyard.POType = poDetails?.POType;

                var sourceId = outModifiedInyard.SourceId;
                var source   = sourceRepository.Get()
                               .Where(a => a.SourceId == sourceId)
                               .Include(a => a.SourceCategory).DefaultIfEmpty()
                               .Select(a => new { a.SourceDesc, a.SourceCategoryId, SourceCategoryDesc = a.SourceCategory == null ? null : a.SourceCategory.Description })
                               .FirstOrDefault();
                outModifiedInyard.SourceName         = source?.SourceDesc;
                outModifiedInyard.SourceCategoryId   = source?.SourceCategoryId ?? 0;
                outModifiedInyard.SourceCategoryDesc = source?.SourceCategoryDesc;
            }
            else
            {
                var clientId = outModifiedInyard.ClientId;
                outModifiedInyard.ClientName = customerRepository.Get()
                                               .Where(a => a.CustomerId == clientId).Select(a => a.CustomerName).FirstOrDefault();

                var haulerId = outModifiedInyard.HaulerId;
                outModifiedInyard.HaulerName = haulerRepository.Get()
                                               .Where(a => a.HaulerId == haulerId).Select(a => a.HaulerName).FirstOrDefault();

                var commodityId = outModifiedInyard.CommodityId;
                var product     = productRepository.Get()
                                  .Where(a => a.ProductId == commodityId)
                                  .Include(a => a.Category).DefaultIfEmpty()
                                  .Select(a => new { a.ProductDesc, a.CategoryId, CategoyDesc = a.Category == null ? null : a.Category.CategoryDesc })
                                  .FirstOrDefault();
                outModifiedInyard.CommodityDesc = product?.ProductDesc;
                outModifiedInyard.CategoryId    = product?.CategoryId ?? 0;
                outModifiedInyard.CategoryDesc  = product?.CategoyDesc;


                var pmId = outModifiedInyard.PaperMillId;
                outModifiedInyard.PaperMillCode = paperMillRepository.Get()
                                                  .Where(a => a.PaperMillId == pmId).Select(a => a.PaperMillCode).FirstOrDefault();
            }

            var msId = outModifiedInyard.MoistureReaderId;

            outModifiedInyard.MoistureReaderDesc = moistureReaderRepository.Get()
                                                   .Where(a => a.MoistureReaderId == msId).Select(a => a.Description).FirstOrDefault();

            var balingStation = balingStationRepository.Get().Where(a => a.Selected).Take(1).AsNoTracking()
                                .Select(a => new { a.BalingStationNum, a.BalingStationCode, a.BalingStationName }).FirstOrDefault();

            outModifiedInyard.BalingStationNum  = balingStation.BalingStationNum;
            outModifiedInyard.BalingStationCode = balingStation.BalingStationCode;
            outModifiedInyard.BalingStationName = balingStation.BalingStationName;

            var userAccountId = String.Empty;

            if (outModifiedInyard.TransactionProcess == SysUtility.Enums.TransactionProcess.WEIGH_IN ||
                outModifiedInyard.TransactionProcess == SysUtility.Enums.TransactionProcess.UPDATE_WEIGH_IN)
            {
                userAccountId = outModifiedInyard.WeigherInId;
                outModifiedInyard.WeigherInName = userAccountRepository.Get().Where(a => a.UserAccountId == userAccountId)
                                                  .Select(a => a.FullName).FirstOrDefault();
            }
            else if (outModifiedInyard.TransactionProcess == SysUtility.Enums.TransactionProcess.WEIGH_OUT ||
                     outModifiedInyard.TransactionProcess == SysUtility.Enums.TransactionProcess.UPDATE_WEIGH_OUT)
            {
                userAccountId = outModifiedInyard.WeigherOutId;
                outModifiedInyard.WeigherOutName = userAccountRepository.Get().Where(a => a.UserAccountId == userAccountId)
                                                   .Select(a => a.FullName).FirstOrDefault();
            }
            return(outModifiedInyard);
        }