public ActionResult <CustomResponseModel> PutArtist([FromForm] ArtistRegistrationModel artistRegistrationModel) { ArtistGlobalModel artistGlobalModel = new ArtistGlobalModel(); artistGlobalModel.LabelId = new UserDataAccess().JwtTokenValidation(artistRegistrationModel.JwtToken); if (artistGlobalModel.LabelId == "") { return(Unauthorized(new CustomResponseModel() { Code = "401", Phrase = "Unauthorized", Message = "Invalid Jwt Token" })); } else if (new UserDataAccess().GetUserType(artistGlobalModel.LabelId) != "label") { return(Unauthorized(new CustomResponseModel() { Code = "401", Phrase = "Unauthorized", Message = "Artist Creator Must be a Label" })); } artistGlobalModel.Id = GenerateUserId(artistRegistrationModel.Username + DateTime.Now.ToString("dddd, dd MMMM yyyy HH:mm:ss")); artistGlobalModel.ProfileImage = artistRegistrationModel.ProfileImage; artistGlobalModel.ProfileImageUrl = new UserDataAccess().UploadProfileImage(artistGlobalModel.ProfileImage, artistGlobalModel.Id); artistGlobalModel.Username = artistRegistrationModel.Username; artistGlobalModel.FirstName = artistRegistrationModel.FirstName; artistGlobalModel.LastName = artistRegistrationModel.LastName; artistGlobalModel.Phone = artistRegistrationModel.Phone; artistGlobalModel.Email = artistRegistrationModel.Email; artistGlobalModel.Region = artistRegistrationModel.Region; artistGlobalModel.Dob = artistRegistrationModel.Dob; artistGlobalModel.Pass = BCrypt.Net.BCrypt.HashPassword(artistRegistrationModel.Pass, BCrypt.Net.BCrypt.GenerateSalt()); artistGlobalModel.IsEmailVerified = "false"; artistGlobalModel.IsVerified = "false"; artistGlobalModel.Type = "artist"; if (new UserDataAccess().RegisterArtist(artistGlobalModel)) { new UserDataAccess().SendArtistVerificationEmail(artistGlobalModel.FirstName + " " + artistGlobalModel.LastName, artistGlobalModel.Email, artistGlobalModel.Id, artistRegistrationModel.Pass); return(Ok(new CustomResponseModel() { Code = "200", Phrase = "OK", Message = "Artist Account Created" })); } return(BadRequest(new CustomResponseModel() { Code = "400", Phrase = "BadRequest", Message = "Artist Account Creation Failed" })); }
//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()); }