예제 #1
0
 public IActionResult Get([FromQuery] BalingStation 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));
     }
 }
        public void GenerateBaleCode(Bale model, out Bale outModel)
        {
            var product = productRepository.Get().AsNoTracking().Where(a => a.ProductId == model.ProductId).Select(a => new { a.ProductDesc, a.CategoryId }).FirstOrDefault();

            model.CategoryId  = product.CategoryId;
            model.ProductDesc = product.ProductDesc;

            var catcode = catRepository.Get().AsNoTracking().Where(a => a.CategoryId == model.CategoryId).Select(a => a.CategoryCode).FirstOrDefault();

            var bs = baleStationRepository.Get().AsNoTracking().Where(a => a.Selected).Select(a => a.BalingStationNum).FirstOrDefault();
            var mn = model.DT.GetBaleMonthLetter();
            var yr = model.DT.Year;

            if (model.BaleNum == 0)
            {
                model.BaleNum = GetLastBaleNum(model.DT, model.CategoryId) + 1;
            }

            model.BaleCode = catcode + bs + mn + yr + model.BaleNum.PadZero(4);

            outModel = model;
        }
예제 #3
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);
        }