//INSERT ALBUM public bool CreatePlaylist(PlaylistCreateModel playlistCreateModel) { if (playlistCreateModel.PlaylistImage != null) { playlistCreateModel.PlaylistImageUrl = UploadPlaylistCoverImage(playlistCreateModel.PlaylistImage, playlistCreateModel.PlaylistId); } else { playlistCreateModel.PlaylistImageUrl = UploadPlaylistCoverImage(new DynamicPictureGenerator().GenerateNewImage(playlistCreateModel.PlaylistName[0].ToString(), 854, 854, 500), playlistCreateModel.PlaylistId); } try { var collection = new MongodbConnectionProvider().GeShantyDatabase().GetCollection <BsonDocument>("playlists"); var document = new BsonDocument { { "PlaylistId", playlistCreateModel.PlaylistId }, { "PlaylistName", playlistCreateModel.PlaylistName }, { "PlaylistImageUrl", playlistCreateModel.PlaylistImageUrl }, { "CreatorId", playlistCreateModel.CreatorId }, { "Songs", new BsonArray() } }; collection.InsertOne(document); return(true); } catch (Exception) { return(false); } }
//ARTIST REGISTRATION public bool RegisterArtist(ArtistGlobalModel artist) { bool InsertArtistMysql() { MysqlConnectionProvider dbConnection = new MysqlConnectionProvider(); dbConnection.CreateQuery("INSERT INTO users(id, username, email, phone, pass, type, isemailverified) VALUES ('" + artist.Id + "','" + artist.Username + "','" + artist.Email + "','" + artist.Phone + "','" + artist.Pass + "','" + artist.Type + "','" + artist.IsEmailVerified + "')"); if ((dbConnection.DoNoQuery()) < 1) { dbConnection.Dispose(); return(false); } dbConnection.Dispose(); return(true); } bool InsertArtistMongo() { try { var collection = new MongodbConnectionProvider().GeShantyDatabase().GetCollection <BsonDocument>("artists"); var document = new BsonDocument { { "ArtistId", artist.Id }, { "ProfileImageUrl", artist.ProfileImageUrl }, { "FirstName", artist.FirstName }, { "LastName", artist.LastName }, { "Dob", artist.Dob }, { "Region", artist.Region }, { "LabelId", artist.LabelId }, { "IsVerified", artist.IsVerified } }; collection.InsertOne(document); return(true); } catch (Exception) { return(false); } } return(InsertArtistMysql() && InsertArtistMongo()); }
//LISTENER REGISTRATION public bool RegisterListener(ListenerGlobalModel listener) { bool InsertListenerMysql() { MysqlConnectionProvider dbConnection = new MysqlConnectionProvider(); dbConnection.CreateQuery("INSERT INTO users(id, username, email, phone, pass, type, isemailverified) VALUES ('" + listener.Id + "','" + listener.Username + "','" + listener.Email + "','" + listener.Phone + "','" + listener.Pass + "','" + listener.Type + "','" + listener.IsEmailVerified + "')"); if ((dbConnection.DoNoQuery()) < 1) { dbConnection.Dispose(); return(false); } dbConnection.Dispose(); return(true); } bool InsertListenerMongo() { try { var collection = new MongodbConnectionProvider().GeShantyDatabase().GetCollection <BsonDocument>("listeners"); var document = new BsonDocument { { "ListenerId", listener.Id }, { "ProfileImageUrl", listener.ProfileImageUrl }, { "FirstName", listener.FirstName }, { "LastName", listener.LastName }, { "Dob", listener.Dob }, { "Region", listener.Region }, { "IsSubscriber", listener.IsSubscriber } }; collection.InsertOne(document); return(true); } catch (Exception) { return(false); } } return(InsertListenerMysql() && InsertListenerMongo()); }
//LABEL REGISTRTION public bool RegisterLabel(LabelGlobalModel label) { bool InsertLabelMysql() { MysqlConnectionProvider dbConnection = new MysqlConnectionProvider(); dbConnection.CreateQuery("INSERT INTO users(id, username, email, phone, pass, type, isemailverified) VALUES ('" + label.Id + "','" + label.Username + "','" + label.Email + "','" + label.Phone + "','" + label.Pass + "','" + label.Type + "','" + label.IsEmailVerified + "')"); if ((dbConnection.DoNoQuery()) < 1) { dbConnection.Dispose(); return(false); } dbConnection.Dispose(); return(true); } bool InsertLabelMongo() { try { var collection = new MongodbConnectionProvider().GeShantyDatabase().GetCollection <BsonDocument>("labels"); var document = new BsonDocument { { "LabelId", label.Id }, { "LabelIconUrl", label.LabelIconUrl }, { "LabelName", label.LabelName }, { "EstDate", label.EstDate }, { "Region", label.Region }, { "IsVerified", label.IsVerified } }; collection.InsertOne(document); return(true); } catch (Exception) { return(false); } } return(InsertLabelMysql() && InsertLabelMongo()); }
//INSERT ALBUM public bool CreateAlbum(AlbumGlobalModel albumGlobalModel) { try { var collection = new MongodbConnectionProvider().GeShantyDatabase().GetCollection <BsonDocument>("albums"); var document = new BsonDocument { { "AlbumId", albumGlobalModel.Id }, { "AlbumName", albumGlobalModel.AlbumName }, { "CoverImageUrl", albumGlobalModel.CoverImageUrl }, { "LabelId", albumGlobalModel.LabelId }, { "ArtistId", albumGlobalModel.ArtistId }, { "Year", albumGlobalModel.Year }, { "Genre", albumGlobalModel.Genre } }; collection.InsertOne(document); return(true); } catch (Exception) { return(false); } }
//UPLOAD SONG public bool UploadSong(SongGlobalModel songGlobalModel) { try { var collection = new MongodbConnectionProvider().GeShantyDatabase().GetCollection <BsonDocument>("songs"); var document = new BsonDocument { { "SongId", songGlobalModel.Id }, { "SongName", songGlobalModel.SongName }, { "SongFileUrl", songGlobalModel.SongFileUrl }, { "AlbumId", songGlobalModel.AlbumId }, { "ArtistName", songGlobalModel.ArtistName }, { "TimesStreamed", songGlobalModel.TimesStreamed }, { "Genre", songGlobalModel.Genre }, { "CoverImageUrl", songGlobalModel.CoverImageUrl } }; collection.InsertOne(document); return(true); } catch (Exception) { return(false); } }