public bool RegisterArtistSocial(Artist artist, string provider, string providerUserId) { var util = new Utilities(); bool isRegistered; using (var tranScope = new TransactionScope()) { try { OAuthWebSecurity.CreateOrUpdateAccount(provider, providerUserId, artist.UserName); Roles.AddUserToRole(artist.UserName, "Artist"); // if the user is saved successfully it will return a userId which is always greater than 0 artist.UserId = WebSecurity.GetUserId(artist.UserName); // save an artist instance of this user isRegistered = SaveArtist(artist); tranScope.Complete(); } catch (MembershipCreateUserException ex) { util.ErrorNotification(ex); throw; } catch (Exception ex) { util.ErrorNotification(ex); throw; } } return (artist.UserId > 0 && isRegistered); }
public bool RegisterArtist(Artist artist, List<Genre> genreCollection, HttpPostedFileBase sourceFile) { var util = new Utilities(); bool isRegistered; using (var tranScope = new TransactionScope()) { try { // if the user is saved successfully it will return a userId which is always greater than 0 WebSecurity.CreateUserAndAccount(artist.UserName, artist.Password); Roles.AddUserToRole(artist.UserName, artist.UserType.ToString()); artist.UserId = WebSecurity.GetUserId(artist.UserName); // first save an artist instance of this user isRegistered = SaveArtist(artist); if (isRegistered) { // now create an account for this user isRegistered = SaveUserAccount(artist, Account.AccountTypeList.artist); foreach (var genre in genreCollection) { isRegistered = SqlArtistGenreRepository.SaveArtistGenre(new ArtistGenre() { UserId = artist.UserId, GenreId = genre.GenreId }); if (!isRegistered) { return false; } } // save file locally to upload it if (!UploadFileToS3(SaveFileLocally(sourceFile), util.RemoveSpaces(artist.ArtistName) + "/", "stream")) { return false; } tranScope.Complete(); } } catch (MembershipCreateUserException ex) { util.ErrorNotification(ex); throw; } catch (Exception ex) { util.ErrorNotification(ex); throw; } } return (artist.UserId > 0 && isRegistered); }