using System.Collections.Generic;
using System.Linq;

namespace TestDemo
{
    public class ViewModel
    {
        
        public List<books> BuildBooks()
        {
            try
            {
                BaseModel.BaseConnect = new EntitiesDB();
                List<books> books = BaseModel.BaseConnect.books.ToList();
                List<books> booksReturn = new List<books>();

                foreach (books book in books)
                {
                    if (book.count_in_stock > 5)
                    {
                        book.CountInStock = "Много";

                    }
                    else if (book.count_in_stock <= 0)
                    {
                        book.CountInStock = "Нет";
                    }
                    else
                    {
                        book.CountInStock = book.count_in_stock.ToString();
                    }
                    if (book.count_in_shop > 5)
                    {
                        book.CountInMagazine = "Много";

                    }
                    else if (book.count_in_shop <= 0)
                    {
                        book.CountInMagazine = "Нет";
                    }
                    else
                    {
                        book.CountInMagazine = book.count_in_shop.ToString();
                    }


                }



                return books;
            }
            catch
            {
                return null;
            }
        }
    }

}
