コード例 #1
0
        static private void AllProductsOfUser()
        {
            var products = productDAL.GetAll();

            foreach (var item in products.Where(x => x.UserId == currentUser.Id))
            {
                Console.WriteLine($"{item.Id} {item.ProductName}");
            }

            Console.WriteLine("\n Select id of product: ");
            var id      = Console.ReadLine();
            var product = products.Where(x => x.UserId == currentUser.Id).First(x => x.Id == int.Parse(id));

            Console.WriteLine("Enter responce for this product: ");
            string responce = Console.ReadLine();

            if (product.ResponceId != null)
            {
                var resp = responceDAL.Add(new ResponceDTO()
                {
                    Responce = responce,
                });
                var myResponce = responceDAL.GetAll().First(x => x.Responce == resp.Responce);
                productDAL.AddResponceId(product.Id.ToString(), myResponce.Id.ToString());
            }
        }