Exemplo n.º 1
0
        public async Task<IList<Shop>> GetShopsByProduct(string productId)
        {
            ProductRepository productRepository = new ProductRepository();
            IList<SearchData> searchDataList = new List<SearchData>();
            SearchData searchData = null;
            if (!string.IsNullOrEmpty(productId))
            {
                searchData = new SearchData
                {
                    SearchField = "ProductId",
                    SearchValue = new List<string> { productId }
                };

                searchDataList.Add(searchData);
            }
            var products = await productRepository.GetProduct(productId);
            var shops = await AccessDb.GetListOf<Shop>(MongoTables.ShopTableName);

            var shopDetails = from shop in shops 
                              join product in products on shop.ShopId equals product.ShopId 
                              select new Shop {
                                  ShopId = shop.ShopId,
                                  Address = shop.Address,
                                  EmailAddress = shop.EmailAddress,
                                  Latitude = shop.Latitude,
                                  Longitude = shop.Longitude,
                                  Pincode = shop.Pincode,
                                  ShopName = shop.ShopName
                              };


            return shopDetails.ToList();

        }
 public ProductsController()
 {
      _productRepository = new ProductRepository();
 }