public List <ListItem> GetCategories() { IMongoDAL dal = new MongoDAL(); var result = dal.GetCategorySubCategory(); var response = new Dictionary <string, string>(); response.Add("--select--", "--select--"); foreach (BsonDocument item in result) { if (!response.Keys.Contains(item["Category"].ToString())) { response.Add(item["Category"].ToString(), item["Category"].ToString()); } } var listItemResponse = new List <ListItem>(); foreach (var item in response.Keys) { listItemResponse.Add(new ListItem { Id = item, Value = item }); } return(listItemResponse); }
public Dictionary <string, string> GetCategories() { IMongoDAL dal = new MongoDAL(); var result = dal.GetCategorySubCategory(); var response = new Dictionary <string, string>(); response.Add("--select--", "--select--"); foreach (BsonDocument item in result) { if (!response.Keys.Contains(item["Category"].ToString())) { response.Add(item["Category"].ToString(), item["Category"].ToString()); } } return(response); }