public static void ReadWriteStream(TcpClient client)
        {
            try
            {
                Stream       ns = client.GetStream();
                StreamReader sr = new StreamReader(ns);
                StreamWriter sw = new StreamWriter(ns);
                sw.AutoFlush = true;

                string message = sr.ReadLine();
                string answar  = "";

                while (message != " " && message != "stop")
                {
                    Console.WriteLine("client: " + message);
                    switch (message)
                    {
                    case "GetAll":
                        Console.WriteLine(JsonConvert.SerializeObject(Beers.BeerList));
                        sw.WriteLine(JsonConvert.SerializeObject(Beers.BeerList));
                        break;

                    case "GetByID":
                        int id = Int32.Parse(sr.ReadLine());
                        answar = Beers.GetById(id).ToString();
                        Console.WriteLine(answar);
                        sw.WriteLine(answar);
                        break;

                    case "Save":
                        string JsonString = sr.ReadLine();
                        Beer   beer       = JsonConvert.DeserializeObject <Beer>(JsonString);
                        Beers.Addbeer(beer);
                        break;

                    default:
                        answar = "bad request";
                        Console.WriteLine(answar);
                        sw.WriteLine(answar);
                        break;
                    }
                    message = sr.ReadLine();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw;
            }
        }