コード例 #1
0
        public RestApiResult CreateList(JArray jsonList)
        {
            if (jsonList == null)
            {
                return(new RestApiResult {
                    StatusCode = HttpStatusCode.BadRequest
                });
            }

            foreach (JObject json in jsonList)
            {
                ProductInput productInputs = ProductInput.FromJson(json);
                productInputs.CreatedDate = DateTime.Now;
                ClarityDB.Instance.ProductInputs.Add(productInputs);
                //update Inventory and Product
                long productId = json.Value <long>("productId");
                long quantity  = json.Value <long>("quantity");
                long price     = json.Value <long>("price");
                UpdateInventory(productId, quantity);
            }
            ClarityDB.Instance.SaveChanges();

            return(new RestApiResult {
                StatusCode = HttpStatusCode.OK
            });
        }
コード例 #2
0
        private void CreateProductInputForInputOrder(JObject json, InputOrder inputOrder, long productId)
        {
            ProductInput productInput = ProductInput.FromJson(json);

            productInput.ProductID    = productId;
            productInput.CreatedDate  = DateTime.Now;
            productInput.InputOrderID = inputOrder.ID;
            inputOrder.ProductInputs.Add(productInput);
            //Increase quantity in Inventory
            updateInventory(productInput);
        }
コード例 #3
0
        public RestApiResult Create(JObject json)
        {
            if (json == null)
            {
                return(new RestApiResult {
                    StatusCode = HttpStatusCode.BadRequest
                });
            }

            ProductInput productInputs = ProductInput.FromJson(json);

            productInputs.CreatedDate = DateTime.Now;

            ClarityDB.Instance.ProductInputs.Add(productInputs);
            ClarityDB.Instance.SaveChanges();

            return(new RestApiResult {
                StatusCode = HttpStatusCode.OK
            });
        }
コード例 #4
0
        private void AddProductInputsFromJson(long inputOrderID, JObject json)
        {
            InputOrder inputOrder = ClarityDB.Instance.InputOrders.FirstOrDefault(x => x.ID == inputOrderID);

            var productInputsJsons = json.Value <JArray>("productInputs");

            if (productInputsJsons != null)
            {
                foreach (JObject productInputsJson in productInputsJsons)
                {
                    ProductInput productInput = ProductInput.FromJson(productInputsJson);
                    productInput.CreatedDate  = DateTime.Now;
                    productInput.InputOrderID = inputOrderID;
                    inputOrder.ProductInputs.Add(productInput);
                    //Increase quantity in Inventory
                    updateInventory(productInput);
                }
                ClarityDB.Instance.SaveChanges();
            }
        }