Ejemplo n.º 1
0
        public void CreatePurchaseOrder_VendorExists_ReturnsPurchaseOrderCreatedEvent()
        {
            /// Arrange
            // Get a create purchase order command with the vendor.
            // (By the time the command gets to the domain it's already been structurally validated.)
            var command = new CreatePurchaseOrder(
                vendorId: Guid.NewGuid(),
                lines: new List <CreatePurchaseOrderLine> {
                new CreatePurchaseOrderLine(productId: Guid.NewGuid(), quantity: 354M, measure: "EA", pricePerUnit: 4.75M),
                new CreatePurchaseOrderLine(productId: Guid.NewGuid(), quantity: 10M, measure: "EA", pricePerUnit: 24.99M)
            }
                );

            // Assume the vendor exists.
            Func <Guid, bool> getVendorExists = _ => true;

            // Get some id as the next id.
            var nextId = Guid.NewGuid();

            // Get the event we expect the domain to return.
            var expected = new PurchaseOrderCreated(
                purchaseOrderId: nextId,
                status: PurchaseOrderStatus.Unpaid,
                vendorId: command.VendorId,
                lines: command.Lines.Select(l =>
                                            new PurchaseOrderLine(l.ProductId, l.Quantity, l.Measure, l.PricePerUnit))
                );

            /// Act
            var actual = JC.CreatePurchaseOrder(getVendorExists, nextId, command);

            /// Assert
            CustomAssert.CoreValuesAreEqual(expected, actual);
        }
