예제 #1
0
 public bool DeactivateArtist(int userId)
 {
     var trmwebservice = new WebService.WCFWebServiceJson();
     var artist = trmwebservice.GetArtist(userId);
     artist.Active = false;
     return trmwebservice.UpdateArtist(artist, artist.GenreCollection, null);
 }
예제 #2
0
        public string ArtistDetails(string form, string fileStream, string fileName, string fileType)
        {
            var result = "Your details have not been updated. Please try again. If the problem persists, please contact us at [email protected]";
            var formCollection = form.Split('&');
            var trmservice = new WebService.WCFWebServiceJson();
            var artist = trmservice.GetArtist(WebSecurity.CurrentUserId);
            var util = new Utilities();
            var profileImage = string.Empty;
            var localFile = Path.Combine(MusicManagerBase.LocalTempDestinationPath, fileName);

            if (!string.IsNullOrEmpty(fileStream))
            {
                byte[] bytes = Convert.FromBase64String(fileStream);
                using (MemoryStream ms = new MemoryStream(bytes))
                {
                    using (FileStream file = new FileStream(localFile, FileMode.Create, System.IO.FileAccess.Write))
                    {
                        ms.Read(bytes, 0, (int)ms.Length);
                        file.Write(bytes, 0, bytes.Length);
                        ms.Close();
                    }
                }
            }

            if (!string.IsNullOrEmpty(fileName) || !string.IsNullOrEmpty(MusicManagerBase.ReturnFormItemValue(formCollection, "ProfileImagePath")))
            {
                // Attempt to upate the user
                try
                {
                    if (string.IsNullOrEmpty(fileName))
                    {
                        profileImage = MusicManagerBase.ReturnFormItemValue(formCollection, "ProfileImagePath");
                    }
                    else
                    {
                        profileImage = util.RemoveSpaces(MusicManagerBase.ReturnFormItemValue(formCollection, "ArtistName")) + "/" + fileName;
                    }

                    artist.ProfileImage = profileImage;
                    artist.ArtistName = MusicManagerBase.ReturnFormItemValue(formCollection, "ArtistName");
                    artist.Email = MusicManagerBase.ReturnFormItemValue(formCollection, "Email");
                    artist.Facebook = MusicManagerBase.ReturnFormItemValue(formCollection, "Facebook");
                    artist.MySpace = MusicManagerBase.ReturnFormItemValue(formCollection, "MySpace");
                    artist.SoundCloud = MusicManagerBase.ReturnFormItemValue(formCollection, "SoundCloud");
                    artist.Twitter = MusicManagerBase.ReturnFormItemValue(formCollection, "Twitter");
                    artist.Website = MusicManagerBase.ReturnFormItemValue(formCollection, "Website");
                    artist.PRS = MusicManagerBase.ReturnFormBooleanValue(formCollection, "PRS");
                    artist.CreativeCommonsLicence = MusicManagerBase.ReturnFormBooleanValue(formCollection, "CreativeCommonsLicence");
                    artist.Bio = MusicManagerBase.ReturnFormItemValue(formCollection, "Bio");

                    var artistGenreList = new List<Genre>();

                    foreach (var formItem in formCollection)
                    {
                        if (formItem.ToString().StartsWith("genre"))
                        {
                            artistGenreList.Add(new Genre
                            {
                                GenreId = GetGenreId(formItem.ToString()),
                                GenreName = GetGenreName(formItem.ToString())
                            });
                        }
                    }

                    if (trmservice.UpdateArtist(artist, artistGenreList, localFile))
                    {
                        result = "You have successfully updated your details";
                    }
                }
                catch (MembershipCreateUserException e)
                {
                    result = ErrorCodeToString(e.StatusCode);
                }
            }
            else
            {
                result = "Please select a profile image";
            }

            return result;
        }