Esempio n. 1
0
        public IActionResult Get([FromQuery] RawMaterial parameters = null)
        {
            try
            {
                var model = repository.Get(parameters)
                            .Include(a => a.Category).DefaultIfEmpty()
                            .Select(a => new
                {
                    a.RawMaterialId,
                    a.RawMaterialCode,
                    a.RawMaterialDesc,
                    a.CategoryId,
                    CategoryDesc = a.Category == null ? null : a.Category.CategoryDesc,
                    a.IsActive,
                    a.Price
                });

                return(Ok(model));
            }
            catch (Exception ex)
            {
                logger.LogError(ex.GetExceptionMessages());
                return(StatusCode(StatusCodes.Status500InternalServerError, Constants.ErrorMessages.FetchError));
            }
        }
Esempio n. 2
0
        public void DeleteRawMaterial(DeleteRawMaterialInput input)
        {
            var rawmaterial = _RawMaterialRepository.Get(input.Id);

            rawmaterial.IsDeleted = true;
            _RawMaterialRepository.Delete(rawmaterial);
        }
Esempio n. 3
0
        public void updateRelatedTableColumns(ref PurchaseTransaction 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 supplierId = model.SupplierId;

            model.SupplierName = supplierRepository.Get()
                                 .Where(a => a.SupplierId == supplierId).Select(a => a.SupplierName).FirstOrDefault();

            var rawMaterialId = model.RawMaterialId;
            var material      = rawMaterialRepository.Get()
                                .Where(a => a.RawMaterialId == rawMaterialId)
                                .Include(a => a.Category).DefaultIfEmpty()
                                .Select(a => new { a.RawMaterialDesc, a.CategoryId, CategoryDesc = a.Category == null ? null : a.Category.CategoryDesc })
                                .FirstOrDefault();

            model.RawMaterialDesc = material?.RawMaterialDesc;
            model.CategoryId      = material?.CategoryId ?? 0;
            model.CategoryDesc    = material?.CategoryDesc;

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

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

            var sourceId = model.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();

            model.SourceName         = source?.SourceDesc;
            model.SourceCategoryId   = source?.SourceCategoryId ?? 0;
            model.SourceCategoryDesc = source?.SourceCategoryDesc;

            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();
        }
Esempio n. 4
0
 public IActionResult Get(Nullable <Int64> id)
 {
     if (id == null)
     {
         return(BadRequest());
     }
     else
     {
         var model = _repository.Get(id.Value);
         return(Ok(model));
     }
 }
Esempio n. 5
0
 public bool RawMaterialExists(long id)
 {
     return(rawMaterialRepository.Get().Count(a => a.RawMaterialId == id) > 0);
 }
Esempio n. 6
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);
        }
Esempio n. 7
0
 public async Task <RawMaterial> Get(int corpClientId, long id)
 {
     return(await rawMaterialRepository.Get(corpClientId, id));
 }