Ejemplo n.º 2
0
        public void CreatePurchaseOrder_VendorDoesNotExist_ReturnsExpectedError()
        {
            /// Arrange
            // Get a create purchase order command with the vendor.
            // (By the time the command gets to the domain it's already been structurally validated.)
            var command = new CreatePurchaseOrder(
                vendorId: Guid.NewGuid(),
                lines: new List <CreatePurchaseOrderLine> {
                new CreatePurchaseOrderLine(productId: Guid.NewGuid(), quantity: 354M, measure: "EA", pricePerUnit: 4.75M),
                new CreatePurchaseOrderLine(productId: Guid.NewGuid(), quantity: 10M, measure: "EA", pricePerUnit: 24.99M)
            }
                );

            // Assume the vendor does not exist.
            Func <Guid, bool> getVendorExists = _ => false;

            // Get some id as the next id.
            var nextId = Guid.NewGuid();

            // Get the error we expect the domain to return.
            var expected = new VendorDoesNotExist(command.VendorId);

            /// Act
            var actual = JC.CreatePurchaseOrder(getVendorExists, nextId, command);

            /// Assert
            CustomAssert.CoreValuesAreEqual(expected, actual);
        }
        public void AddProductToPurchaseOrder_POStatusIsPaid_ReturnsCannotAddProductsToPaidPurchaseOrderResult()
        {
            /// Arrange
            // Get a command to Add a product To a purchase order.
            var command = new AddProductToPurchaseOrder(
                purchaseOrderId: Guid.NewGuid(),
                productId: Guid.NewGuid(),
                measure: "EA",
                quantity: 14.5M
                );

            // Get a purchase order aggregate to use
            // when adding a product to a purchase order.
            var purchaseOrder = new PurchaseOrderForAddProductTask(
                purchaseOrderId: command.PurchaseOrderId,
                status: PurchaseOrderStatus.Paid,
                productIds: Enumerable.Empty <Guid>() // doesn't matter for this test
                );

            // Get a function that returns the purchase order aggregate
            // to use when adding a product to a purchase order.
            Func <Guid, PurchaseOrderForAddProductTask> getPurchaseOrder = _ => purchaseOrder;

            // Get the event we expect the domain to return.
            var expected = new CannotAddProductsToPaidPurchaseOrder(
                purchaseOrderId: command.PurchaseOrderId);

            /// Act
            var actual = JC.AddProductToPurchaseOrder(getPurchaseOrder, command);

            /// Assert
            CustomAssert.CoreValuesAreEqual(expected, actual);
        }
        public void AddProductToPurchaseOrder_POStatusIsUnpaidAndPurchaseOrderHasSameProduct_ReturnsCannotAddDuplicateProductToPurchaseOrderResult()
        {
            /// Arrange
            // Get a command to Add a product To a purchase order.
            var command = new AddProductToPurchaseOrder(
                purchaseOrderId: Guid.NewGuid(),
                productId: Guid.NewGuid(),
                measure: "EA",
                quantity: 14.5M
                );

            // Get a purchase order aggregate to use when adding a product to a purchase order,
            // making sure it already has the same product.
            var purchaseOrder = new PurchaseOrderForAddProductTask(
                purchaseOrderId: command.PurchaseOrderId,
                status: PurchaseOrderStatus.Unpaid,
                productIds: Enumerable.Empty <Guid>()
                .Append(command.ProductId)
                );

            // Get a function that returns the purchase order aggregate
            // to use when adding a product to a purchase order.
            Func <Guid, PurchaseOrderForAddProductTask> getPurchaseOrder = _ => purchaseOrder;

            // Get the event we expect the domain to return.
            var expected = new CannotAddDuplicateProductToPurchaseOrder(
                purchaseOrderId: command.PurchaseOrderId,
                productId: command.ProductId);

            /// Act
            var actual = JC.AddProductToPurchaseOrder(getPurchaseOrder, command);

            /// Assert
            CustomAssert.CoreValuesAreEqual(expected, actual);
        }
        public void RemoveProductFromPurchaseOrder_PurchaseOrderStatusIsUnPaidButPurchaseOrderDoesNotHaveProduct_ReturnsCannotRemoveProductThatIsNotOnPurchaseOrderResult()
        {
            /// Arrange
            // Get a command to remove a product from a purchase order.
            var command = new RemoveProductFromPurchaseOrder(
                purchaseOrderId: Guid.NewGuid(),
                productId: Guid.NewGuid()
                );

            // Get a purchase order aggregate to use
            // when removing a product from a purchase order,
            // and make sure that it does not have the product.
            var purchaseOrder = new PurchaseOrderForRemoveProductTask(
                purchaseOrderId: command.PurchaseOrderId,
                status: PurchaseOrderStatus.Unpaid,
                productIds: Enumerable.Empty <Guid>()
                );

            // Get a function that returns the purchase order aggregate
            // to use when removing a product from a purchase order.
            Func <Guid, PurchaseOrderForRemoveProductTask> getPurchaseOrder = _ => purchaseOrder;

            // Get the event we expect the domain to return.
            var expected = new CannotRemoveProductThatIsNotOnPurchaseOrder(
                purchaseOrderId: command.PurchaseOrderId,
                productId: command.ProductId);

            /// Act
            var actual = JC.RemoveProductFromPurchaseOrder(getPurchaseOrder, command);

            /// Assert
            CustomAssert.CoreValuesAreEqual(expected, actual);
        }
        public void RemoveProductFromPurchaseOrder_POStatusIsPaid_ReturnsCannotRemoveProductsFromPaidPurchaseOrderResult()
        {
            /// Arrange
            // Get a command to remove a product from a purchase order.
            var command = new RemoveProductFromPurchaseOrder(
                purchaseOrderId: Guid.NewGuid(),
                productId: Guid.NewGuid()
                );

            // Get a purchase order aggregate to use
            // when removing a product from a purchase order.
            var purchaseOrder = new PurchaseOrderForRemoveProductTask(
                purchaseOrderId: command.PurchaseOrderId,
                status: PurchaseOrderStatus.Paid,
                productIds: Enumerable.Empty <Guid>() // doesn't matter for this test
                );

            // Get a function that returns the purchase order aggregate
            // to use when removing a product from a purchase order.
            Func <Guid, PurchaseOrderForRemoveProductTask> getPurchaseOrder = _ => purchaseOrder;

            // Get the event we expect the domain to return.
            var expected = new CannotRemoveProductsFromPaidPurchaseOrder(
                purchaseOrderId: command.PurchaseOrderId);

            /// Act
            var actual = JC.RemoveProductFromPurchaseOrder(getPurchaseOrder, command);

            /// Assert
            CustomAssert.CoreValuesAreEqual(expected, actual);
        }
        public void AddProductToPurchaseOrder_PurchaseOrderStatusIsUnPaid_ReturnsProductAddedToPurchaseOrderResult()
        {
            /// Arrange
            // Get a command to add a product to a purchase order.
            var command = new AddProductToPurchaseOrder(
                purchaseOrderId: Guid.NewGuid(),
                productId: Guid.NewGuid(),
                measure: "EA",
                quantity: 3.56M
                );

            // Get a purchase order aggregate to use
            // when adding a product to a purchase order,
            // and give it some other product.
            var purchaseOrder = new PurchaseOrderForAddProductTask(
                purchaseOrderId: command.PurchaseOrderId,
                status: PurchaseOrderStatus.Unpaid,
                productIds: Enumerable.Empty <Guid>()
                .Append(Guid.NewGuid())
                );

            // Get a function that returns the purchase order aggregate
            // to use when adding a product to a purchase order.
            Func <Guid, PurchaseOrderForAddProductTask> getPurchaseOrder = _ => purchaseOrder;

            // Get the event we expect the domain to return.
            var expected = new ProductAddedToPurchaseOrder(
                purchaseOrderId: command.PurchaseOrderId,
                productId: command.ProductId,
                measure: command.Measure,
                quantity: command.Quantity);

            /// Act
            var actual = JC.AddProductToPurchaseOrder(getPurchaseOrder, command);

            /// Assert
            CustomAssert.CoreValuesAreEqual(expected, actual);
        }
