//GET USER DATA public List <ArtistGetInfoModel> GetAllArtistInfo(string labelId) { List <ArtistGetInfoModel> artistGetInfoModels = new List <ArtistGetInfoModel>(); var collection = new MongodbConnectionProvider().GeShantyDatabase().GetCollection <BsonDocument>("artists"); var builder = Builders <BsonDocument> .Filter; var filter = builder.Eq("LabelId", labelId); var results = collection.Find(filter).ToList(); foreach (BsonDocument result in results) { if (result != null) { ArtistGetInfoModel res = BsonSerializer.Deserialize <ArtistGetInfoModel>(result); //MysqlConnectionProvider dbConnection = new MysqlConnectionProvider(); //dbConnection.CreateQuery("SELECT username,email,phone FROM users WHERE id='" + res.ArtistId + "'"); //MySqlDataReader reader = dbConnection.DoQuery(); //while (reader.Read()) //{ // res.Username = reader["username"].ToString(); // res.Email = reader["email"].ToString(); // res.Phone = reader["phone"].ToString(); //} //dbConnection.Dispose(); //dbConnection = null; artistGetInfoModels.Add(res); } } return(artistGetInfoModels); }
public SearchResultModel SearchResult(string query) { SearchResultModel searchResultModel = new SearchResultModel(); searchResultModel.AlbumGetModels = new List <AlbumGetModel>(); searchResultModel.SongGetModels = new List <SongGetModel>(); searchResultModel.ArtistGetInfoModels = new List <ArtistGetInfoModel>(); var songCollection = new MongodbConnectionProvider().GeShantyDatabase().GetCollection <BsonDocument>("songs"); var artistCollection = new MongodbConnectionProvider().GeShantyDatabase().GetCollection <BsonDocument>("artists"); var albumCollection = new MongodbConnectionProvider().GeShantyDatabase().GetCollection <BsonDocument>("albums"); var songfilter = new BsonDocument { { "SongName", new BsonDocument { { "$regex", query }, { "$options", "i" } } } }; var songResults = songCollection.Find(songfilter).ToList(); var albumfilter = new BsonDocument { { "AlbumName", new BsonDocument { { "$regex", query }, { "$options", "i" } } } }; var albumResults = albumCollection.Find(albumfilter).ToList(); var artistfilter = new BsonDocument { { "FirstName", new BsonDocument { { "$regex", query }, { "$options", "i" } } } }; var artistResults = artistCollection.Find(artistfilter).ToList(); foreach (BsonDocument result in songResults) { if (result != null) { SongGetModel res = BsonSerializer.Deserialize <SongGetModel>(result); searchResultModel.SongGetModels.Add(res); } } foreach (BsonDocument result in albumResults) { if (result != null) { AlbumGetModel res = BsonSerializer.Deserialize <AlbumGetModel>(result); searchResultModel.AlbumGetModels.Add(res); } } foreach (BsonDocument result in artistResults) { if (result != null) { ArtistGetInfoModel res = BsonSerializer.Deserialize <ArtistGetInfoModel>(result); searchResultModel.ArtistGetInfoModels.Add(res); } } return(searchResultModel); }
public RecommendedModel GetRecommended(string id) { RecommendedModel recommendedModel = new RecommendedModel(); recommendedModel.AlbumGetModels = new List <AlbumGetModel>(); recommendedModel.SongGetModels = new List <SongGetModel>(); recommendedModel.ArtistGetInfoModels = new List <ArtistGetInfoModel>(); var songCollection = new MongodbConnectionProvider().GeShantyDatabase().GetCollection <BsonDocument>("songs"); var artistCollection = new MongodbConnectionProvider().GeShantyDatabase().GetCollection <BsonDocument>("artists"); var albumCollection = new MongodbConnectionProvider().GeShantyDatabase().GetCollection <BsonDocument>("albums"); var songResults = songCollection.Find(new BsonDocument()).Limit(15).ToList(); var albumResults = albumCollection.Find(new BsonDocument()).Limit(15).ToList(); var artistResults = artistCollection.Find(new BsonDocument()).Limit(15).ToList(); foreach (BsonDocument result in songResults) { if (result != null) { SongGetModel res = BsonSerializer.Deserialize <SongGetModel>(result); recommendedModel.SongGetModels.Add(res); } } foreach (BsonDocument result in albumResults) { if (result != null) { AlbumGetModel res = BsonSerializer.Deserialize <AlbumGetModel>(result); recommendedModel.AlbumGetModels.Add(res); } } foreach (BsonDocument result in artistResults) { if (result != null) { ArtistGetInfoModel res = BsonSerializer.Deserialize <ArtistGetInfoModel>(result); recommendedModel.ArtistGetInfoModels.Add(res); } } return(recommendedModel); }
public ArtistGetInfoModel GetArtistInfo(string Id) { MysqlConnectionProvider dbConnection = new MysqlConnectionProvider(); dbConnection.CreateQuery("SELECT username,email,phone FROM users WHERE id='" + Id + "'"); ArtistGetInfoModel artistGetInfoModel = null; MySqlDataReader reader = dbConnection.DoQuery(); while (reader.Read()) { artistGetInfoModel = new ArtistGetInfoModel(); artistGetInfoModel.Username = reader["username"].ToString(); artistGetInfoModel.Email = reader["email"].ToString(); artistGetInfoModel.Phone = reader["phone"].ToString(); } dbConnection.Dispose(); dbConnection = null; var collection = new MongodbConnectionProvider().GeShantyDatabase().GetCollection <BsonDocument>("artists"); var builder = Builders <BsonDocument> .Filter; var filter = builder.Eq("ArtistId", Id); var result = collection.Find(filter).FirstOrDefault(); if (result != null) { ArtistGetInfoModel res = BsonSerializer.Deserialize <ArtistGetInfoModel>(result); artistGetInfoModel.ArtistId = res.ArtistId; artistGetInfoModel.ProfileImageUrl = res.ProfileImageUrl; artistGetInfoModel.FirstName = res.FirstName; artistGetInfoModel.LastName = res.LastName; artistGetInfoModel.Dob = res.Dob; artistGetInfoModel.Region = res.Region; artistGetInfoModel.IsVerified = res.IsVerified; artistGetInfoModel.LabelId = res.LabelId; } return(artistGetInfoModel); }