コード例 #1
0
        public void UpdateIsRequestedProductionOrder(List <string> productionOrderIds, string context)
        {
            string productionOrderUri;

            if (context == "DELETE")
            {
                productionOrderUri = "sales/production-orders/update-requested-false";
            }
            else
            {
                productionOrderUri = "sales/production-orders/update-requested-true";
            }

            _ = new
            {
                context,
                ids = productionOrderIds
            };

            IHttpServiceRepository httpClient = (IHttpServiceRepository)_serviceProvider.GetService(typeof(IHttpServiceRepository));

            var response = httpClient.PutAsync($"{APIEndpoint.Sales}{productionOrderUri}", new StringContent(JsonConvert.SerializeObject(productionOrderIds).ToString(), Encoding.UTF8, General.JsonMediaType)).Result;

            response.EnsureSuccessStatusCode();
        }
コード例 #2
0
        public void UpdateIsCompletedProductionOrder(string productionOrderId)
        {
            string productionOrderUri = "sales/production-orders/update-iscompleted-true";

            IHttpServiceRepository httpClient = (IHttpServiceRepository)this._serviceProvider.GetService(typeof(IHttpServiceRepository));

            var response = httpClient.PutAsync($"{APIEndpoint.Sales}{productionOrderUri}", new StringContent(productionOrderId, Encoding.UTF8, General.JsonMediaType)).Result;

            response.EnsureSuccessStatusCode();
        }
コード例 #3
0
        public void UpdateDistributedQuantityProductionOrder(List <SppParams> contextAndIds)
        {
            string productionOrderUri = "sales/production-orders/update-distributed-quantity";

            _ = new
            {
                data = contextAndIds
            };

            IHttpServiceRepository httpClient = (IHttpServiceRepository)this._serviceProvider.GetService(typeof(IHttpServiceRepository));
            var response = httpClient.PutAsync($"{APIEndpoint.Sales}{productionOrderUri}", new StringContent(JsonConvert.SerializeObject(contextAndIds).ToString(), Encoding.UTF8, General.JsonMediaType)).Result;

            response.EnsureSuccessStatusCode();
        }
        public async Task <int> CreateInventoryDocument(StockTransferNote Model, string Type, string Context)
        {
            StockTransferNoteViewModel ViewModel = MapToViewModel(Model);

            IHttpServiceRepository httpClient = (IHttpServiceRepository)this.ServiceProvider.GetService(typeof(IHttpServiceRepository));

            /* Create Inventory Document */
            List <InventoryDocumentItem> inventoryDocumentItems = new List <InventoryDocumentItem>();

            foreach (StockTransferNoteItemViewModel stni in ViewModel.StockTransferNoteItems)
            {
                InventoryDocumentItem inventoryDocumentItem = new InventoryDocumentItem
                {
                    ProductId   = stni.Summary.ProductId,
                    ProductCode = stni.Summary.ProductCode,
                    ProductName = stni.Summary.ProductName,
                    Quantity    = stni.TransferedQuantity != null ? (double)stni.TransferedQuantity : 0,
                    UomId       = stni.Summary.UomId,
                    UomUnit     = stni.Summary.Uom
                };

                inventoryDocumentItems.Add(inventoryDocumentItem);
            }

            InventoryDocument inventoryDocument = new InventoryDocument
            {
                Date          = DateTimeOffset.UtcNow,
                ReferenceNo   = Model.ReferenceNo,
                ReferenceType = Model.ReferenceType,
                Type          = Type,
                StorageId     = string.Equals(Context.ToUpper(), "CREATE") || string.Equals(Context.ToUpper(), "DELETE-SOURCE") ? int.Parse(Model.SourceStorageId) : int.Parse(Model.TargetStorageId),
                StorageCode   = string.Equals(Context.ToUpper(), "CREATE") || string.Equals(Context.ToUpper(), "DELETE-SOURCE") ? Model.SourceStorageCode : Model.TargetStorageCode,
                StorageName   = string.Equals(Context.ToUpper(), "CREATE") || string.Equals(Context.ToUpper(), "DELETE-SOURCE") ? Model.SourceStorageName : Model.TargetStorageName,
                Items         = inventoryDocumentItems
            };

            var inventoryDocumentFacade = ServiceProvider.GetService <IInventoryDocumentRepository>();

            return(await inventoryDocumentFacade.Create(inventoryDocument));
        }
