public IHttpActionResult GetReceiptOrderItem(int id)
        {
            ReceiptOrderItem receiptOrderItem = db.ReceiptOrderItems.Find(id);

            if (receiptOrderItem == null)
            {
                return(NotFound());
            }

            return(Ok(receiptOrderItem));
        }
        public IHttpActionResult DeleteReceiptOrderItem(int id)
        {
            ReceiptOrderItem receiptOrderItem = db.ReceiptOrderItems.Find(id);

            if (receiptOrderItem == null)
            {
                return(NotFound());
            }
            db.ReceiptOrderItems.Remove(receiptOrderItem);
            db.SaveChanges();
            return(Ok(receiptOrderItem));
        }
        public IHttpActionResult PostReceiptOrderItem(ReceiptOrderItem receiptOrderItem)
        {
            var    pageName = Request.RequestUri.LocalPath.getRouteName();
            Object obj      = null;
            var    UserId   = 0;

            if (Request.Headers.Contains("Email"))
            {
                var email = ((string[])(Request.Headers.GetValues("Email")))[0].ToString();
                UserId = db.Users.Where(x => x.IsActive == true && x.Email.Contains(email)).FirstOrDefault().Id;
            }
            ReceiptOrderItem model = new ReceiptOrderItem();

            model.Cost01     = receiptOrderItem.Cost01;
            model.Cost02     = receiptOrderItem.Cost02;
            model.Cost03     = receiptOrderItem.Cost03;
            model.Cost04     = receiptOrderItem.Cost04;
            model.Cost05     = receiptOrderItem.Cost05;
            model.Cost06     = receiptOrderItem.Cost06;
            model.Cost07     = receiptOrderItem.Cost07;
            model.Cost08     = receiptOrderItem.Cost08;
            model.Cost09     = receiptOrderItem.Cost09;
            model.Cost10     = receiptOrderItem.Cost10;
            model.Cost11     = receiptOrderItem.Cost11;
            model.Cost12     = receiptOrderItem.Cost12;
            model.Cost13     = receiptOrderItem.Cost13;
            model.Cost14     = receiptOrderItem.Cost14;
            model.Cost15     = receiptOrderItem.Cost15;
            model.Cost16     = receiptOrderItem.Cost16;
            model.Cost17     = receiptOrderItem.Cost17;
            model.Cost18     = receiptOrderItem.Cost18;
            model.Cost19     = receiptOrderItem.Cost19;
            model.Cost20     = receiptOrderItem.Cost20;
            model.Cost21     = receiptOrderItem.Cost21;
            model.Cost22     = receiptOrderItem.Cost22;
            model.Cost23     = receiptOrderItem.Cost23;
            model.Cost24     = receiptOrderItem.Cost24;
            model.Cost25     = receiptOrderItem.Cost25;
            model.Cost26     = receiptOrderItem.Cost26;
            model.Cost27     = receiptOrderItem.Cost27;
            model.Cost28     = receiptOrderItem.Cost28;
            model.Cost29     = receiptOrderItem.Cost29;
            model.Cost30     = receiptOrderItem.Cost30;
            model.Quantity01 = receiptOrderItem.Quantity01;
            model.Quantity02 = receiptOrderItem.Quantity02;
            model.Quantity03 = receiptOrderItem.Quantity03;
            model.Quantity04 = receiptOrderItem.Quantity04;
            model.Quantity05 = receiptOrderItem.Quantity05;
            model.Quantity06 = receiptOrderItem.Quantity06;
            model.Quantity07 = receiptOrderItem.Quantity07;
            model.Quantity08 = receiptOrderItem.Quantity08;
            model.Quantity09 = receiptOrderItem.Quantity09;
            model.Quantity10 = receiptOrderItem.Quantity10;
            model.Quantity11 = receiptOrderItem.Quantity11;
            model.Quantity12 = receiptOrderItem.Quantity12;
            model.Quantity13 = receiptOrderItem.Quantity13;
            model.Quantity14 = receiptOrderItem.Quantity14;
            model.Quantity15 = receiptOrderItem.Quantity15;
            model.Quantity16 = receiptOrderItem.Quantity16;
            model.Quantity17 = receiptOrderItem.Quantity17;
            model.Quantity18 = receiptOrderItem.Quantity18;
            model.Quantity19 = receiptOrderItem.Quantity19;
            model.Quantity20 = receiptOrderItem.Quantity20;
            model.Quantity21 = receiptOrderItem.Quantity21;
            model.Quantity22 = receiptOrderItem.Quantity22;
            model.Quantity23 = receiptOrderItem.Quantity23;
            model.Quantity24 = receiptOrderItem.Quantity24;
            model.Quantity25 = receiptOrderItem.Quantity25;
            model.Quantity26 = receiptOrderItem.Quantity26;
            model.Quantity27 = receiptOrderItem.Quantity27;
            model.Quantity28 = receiptOrderItem.Quantity28;
            model.Quantity29 = receiptOrderItem.Quantity29;
            model.Quantity30 = receiptOrderItem.Quantity30;
            model.IsActive   = true;
            var Total = model.Quantity01 * model.Cost01 + model.Quantity02 * model.Cost02 +
                        model.Quantity03 * model.Cost03 + model.Quantity04 * model.Cost04 +
                        model.Quantity05 * model.Cost05 + model.Quantity06 * model.Cost06 +
                        model.Quantity07 * model.Cost07 + model.Quantity08 * model.Cost08 +
                        model.Quantity09 * model.Cost09 + model.Quantity10 * model.Cost10 +
                        model.Quantity11 * model.Cost11 + model.Quantity12 * model.Cost12 +
                        model.Quantity13 * model.Cost13 + model.Quantity14 * model.Cost14 +
                        model.Quantity15 * model.Cost15 + model.Quantity16 * model.Cost16 +
                        model.Quantity17 * model.Cost17 + model.Quantity18 * model.Cost18 +
                        model.Quantity19 * model.Cost19 + model.Quantity20 * model.Cost20 +
                        model.Quantity21 * model.Cost21 + model.Quantity22 * model.Cost22 +
                        model.Quantity23 * model.Cost23 + model.Quantity24 * model.Cost24 +
                        model.Quantity25 * model.Cost25 + model.Quantity26 * model.Cost26 +
                        model.Quantity27 * model.Cost27 + model.Quantity28 * model.Cost28 +
                        model.Quantity29 * model.Cost29 + model.Quantity30 * model.Cost30;

            model.ProductId      = receiptOrderItem.ProductId;
            model.ReceiptOrderId = receiptOrderItem.ReceiptOrderId;
            // model.ProductStyleId = receiptOrderItem.ProductStyleId;
            model.SalesCost = Total ?? 0;
            db.ReceiptOrderItems.Add(model);
            db.SaveChanges();
            var receipt     = db.ReceiptOrderItems.Where(x => x.IsActive == true).ToList().LastOrDefault();
            var stockInvent = db.StockInventories.Where(x => x.IsActive == true && x.ProductID == receipt.ProductId).FirstOrDefault();

            if (stockInvent != null)
            {
                var stock = db.StockInventories.Where(x => x.IsActive == true && x.ProductID == receipt.ProductId).FirstOrDefault();
                stock.Quantity01 = stock.Quantity01 + receipt.Quantity01;
                stock.Quantity02 = stock.Quantity02 + receipt.Quantity02;
                stock.Quantity03 = stock.Quantity03 + receipt.Quantity03;
                stock.Quantity04 = stock.Quantity04 + receipt.Quantity04;
                stock.Quantity05 = stock.Quantity05 + receipt.Quantity05;
                stock.Quantity06 = stock.Quantity06 + receipt.Quantity06;
                stock.Quantity07 = stock.Quantity07 + receipt.Quantity07;
                stock.Quantity08 = stock.Quantity08 + receipt.Quantity08;
                stock.Quantity09 = stock.Quantity09 + receipt.Quantity09;
                stock.Quantity10 = stock.Quantity10 + receipt.Quantity10;
                stock.Quantity11 = stock.Quantity11 + receipt.Quantity11;
                stock.Quantity12 = stock.Quantity12 + receipt.Quantity12;
                stock.Quantity13 = stock.Quantity13 + receipt.Quantity13;
                stock.Quantity14 = stock.Quantity14 + receipt.Quantity14;
                stock.Quantity15 = stock.Quantity15 + receipt.Quantity15;
                stock.Quantity16 = stock.Quantity16 + receipt.Quantity16;
                stock.Quantity17 = stock.Quantity17 + receipt.Quantity17;
                stock.Quantity18 = stock.Quantity18 + receipt.Quantity18;
                stock.Quantity19 = stock.Quantity19 + receipt.Quantity19;
                stock.Quantity20 = stock.Quantity20 + receipt.Quantity20;
                stock.Quantity21 = stock.Quantity21 + receipt.Quantity21;
                stock.Quantity22 = stock.Quantity22 + receipt.Quantity22;
                stock.Quantity23 = stock.Quantity23 + receipt.Quantity23;
                stock.Quantity24 = stock.Quantity24 + receipt.Quantity24;
                stock.Quantity25 = stock.Quantity25 + receipt.Quantity25;
                stock.Quantity26 = stock.Quantity26 + receipt.Quantity26;
                stock.Quantity27 = stock.Quantity27 + receipt.Quantity27;
                stock.Quantity28 = stock.Quantity28 + receipt.Quantity28;
                stock.Quantity29 = stock.Quantity29 + receipt.Quantity29;
                stock.Quantity30 = stock.Quantity30 + receipt.Quantity30;
                db.SaveChanges();
            }
            else
            {
                StockInventory stock = new StockInventory();
                stock.Quantity01 = receipt.Quantity01;
                stock.Quantity02 = receipt.Quantity02;
                stock.Quantity03 = receipt.Quantity03;
                stock.Quantity04 = receipt.Quantity04;
                stock.Quantity05 = receipt.Quantity05;
                stock.Quantity06 = receipt.Quantity06;
                stock.Quantity07 = receipt.Quantity07;
                stock.Quantity08 = receipt.Quantity08;
                stock.Quantity09 = receipt.Quantity09;
                stock.Quantity10 = receipt.Quantity10;
                stock.Quantity11 = receipt.Quantity11;
                stock.Quantity12 = receipt.Quantity12;
                stock.Quantity13 = receipt.Quantity13;
                stock.Quantity14 = receipt.Quantity14;
                stock.Quantity15 = receipt.Quantity15;
                stock.Quantity16 = receipt.Quantity16;
                stock.Quantity17 = receipt.Quantity17;
                stock.Quantity18 = receipt.Quantity18;
                stock.Quantity19 = receipt.Quantity19;
                stock.Quantity20 = receipt.Quantity20;
                stock.Quantity21 = receipt.Quantity21;
                stock.Quantity22 = receipt.Quantity22;
                stock.Quantity23 = receipt.Quantity23;
                stock.Quantity24 = receipt.Quantity24;
                stock.Quantity25 = receipt.Quantity25;
                stock.Quantity26 = receipt.Quantity26;
                stock.Quantity27 = receipt.Quantity27;
                stock.Quantity28 = receipt.Quantity28;
                stock.Quantity29 = receipt.Quantity29;
                stock.Quantity30 = receipt.Quantity30;
                stock.ProductID  = receipt.ProductId;
                stock.LogId      = receipt.LogId;
                stock.IsActive   = receipt.IsActive;
                db.StockInventories.Add(stock);
                db.SaveChanges();
            }

            return(Ok(true));
        }