Example #1
0
        private static void ListItems(string codesFilePath, string targetCompany, string targetItem)
        {
            List <string> validSN    = new List <string>();
            List <string> invalidHex = new List <string>();

            string[] codeList = File.ReadAllLines(codesFilePath);

            foreach (var code in codeList)
            {
                SGTIN96Decoder sgtin96Decoder = new SGTIN96Decoder(code);
                if (sgtin96Decoder.CodeIsValid)
                {
                    if (sgtin96Decoder.CompanyCode == targetCompany && sgtin96Decoder.ItemCode == targetItem)
                    {
                        validSN.Add(sgtin96Decoder.SerialNumber);
                    }
                }
                else
                {
                    invalidHex.Add(code);
                }
            }

            PrintList("Invalid tags:", invalidHex);
            PrintList("Founded serials:", validSN);
        }
        public HttpResponseMessage Get(string hex)
        {
            SGTIN96Decoder sgtin96Decoder = new SGTIN96Decoder(hex);

            if (sgtin96Decoder.CodeIsValid)
            {
                return(Request.CreateResponse <SGTIN96Decoder>(HttpStatusCode.OK, sgtin96Decoder));
            }
            else
            {
                return(Request.CreateResponse <object>(HttpStatusCode.BadRequest, new { message = "Tag is not valid" }));
            }
        }