コード例 #5
0
        public async Task <int> CreateInventoryDocument(MaterialDistributionNote model, string type)
        {
            string storageURI = "master/storages";
            string uomURI     = "master/uoms";

            IHttpServiceRepository httpClient = (IHttpServiceRepository)_serviceProvider.GetService(typeof(IHttpServiceRepository));
            /* Get UOM */
            Dictionary <string, object> filterUom = new Dictionary <string, object> {
                { "Unit", "MTR" }
            };
            var responseUom = httpClient.GetAsync($@"{APIEndpoint.Core}{uomURI}?filter=" + JsonConvert.SerializeObject(filterUom)).Result.Content.ReadAsStringAsync();
            Dictionary <string, object> resultUom = JsonConvert.DeserializeObject <Dictionary <string, object> >(responseUom.Result);
            var jsonUom = resultUom.Single(p => p.Key.Equals("data")).Value;
            Dictionary <string, object> Uom = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(jsonUom.ToString())[0];

            /* Get Storage */
            var storageName = model.UnitName.Equals("PRINTING") ? "Warehouse Here Printing" : "Warehouse Here Finishing";
            Dictionary <string, object> filterStorage = new Dictionary <string, object> {
                { "name", storageName }
            };
            var responseStorage = httpClient.GetAsync($@"{APIEndpoint.Core}{storageURI}?filter=" + JsonConvert.SerializeObject(filterStorage)).Result.Content.ReadAsStringAsync();
            Dictionary <string, object> resultStorage = JsonConvert.DeserializeObject <Dictionary <string, object> >(responseStorage.Result);
            var jsonStorage = resultStorage.Single(p => p.Key.Equals("data")).Value;
            Dictionary <string, object> storage = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(jsonStorage.ToString())[0];

            /* Create Inventory Document */
            List <InventoryDocumentItem>          inventoryDocumentItems = new List <InventoryDocumentItem>();
            List <MaterialDistributionNoteDetail> mdnds = new List <MaterialDistributionNoteDetail>();

            foreach (MaterialDistributionNoteItem mdni in model.MaterialDistributionNoteItems)
            {
                mdnds.AddRange(mdni.MaterialDistributionNoteDetails);
            }

            foreach (MaterialDistributionNoteDetail mdnd in mdnds)
            {
                InventoryDocumentItem inventoryDocumentItem = new InventoryDocumentItem
                {
                    ProductId     = int.Parse(mdnd.ProductId),
                    ProductCode   = mdnd.ProductCode,
                    ProductName   = mdnd.ProductName,
                    Quantity      = mdnd.ReceivedLength,
                    StockPlanning = model.Type != "RE-GRADING" ? (mdnd.DistributedLength == 0 ? mdnd.MaterialRequestNoteItemLength - mdnd.ReceivedLength : mdnd.ReceivedLength * -1) : mdnd.ReceivedLength * -1,
                    UomId         = int.Parse(Uom["Id"].ToString()),
                    UomUnit       = Uom["Unit"].ToString()
                };

                inventoryDocumentItems.Add(inventoryDocumentItem);
            }

            List <InventoryDocumentItem> list = inventoryDocumentItems
                                                .GroupBy(m => new { m.ProductId, m.ProductCode, m.ProductName })
                                                .Select(s => new InventoryDocumentItem
            {
                ProductId     = s.First().ProductId,
                ProductCode   = s.First().ProductCode,
                ProductName   = s.First().ProductName,
                Quantity      = s.Sum(d => d.Quantity),
                StockPlanning = s.Sum(d => d.StockPlanning),
                UomUnit       = s.First().UomUnit,
                UomId         = s.First().UomId
            }).ToList();

            InventoryDocument inventoryDocument = new InventoryDocument
            {
                Date          = DateTimeOffset.UtcNow,
                ReferenceNo   = model.No,
                ReferenceType = "Bon introduction to Here",
                Type          = type,
                StorageId     = int.Parse(storage["Id"].ToString()),
                StorageCode   = storage["Code"].ToString(),
                StorageName   = storage["Name"].ToString(),
                Items         = list
            };

            var inventoryDocumentFacade = _serviceProvider.GetService <IInventoryDocumentRepository>();

            return(await inventoryDocumentFacade.Create(inventoryDocument));
        }
コード例 #6
0
 public RoadStatusRepository(IHttpServiceRepository httpServiceRepository)
 {
     _httpServiceRepository = httpServiceRepository ?? throw new ArgumentNullException("httpServiceRepository");
 }