private Task <bool> imageExists(string directory, Bitmap bitmap)
        {
            foreach (var file in Directory.EnumerateFiles(directory, "*.png", SearchOption.TopDirectoryOnly))
            {
                int      logoId;
                FileInfo fInfo = new FileInfo(file);

                if (int.TryParse(fInfo.Name.Replace(".png", "").Trim(), out logoId))
                {
                    if (logoId > 0 && logoId < 10000)
                    {
                        if (logoId == 3)
                        {
                            Console.Write(logoId);
                        }
                        using (var serverBM = new Bitmap(file))
                        {
                            if (Toolset.CompareBitmaps(bitmap, serverBM))
                            {
                                return(Task.FromResult <bool>(true));
                            }
                        }
                    }
                }
            }
            return(Task.FromResult <bool>(false));
        }
        public async Task <IHttpActionResult> FindChannelLogo(bool searchArchive = false)
        {
            string srchDir = this._activeLogoDir;

            if (searchArchive)
            {
                srchDir = this._archiveLogoDir;
            }

            var readTask = await Request.Content.ReadAsStreamAsync();

            var chLogos = new List <ChannelLogoInfo>();

            foreach (var file in Directory.EnumerateFiles(srchDir, "*.png", SearchOption.TopDirectoryOnly))
            {
                FileInfo fInfo = new FileInfo(file);

                int id;

                if (int.TryParse(fInfo.Name.Replace(".png", "").Trim(), out id))
                {
                    if (id > 0 && id < 10000)
                    {
                        using (var serverBM = new Bitmap(file))
                            using (var clientBM = new Bitmap(readTask))
                            {
                                if (Toolset.CompareBitmaps(clientBM, serverBM))
                                {
                                    var chLogo = new ChannelLogoInfo();
                                    chLogo.FileName   = fInfo.Name;
                                    chLogo.BitmapId   = id;
                                    chLogo.IsAssigned = await isAssignedAsync(id);

                                    chLogos.Add(chLogo);
                                }
                            }
                    }
                }
            }
            if (chLogos.Count > 0)
            {
                return(Ok(chLogos));
            }

            return(NotFound());
        }