Ejemplo n.º 8
0
        public void TestJCCarryDisabled()
        {
            SignalBus     signals = new SignalBus();
            FlagsRegister flags   = new FlagsRegister(null, signals, null);

            flags.Value = 0;
            Operation op = new JC(null, signals, flags);

            signals.Reset();
            op.Step0();
            Assert.IsTrue(signals.MI);
            Assert.IsTrue(signals.CO);

            signals.Reset();
            op.Step1();
            Assert.IsTrue(signals.RO);
            Assert.IsTrue(signals.II);
            Assert.IsTrue(signals.CE);

            signals.Reset();
            op.Step2();
            Assert.IsFalse(signals.IO);
            Assert.IsFalse(signals.J);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Test per l'algoritme de JC
        /// </summary>
        public static void TestJC()
        {
            JC     a         = new JC(1, "abcdefghijklmnopqrstuvwxyz");
            string txtXifrat = a.Xifrar("patata");
            string b         = "holaaa";

            Console.WriteLine(b[0]);

            if (txtXifrat != "qbubub")
            {
                throw new Exception("Error text incorrecte.");
            }
            Console.WriteLine(a.Desxifrar(txtXifrat));
            txtXifrat = a.Xifrar("xyz");

            if (txtXifrat != "yza")
            {
                throw new Exception("Error text incorrecte.");
            }

            Console.WriteLine(a.Desxifrar(txtXifrat));

            JC bc = new JC(1, "abcdefghijklmnopqrstuvwxyz");
        }
Ejemplo n.º 10
0
 static FEData()
 {
     var stArray = new ST[2, 20];
     stArray[0, 3] = ST.ERR;
     stArray[0, 4] = ST.ST1;
     stArray[0, 5] = ST.ST1;
     stArray[0, 6] = ST.ST1;
     stArray[0, 7] = ST.ST1;
     stArray[0, 8] = ST.ERR;
     stArray[0, 12] = ST.ST1;
     stArray[0, 13] = ST.ST1;
     stArray[0, 14] = ST.ST1;
     stArray[0, 15] = ST.ST1;
     stArray[0, 16] = ST.ST1;
     stArray[0, 17] = ST.ERR;
     stArray[0, 18] = ST.ERR;
     stArray[1, 0] = ST.ERR;
     stArray[1, 1] = ST.ERR;
     stArray[1, 17] = ST.ERR;
     stArray[1, 18] = ST.ERR;
     stArray[1, 19] = ST.ERR;
     SJisNextState = stArray;
     EucJpNextState = new ST[4, 20] {
         {
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ERR,
             ST.ERR,
             ST.ST2,
             ST.ST3,
             ST.ERR,
             ST.ERR,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ERR,
             ST.ST0
         }, {
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ERR,
             ST.ERR
         }, {
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR
         }, {
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ERR,
             ST.ERR
         }
     };
     GbkWanNextState = new ST[2, 20] {
         {
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ERR,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ERR,
             ST.ST0
         }, {
             ST.ERR,
             ST.ERR,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ERR,
             ST.ERR
         }
     };
     EucKrCnNextState = new ST[2, 20] {
         {
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ERR,
             ST.ST0
         }, {
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ERR,
             ST.ERR
         }
     };
     Big5NextState = new ST[2, 20] {
         {
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ERR,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ERR,
             ST.ST0
         }, {
             ST.ERR,
             ST.ERR,
             ST.ST0,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ERR,
             ST.ERR
         }
     };
     Utf8NextState = new ST[6, 20] {
         {
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ST1,
             ST.ST4,
             ST.ST2,
             ST.ST5,
             ST.ST3,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ST0
         }, {
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ST0,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR
         }, {
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ST1,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR
         }, {
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ST2,
             ST.ST2,
             ST.ST2,
             ST.ST2,
             ST.ST2,
             ST.ST2,
             ST.ST2,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR
         }, {
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ST1,
             ST.ST1,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR
         }, {
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ST2,
             ST.ST2,
             ST.ST2,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR,
             ST.ERR
         }
     };
     var jcArray = new JC[128];
     jcArray[14] = JC.so;
     jcArray[15] = JC.si;
     jcArray[27] = JC.esc;
     jcArray[36] = JC.dlr;
     jcArray[38] = JC.amp;
     jcArray[40] = JC.opr;
     jcArray[41] = JC.cpr;
     jcArray[64] = JC.at;
     jcArray[66] = JC.tkB;
     jcArray[67] = JC.tkC;
     jcArray[68] = JC.tkD;
     jcArray[72] = JC.tkH;
     jcArray[73] = JC.tkI;
     jcArray[74] = JC.tkJ;
     JisCharClass = jcArray;
     var jsArray = new JS[7, 15];
     jsArray[0, 1] = JS.CNTA;
     jsArray[0, 3] = JS.S1;
     jsArray[1, 4] = JS.S2;
     jsArray[1, 5] = JS.S6;
     jsArray[1, 6] = JS.S5;
     jsArray[2, 6] = JS.S3;
     jsArray[2, 7] = JS.S4;
     jsArray[2, 8] = JS.CNTJ;
     jsArray[2, 9] = JS.CNTJ;
     jsArray[3, 11] = JS.CNTJ;
     jsArray[4, 10] = JS.CNTK;
     jsArray[5, 9] = JS.CNTJ;
     jsArray[5, 12] = JS.CNTJ;
     jsArray[5, 13] = JS.CNTJ;
     jsArray[5, 14] = JS.CNTJ;
     jsArray[6, 8] = JS.CNTJ;
     JisEscNextState = jsArray;
 }
Ejemplo n.º 11
0
        public void loadtest()
        {
            // Get a MongoClient.
            var client = new MongoClient("mongodb://localhost:27017");

            Func <Guid, bool> getVendorExists = _ => true;
            Func <Guid, PurchaseOrderForAddProductTask>    getPurchaseOrderForAddProductTask    = purchaseOrderId => MongoDBEventStore.GetPurchaseOrderForAddProductTask(client, purchaseOrderId);
            Func <Guid, PurchaseOrderForRemoveProductTask> getPurchaseOrderForRemoveProductTask = purchaseOrderId => MongoDBEventStore.GetPurchaseOrderForRemoveProductTask(client, purchaseOrderId);
            Func <Guid> nextId = Guid.NewGuid;

            var create = new CreatePurchaseOrder(
                vendorId: nextId(),
                lines: new List <CreatePurchaseOrderLine>
            {
                new CreatePurchaseOrderLine(
                    productId: nextId(),
                    quantity: 14.5M,
                    measure: "FT",
                    pricePerUnit: 2.8M),
                new CreatePurchaseOrderLine(
                    productId: nextId(),
                    quantity: 1.5M,
                    measure: "YD",
                    pricePerUnit: 235.82M)
            });


            Guid purchaseOrderId = nextId();

            var createResult = JC.CreatePurchaseOrder(
                getVendorExists: getVendorExists,
                nextId: purchaseOrderId,
                command: create);

            MongoDBEventStore.Save(client, nextId(), createResult);

            var expected = getPurchaseOrderForAddProductTask(purchaseOrderId);

            var productId = Guid.NewGuid();

            // Put 10000 events in the store for this purchase order.
            for (int i = 0; i < 5000; i++)
            {
                var addResult = new ProductAddedToPurchaseOrder(
                    purchaseOrderId: purchaseOrderId,
                    productId: productId,
                    measure: "EA",
                    quantity: i);

                MongoDBEventStore.Save(client, nextId(), addResult);

                var removeResult = new ProductRemovedFromPurchaseOrder(
                    purchaseOrderId: purchaseOrderId,
                    productId: productId);

                MongoDBEventStore.Save(client, nextId(), removeResult);
            }

            // Now for the time trial
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            var actual = getPurchaseOrderForAddProductTask(purchaseOrderId);

            stopwatch.Stop();

            CustomAssert.CoreValuesAreEqual(expected, actual);
            Assert.Equal(0, stopwatch.ElapsedMilliseconds);
        }
Ejemplo n.º 12
0
        public string GetPackages(string token)
        {
            //public string Get(string token)
            //{

            token = TokenManager.readToken(HttpContext.Current.Request);
            var strP = TokenManager.GetPrincipal(token);

            if (strP != "0") //invalid authorization
            {
                return(TokenManager.GenerateToken(strP));
            }
            else
            {
                try
                {
                    List <int> noUpdateList = new List <int>();

                    using (incposdbEntities entity = new incposdbEntities())
                    {
                        noUpdateList = canNotUpdatePack();
                        var List = (from I in entity.items
                                    join C in entity.categories on I.categoryId equals C.categoryId into JC

                                    from CC in JC.DefaultIfEmpty()
                                    where I.type == "p"

                                    select new ItemModel()
                        {
                            itemId = I.itemId,
                            code = I.code,
                            name = I.name,
                            details = I.details,
                            type = I.type,
                            image = I.image,
                            taxes = I.taxes,
                            isActive = I.isActive,
                            min = I.min,
                            max = I.max,
                            categoryId = I.categoryId,

                            parentId = I.parentId,
                            createDate = I.createDate,
                            updateDate = I.updateDate,
                            createUserId = I.createUserId,
                            updateUserId = I.updateUserId,
                            minUnitId = I.minUnitId,
                            maxUnitId = I.maxUnitId,
                            categoryName = CC.name,

                            canDelete = true,
                            canUpdate = noUpdateList.Contains(I.itemId) ? false : true,
                        }).ToList();


                        return(TokenManager.GenerateToken(List));
                    }
                }
                catch
                {
                    return(TokenManager.GenerateToken("0"));
                }
            }


            //var re = Request;
            //var headers = re.Headers;
            //string token = "";
            //bool canDelete = false;

            //if (headers.Contains("APIKey"))
            //{
            //    token = headers.GetValues("APIKey").First();
            //}
            //Validation validation = new Validation();
            //bool valid = validation.CheckApiKey(token);

            //if (valid) // APIKey is valid
            //{
            //    using (incposdbEntities entity = new incposdbEntities())
            //    {

            //        //
            //        /*
            //        var templist = (from S in entity.packages
            //                        join IU in entity.itemsUnits on S.parentIUId equals IU.itemUnitId

            //                        select new
            //                        {
            //                            IU.itemId

            //                        }
            //                      ).ToList();
            //        List<int> listcontain = new List<int>();
            //        foreach (var row in templist)
            //        {
            //            listcontain.Add(int.Parse(row.itemId.ToString()));
            //        }
            //        */
            //        var List = (from I in entity.items
            //                    join C in entity.categories on I.categoryId equals C.categoryId into JC

            //                    from CC in JC.DefaultIfEmpty()
            //                    where I.type == "p"

            //                    select new ItemModel()
            //                    {
            //                        itemId = I.itemId,
            //                        code = I.code,
            //                        name = I.name,
            //                        details = I.details,
            //                        type = I.type,
            //                        image = I.image,
            //                        taxes = I.taxes,
            //                        isActive = I.isActive,
            //                        min = I.min,
            //                        max = I.max,
            //                        categoryId = I.categoryId,

            //                        parentId = I.parentId,
            //                        createDate = I.createDate,
            //                        updateDate = I.updateDate,
            //                        createUserId = I.createUserId,
            //                        updateUserId = I.updateUserId,
            //                        minUnitId = I.minUnitId,
            //                        maxUnitId = I.maxUnitId,
            //                        categoryName = CC.name,

            //                        canDelete = true,



            //                    }).ToList();



            //        if (List == null)
            //            return NotFound();
            //        else
            //            return Ok(List);
            //    }
            //}
            ////else
            //return NotFound();
        }