Example #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());
            }
        }
Example #2
0
        protected List <(long ID, string FullName, string Title, string Text)> GetJoinAll(List <ProductDTO> products)
        {
            var users     = userDal.GetAll();
            var responces = responseDal.GetAll();

            var res = from ts in products
                      join us in users on ts.UserId equals us.Id
                      join cs in responces on ts.ResponceId equals cs.Id
                      select new { ID = ts.Id, us.FullName, ts.ProductName, ts.Price, cs.Responce };
            List <(long ID, string FullName, string Title, string Text)> ls = new List <(long ID, string FullName, string Title, string Text)>();

            foreach (var i in res)
            {
                Console.WriteLine($"{i.ID} {i.FullName} \nTitle: {i.ProductName} \nText: {i.Responce}");
                ls.Add((i.ID, i.FullName, i.ProductName, i.Responce));
            }

            return(ls);
        }