Пример #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 async Task<IList<Product>> GetProduct(ProductQuery productQuery)
        {
            IList<SearchData> searchDataList = new List<SearchData>();
            SearchData searchData = null;
           if (!string.IsNullOrEmpty(productQuery.ProductName))
            {
                searchData = new SearchData
                {
                    SearchField = "ProductName",
                    SearchValue = new List<string> {productQuery.ProductName}
                };
                searchDataList.Add(searchData);
            }
           if (!string.IsNullOrEmpty(productQuery.ProductTypeId))
          {
              searchData = new SearchData
              {
                  SearchField = "ProductTypeId",
                  SearchValue = new List<string> {productQuery.ProductTypeId}
              };
              searchDataList.Add(searchData);
          }
            var result = await AccessDb.GetListWithFilter<Product>(searchDataList, MongoTables.ProductTableName);

            return result;
        }
Пример #3
0
 public async Task<IList> GetShops(string shopName)
 {
     SearchData searchData = null;
     if (!string.IsNullOrEmpty(shopName))
     {
         searchData = new SearchData { SearchField = "ShopName" };
         searchData.SearchValue.Add(shopName);
     }
     return await AccessDb.GetListOf<BsonDocument>(searchData, MongoTables.ShopTableName);
 }