private List <AbstractItem> GetAllByDiscount(int discount, BiggerSmaller biggerOrSmaller, List <AbstractItem> listToGetFrom)
        {
            List <AbstractItem> items        = listToGetFrom;
            List <AbstractItem> requiredList = new List <AbstractItem>();

            if (biggerOrSmaller == BiggerSmaller.Bigger)
            {
                for (int i = 0; i < items.Count; i++)
                {
                    if (items[i].Discount > discount)
                    {
                        requiredList.Add(items[i]);
                    }
                }
            }
            else
            {
                for (int i = 0; i < items.Count; i++)
                {
                    if (items[i].Discount < discount)
                    {
                        requiredList.Add(items[i]);
                    }
                }
            }
            return(requiredList);
        }
        private List <AbstractItem> GetAllByYear(int year, BiggerSmaller biggerOrSmaller, List <AbstractItem> listToGetFrom)
        {
            List <AbstractItem> items        = listToGetFrom;
            List <AbstractItem> requiredList = new List <AbstractItem>();

            if (biggerOrSmaller == BiggerSmaller.Bigger)
            {
                for (int i = 0; i < items.Count; i++)
                {
                    if (items[i].PrintDate.Year > year)
                    {
                        requiredList.Add(items[i]);
                    }
                }
            }
            else
            {
                for (int i = 0; i < items.Count; i++)
                {
                    if (items[i].PrintDate.Year < year)
                    {
                        requiredList.Add(items[i]);
                    }
                }
            }
            return(requiredList);
        }
        /// <summary>
        /// Search for items by given parameters, if a a paramerter is empty it will not search by the parameter.
        /// </summary>
        /// <param name="year"></param>
        /// <param name="biggerOrSmallerYear"></param>
        /// <param name="publisher"></param>
        /// <param name="writer"></param>
        /// <param name="genre"></param>
        /// <param name="discount"></param>
        /// <param name="biggerOrSmallerDisc"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public async Task <List <AbstractItem> > SearchItems(string year, BiggerSmaller biggerOrSmallerYear, string publisher, string writer, string genre, string discount, BiggerSmaller biggerOrSmallerDisc, string name)
        {
            List <AbstractItem> matchingItems = new List <AbstractItem>();
            bool isStarted = false;

            try
            {
                if (year != "")
                {
                    matchingItems = GetAllByYear(int.Parse(year), biggerOrSmallerYear, await GetAllItems());
                    isStarted     = true;
                }
                if (publisher != "")
                {
                    if (isStarted == false)
                    {
                        matchingItems = GetAllByPublisher(publisher, await GetAllItems());
                        isStarted     = true;
                    }
                    else
                    {
                        matchingItems = GetAllByPublisher(publisher, matchingItems);
                    }
                }
                if (writer != "")
                {
                    if (isStarted == false)
                    {
                        matchingItems = GetAllByAuther(writer, await GetAllItems());
                        isStarted     = true;
                    }
                    else
                    {
                        matchingItems = GetAllByAuther(writer, matchingItems);
                    }
                }
                if (genre != "")
                {
                    if (isStarted == false)
                    {
                        Genre g1 = await _genereService.GetGenre(genre);

                        matchingItems = GetAllByGenre(g1, await GetAllItems());
                        isStarted     = true;
                    }
                    else
                    {
                        Genre g1 = await _genereService.GetGenre(genre);

                        matchingItems = GetAllByGenre(g1, matchingItems);
                    }
                }
                if (discount != "")
                {
                    if (isStarted == false)
                    {
                        matchingItems = GetAllByDiscount(int.Parse(discount), biggerOrSmallerDisc, await GetAllItems());
                        isStarted     = true;
                    }
                    else
                    {
                        matchingItems = GetAllByDiscount(int.Parse(discount), biggerOrSmallerDisc, matchingItems);
                    }
                }
                if (name != "")
                {
                    if (isStarted == false)
                    {
                        matchingItems = GetAllByName(name, await GetAllItems());
                        isStarted     = true;
                    }
                    else
                    {
                        matchingItems = GetAllByName(name, matchingItems);
                    }
                }
            }
            catch (Exception e)
            {
                if (e is GeneralItemException ||
                    e is DALException)
                {
                    await SaveToLogFile(e.ToString());

                    throw new BLLGeneralException("Cannot perform a search atm try again later or call a manager");
                }
                else
                {
                    await SaveToLogFile(e.ToString());

                    throw new LibraryException("Unknown error inform a manager!");
                }
            }
            return(matchingItems);
        }