private List <CseMerchantInfo> ParseAffiliateWindowMerchants(string source, DataTable merchantsTable) { if (merchantsTable == null || merchantsTable.Rows.Count == 0) { return(null); } var merchants = new List <CseMerchantInfo>(); for (int i = 0; i < merchantsTable.Rows.Count; i++) { var merchant = new CseMerchantInfo(); merchant.ShoppingEngine = 6; merchant.Source = source; merchant.MerchantId = merchantsTable.Rows[i]["merchant_id"] as string; merchant.Name = ((string)merchantsTable.Rows[i]["merchant_name"]).ToLower(); merchant.DisplayName = merchantsTable.Rows[i]["merchant_name"] as string; merchant.Logo = merchantsTable.Rows[i]["merchant_logo"] as string; merchant.UseLogo = true; merchants.Add(merchant); } return(merchants); }
//DAL public void UpdateMerchant(CseMerchantInfo merchant) { var dataBase = _server.ServerConnection.GetDatabase(string.Format("cse_caching_{0}", merchant.ShoppingEngine)); var collection = dataBase.GetCollection <CseMerchantInfo>(MERCHANTS_COLLECTION); var updateBuilder = new UpdateBuilder(); if (merchant.Name != null) { updateBuilder.Set("name", merchant.Name); } if (merchant.DisplayName != null) { updateBuilder.Set("display_name", merchant.DisplayName); } if (merchant.Logo != null) { updateBuilder.Set("logo", merchant.Logo); } if (merchant.Source != null) { updateBuilder.Set("source", merchant.Source); } updateBuilder.Set("use_logo", merchant.UseLogo); updateBuilder.Set("rating", merchant.Rating); updateBuilder.Set("shopping_engine", merchant.ShoppingEngine); updateBuilder.Set("date_modified", DateTime.Now); collection.Update(Query.EQ("merchant_id", merchant.MerchantId), updateBuilder); }
private List <CseMerchantInfo> ParseShoppingMerchants(int cse, string source, DataTable products, DataTable productMerchants) { if (productMerchants == null || productMerchants.Rows.Count == 0) { return(null); } var merchants = new List <CseMerchantInfo>(); for (int i = 0; i < productMerchants.Rows.Count; i++) { var merchant = new CseMerchantInfo(); merchant.ShoppingEngine = cse; merchant.Source = source; merchant.MerchantId = productMerchants.Rows[i]["mid"] as string; merchant.Name = ((string)productMerchants.Rows[i]["name"]).ToLower(); merchant.DisplayName = productMerchants.Rows[i]["name"] as string; merchant.Logo = productMerchants.Rows[i]["logo"] as string; merchant.Source = source; merchant.UseLogo = true; var rating = products.Select("PID = '" + (string)productMerchants.Rows[i]["PID"] + "'")[0]["rating"]; merchant.Rating = rating != DBNull.Value ? Convert.ToDouble(rating) : 0; merchants.Add(merchant); } return(merchants); }
public CseMerchantInfo InsertMerchant(CseMerchantInfo merchant) { var dataBase = _server.ServerConnection.GetDatabase(string.Format("cse_caching_{0}", merchant.ShoppingEngine)); var collection = dataBase.GetCollection <CseMerchantInfo>(MERCHANTS_COLLECTION); merchant.DateCreated = DateTime.Now; merchant.DateModified = DateTime.Now; collection.Insert(merchant); return(merchant); }