Ejemplo n.º 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);
 }
Ejemplo n.º 2
0
        public ActionResult ArtistDetails(int userId)
        {
            var TrmWcfWebServiceJson = new WebService.WCFWebServiceJson();
            var artist = TrmWcfWebServiceJson.GetArtist(userId);

            return View(artist);
        }
Ejemplo n.º 3
0
        public PartialViewResult ArtistAlbums(ArtistAlbumModel model, FormCollection form)
        {
            var trmservice = new WebService.WCFWebServiceJson();
            var artist = trmservice.GetArtist(WebSecurity.CurrentUserId);
            var util = new Utilities();

            ViewBag.ArtistAlbums = trmservice.GetArtistAlbums(artist);

            if (ModelState.IsValid)
            {
                if (model.AlbumCover != null)
                {
                    // Attempt to save the album
                    try
                    {
                        var albumGenreList = new List<Genre>();

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

                        var album = new Album
                        {
                            AlbumTitle = model.AlbumTitle,
                            AlbumProducer = model.AlbumProducer,
                            AlbumLabel = model.AlbumLabel,
                            AlbumReleaseDate = model.AlbumReleaseDate,
                            AlbumCover = util.RemoveSpaces(artist.ArtistName) + "/" + util.RemoveSpaces(model.AlbumTitle) + "/" + model.AlbumCover.FileName,
                            GenreCollection = albumGenreList,
                            CreatedDate = DateTime.Now
                        };

                        // link the album to the artist and save it
                        trmservice.SaveArtistAlbum(album, artist, album.AlbumCover);
                        ViewBag.StatusMessage = "The album \"" + album.AlbumTitle + "\" has been uploaded successfully.";
                    }
                    catch (MembershipCreateUserException e)
                    {
                        ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                    }
                }
                else
                {
                    ModelState.AddModelError("MissingAlbumCover", "Please select an album cover");
                }
            }

            // If we got this far, something failed, redisplay form
            return PartialView(model);
        }
Ejemplo n.º 4
0
        //
        // GET: Artist details
        public ActionResult ArtistProfile(int userId)
        {
            var trmwebservice = new WebService.WCFWebServiceJson();
            var artist = trmwebservice.GetArtist(userId);

            ViewBag.ImagePath = MusicManagerBase.StreamingUrl + artist.ProfileImage;

            return View(artist);
        }
Ejemplo n.º 5
0
        public ActionResult ArtistSongs(int userId)
        {
            var trmservice = new WebService.WCFWebServiceJson();
            var artist = trmservice.GetArtist(userId);
            ViewBag.ArtistAlbums = trmservice.GetArtistAlbums(artist);
            ViewBag.UserId = userId;

            return View();
        }
Ejemplo n.º 6
0
        public PartialViewResult ArtistAlbums()
        {
            var trmservice = new WebService.WCFWebServiceJson();
            var artist = trmservice.GetArtist(WebSecurity.CurrentUserId);
            ViewBag.ArtistAlbums = trmservice.GetArtistAlbums(artist);
            ViewBag.ArtistName = artist.ArtistName;

            return PartialView();
        }
Ejemplo n.º 7
0
        public ActionResult CloudPlayer()
        {
            var trmservice = new WebService.WCFWebServiceJson();
            var artist = new Artist(); //trmservice.GetArtist(WebSecurity.CurrentUserId);

            ViewBag.ImagePath = MusicManagerBase.StreamingUrl + artist.ProfileImage;
            ViewBag.Genres = WebService.GetAllGenres();

            return View();
        }
Ejemplo n.º 8
0
        public PartialViewResult AlbumSongList(int albumId)
        {
            var trmservice = new WebService.WCFWebServiceJson();
            var artist = trmservice.GetArtist(WebSecurity.CurrentUserId);
            var songList = trmservice.GetAlbumSongs(albumId);
            var album = trmservice.GetAllAlbums().FirstOrDefault(a => a.AlbumId == albumId);

            ViewBag.AlbumId = albumId;
            ViewBag.AlbumTitle = album.AlbumTitle;

            return PartialView(songList);
        }
Ejemplo n.º 9
0
        public string EditSong(string form, string fileStream, string fileName, string fileType)
        {
            var result = "The song was not uploaded. 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 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, "MediaAssetPath")))
            {
                // Attempt to save the song
                try
                {
                    var albumCollection = new List<Album>();
                    var songGenreList = new List<Genre>();

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

                    var albumId = 0;
                    if (!string.IsNullOrEmpty(MusicManagerBase.ReturnFormItemValue(formCollection, "AlbumId")) && Convert.ToInt32(MusicManagerBase.ReturnFormItemValue(formCollection, "AlbumId")) > 0)
                    {
                        albumId = Convert.ToInt32(MusicManagerBase.ReturnFormItemValue(formCollection, "AlbumId"));
                    }

                    var songId = 0;
                    if (!string.IsNullOrEmpty(MusicManagerBase.ReturnFormItemValue(formCollection, "SongId")) && Convert.ToInt32(MusicManagerBase.ReturnFormItemValue(formCollection, "SongId")) > 0)
                    {
                        songId = Convert.ToInt32(MusicManagerBase.ReturnFormItemValue(formCollection, "SongId"));
                    }

                    var album = trmservice.GetArtistAlbumDetails(albumId);
                    albumCollection.Add(album);

                    var mediaFileFolder = string.Empty;
                    var mediaFileLocation = string.Empty;

                    if (!string.IsNullOrEmpty(fileName))
                    {
                        mediaFileLocation = localFile;
                        mediaFileFolder = util.RemoveSpaces(artist.ArtistName) + "/" + util.RemoveSpaces(album.AlbumTitle) + "/";
                    }

                    var releaseDate = MusicManagerBase.ReturnFormItemValue(formCollection, "SongReleaseDate").ToString().Replace("%2F", "/");

                    var song = new Song()
                    {
                        AlbumCollection = albumCollection,
                        CreatedDate = DateTime.Now,
                        GenreCollection = songGenreList,
                        SongComposer = MusicManagerBase.ReturnFormItemValue(formCollection, "SongComposer"),
                        SongId = songId,
                        SongReleaseDate = Convert.ToDateTime(releaseDate),
                        SongTitle = MusicManagerBase.ReturnFormItemValue(formCollection, "SongTitle"),
                        PRS = MusicManagerBase.ReturnFormBooleanValue(formCollection, "PRS")
                    };

                    // upload and save the song
                    if (trmservice.UploadSong(song, mediaFileLocation, "mp3", mediaFileFolder))
                    {
                        result = "The song \"" + song.SongTitle + "\" has been uploaded successfully.";
                    }
                }
                catch (MembershipCreateUserException e)
                {
                    result = ErrorCodeToString(e.StatusCode);
                }
                catch (Exception ex)
                {
                    result = ex.Message;
                }
            }
            else
            {
                result = "Please select a media file to upload";
            }

            return result;
        }
Ejemplo n.º 10
0
        public string EditAlbum(string form, string fileStream, string fileName, string fileType)
        {
            var result = "The album was not created. 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 localFile = Path.Combine(MusicManagerBase.LocalTempDestinationPath, fileName);

            if (!string.IsNullOrEmpty(fileStream))
            {
                byte[] bytes = Convert.FromBase64String(fileStream);
                using (MemoryStream ms = new MemoryStream(bytes))
                {
                    Image image = Image.FromStream(ms);
                    image.Save(localFile);
                }
            }

            // populate the list of albums for this artist to be displayed in the management section
            ViewBag.ArtistAlbums = trmservice.GetArtistAlbums(artist);

            if (!string.IsNullOrEmpty(fileName) || !string.IsNullOrEmpty(MusicManagerBase.ReturnFormItemValue(formCollection, "AlbumCoverPath")))
            {
                // Attempt to save the album
                try
                {
                    var albumGenreList = new List<Genre>();

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

                    var albumId = 0;
                    if (!string.IsNullOrEmpty(MusicManagerBase.ReturnFormItemValue(formCollection, "AlbumId")) && Convert.ToInt32(MusicManagerBase.ReturnFormItemValue(formCollection, "AlbumId")) > 0)
                    {
                        albumId = Convert.ToInt32(MusicManagerBase.ReturnFormItemValue(formCollection, "AlbumId"));
                        trmservice.UpdateAlbumGenreCollection(albumId, albumGenreList);
                    }

                    // if editing, if no image is uploaded, use the existing path
                    var albumCover = string.Empty;

                    if (string.IsNullOrEmpty(fileName))
                    {
                        albumCover = MusicManagerBase.ReturnFormItemValue(formCollection, "AlbumCoverPath");
                    }
                    else
                    {
                        albumCover = util.RemoveSpaces(artist.ArtistName) + "/" + util.RemoveSpaces(MusicManagerBase.ReturnFormItemValue(formCollection, "AlbumTitle")) + "/" + fileName;
                    }

                    var releaseDate = MusicManagerBase.ReturnFormItemValue(formCollection, "AlbumReleaseDate").ToString().Replace("%2F", "/");

                    var album = new Album
                    {
                        AlbumId = albumId,
                        AlbumTitle = MusicManagerBase.ReturnFormItemValue(formCollection, "AlbumTitle"),
                        AlbumProducer = MusicManagerBase.ReturnFormItemValue(formCollection, "AlbumProducer"),
                        AlbumLabel = MusicManagerBase.ReturnFormItemValue(formCollection, "AlbumLabel"),
                        AlbumReleaseDate = Convert.ToDateTime(releaseDate),
                        AlbumCover = albumCover,
                        GenreCollection = albumGenreList,
                        CreatedDate = DateTime.Now
                    };

                    // link the album to the artist and save it
                    trmservice.SaveArtistAlbum(album, artist, localFile);

                    result = "You have successfully uploaded the album " + album.AlbumTitle;
                }
                catch (MembershipCreateUserException e)
                {
                    result = ErrorCodeToString(e.StatusCode);
                }
            }
            else
            {
                result = "Please select an album cover";
            }

            // delete the temp file
            if (System.IO.File.Exists(localFile))
            {
                System.IO.File.Delete(localFile);
            }
            return result;
        }
Ejemplo n.º 11
0
        public ActionResult EditAlbum(int albumId)
        {
            var artistAlbumModel = new ArtistAlbumModel();

            if (albumId > 0)
            {
                var trmservice = new WebService.WCFWebServiceJson();
                var artist = trmservice.GetArtist(WebSecurity.CurrentUserId);
                var albumDetails = trmservice.GetArtistAlbumDetails(albumId);

                artistAlbumModel.AlbumId = albumDetails.AlbumId;
                artistAlbumModel.AlbumCoverPath = albumDetails.AlbumCover;
                artistAlbumModel.AlbumLabel = albumDetails.AlbumLabel;
                artistAlbumModel.AlbumProducer = albumDetails.AlbumProducer;
                artistAlbumModel.AlbumReleaseDate = albumDetails.AlbumReleaseDate;
                artistAlbumModel.AlbumTitle = albumDetails.AlbumTitle;
                artistAlbumModel.GenreCollection = albumDetails.GenreCollection;
            }

            return View(artistAlbumModel);
        }
Ejemplo n.º 12
0
        public string DeleteSong(int songId, int albumId)
        {
            var result = "There was a problem deleting this song. Please try again. If the problem persists, please contact [email protected]";

            try
            {
                var trmservice = new WebService.WCFWebServiceJson();
                var album = trmservice.GetArtistAlbumDetails(albumId);
                var song = trmservice.GetArtistSongDetails(songId);

                trmservice.DeleteSong(song, album);
                result = "The song " + song.SongTitle + "has been successfully removed from the album " + album.AlbumTitle + ".";
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            return result;
        }
Ejemplo n.º 13
0
        public ActionResult RegisterArtist(ArtistRegisterModel model, FormCollection form)
        {
            ViewBag.Register = "Register as an artist or band";
            ViewBag.RegisterAction = "Register";
            ViewBag.Message = "Artist.";

            if (!model.TermsAndConditions)
            {
                ModelState.AddModelError("TermsAndConditions", "You must agree to the terms and conditions to register.");
            }

            if (ModelState.IsValid)
            {
                if (model.ProfileImage != null)
                {
                    // Attempt to register the user
                    try
                    {
                        var trmservice = new WebService.WCFWebServiceJson();
                        var util = new Utilities();

                        var artist = new Artist
                        {
                            ProfileImage = util.RemoveSpaces(model.ArtistName) + "/" + model.ProfileImage.FileName,
                            ArtistName = model.ArtistName,
                            UserName = model.UserName,
                            Password = model.Password,
                            UserType = DomainModel.Entities.User.UserTypeList.Artist,
                            Email = model.Email,
                            Facebook = model.Facebook,
                            MySpace = model.MySpace,
                            SoundCloud = model.SoundCloud,
                            Twitter = model.Twitter,
                            Website = model.Website,
                            TermsAndConditionsAccepted = model.TermsAndConditions,
                            PRS = model.PRS,
                            CreativeCommonsLicence = model.CreativeCommonsLicence,
                            Bio = model.Bio,
                            CountyCityId = model.CountyCityId
                        };

                        var artistGenreList = new List<Genre>();

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

                        if (trmservice.RegisterArtist(artist, artistGenreList, model.ProfileImage))
                        {
                            WebSecurity.Login(model.UserName, model.Password);
                            return RedirectToAction("RegisterSuccess", "Account");
                        }
                    }
                    catch (MembershipCreateUserException e)
                    {
                        ModelState.AddModelError("Error registering artist", ErrorCodeToString(e.StatusCode));
                    }
                    catch (Exception e)
                    {
                        ModelState.AddModelError("Generic Error", e.ToString());
                    }
                }
                else
                {
                    ModelState.AddModelError("MissingProfileImage", "Please select a profile image.");
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
Ejemplo n.º 14
0
        //
        // GET: /Admin/
        public ActionResult Index()
        {
            var trmwebservice = new WebService.WCFWebServiceJson();

            return View(trmwebservice.GetAllArtists());
        }
Ejemplo n.º 15
0
        public ActionResult LostPassword(LostPasswordModel model)
        {
            if (ModelState.IsValid)
            {
                MembershipUser user;
                var artistUser = new Artist();
                using (var context = new UsersContext())
                {
                    var userProfile = context.UserProfiles.Where(u => u.UserName == model.Username).FirstOrDefault();

                    if (userProfile != null && !string.IsNullOrEmpty(userProfile.UserName))
                    {
                        user = Membership.GetUser(userProfile.UserName);

                        try
                        {
                            // get local user for their email
                            var trmwebservice = new WebService.WCFWebServiceJson();
                            artistUser = trmwebservice.GetArtist(userProfile.UserId);
                        }
                        catch
                        {
                            ModelState.AddModelError("", "No artist found by that user name.");

                            return View(model);
                        }
                    }
                    else
                    {
                        user = null;
                    }
                }
                if (user != null && artistUser != null)
                {
                    try
                    {
                        // Generate password token that will be used in the email link to authenticate user
                        var token = WebSecurity.GeneratePasswordResetToken(user.UserName);
                        // Generate the html link sent via emailModelState.AddModelError("", "There was an issue sending email: " + e.Message);
                        StringBuilder resetLink = new StringBuilder();
                        resetLink.Append(Url.Action("ResetPassword", "Account", new { rt = token }, "http"));
                        resetLink.AppendLine(Environment.NewLine);
                        resetLink.AppendLine("If the link does not work, please copy and paste it in your browser.");
                        resetLink.AppendLine(Environment.NewLine);
                        resetLink.AppendLine("The team at PlayLift Ltd.");

                        // Email stuff
                        string subject = "PlayLift - Reset your password for " + artistUser.ArtistName;
                        string body = "Reset password link: " + resetLink;
                        string from = "*****@*****.**";

                        MailMessage message = new MailMessage(from, artistUser.Email);
                        message.Subject = subject;
                        message.Body = body;
                        SmtpClient client = new SmtpClient("auth.smtp.1and1.co.uk");
                        client.Credentials = new NetworkCredential("*****@*****.**", "trm_info");

                        // Attempt to send the email
                        try
                        {
                            client.Send(message);
                        }
                        catch (Exception e)
                        {
                            ModelState.AddModelError("", "There was an issue sending email: " + e.Message);
                        }
                    }
                    catch (Exception ex)
                    {
                        ModelState.AddModelError("", "We cannot reset your password because: " + ex.Message + " If you have registered with a social network, please reset your password with the provider.");
                    }

                }
                else // Email not found
                {
                    /* Note: You may not want to provide the following information
                    * since it gives an intruder information as to whether a
                    * certain email address is registered with this website or not.
                    * If you're really concerned about privacy, you may want to
                    * forward to the same "Success" page regardless whether an
                    * user was found or not. This is only for illustration purposes.
                    */
                    ModelState.AddModelError("", "No user found by that user name.");

                    return View(model);
                }
            }

            /* You may want to send the user to a "Success" page upon the successful
            * sending of the reset email link. Right now, if we are 100% successful
            * nothing happens on the page. :P
            */
            return RedirectToAction("ResetLinkSent");
        }
Ejemplo n.º 16
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;
        }
Ejemplo n.º 17
0
        public PartialViewResult ViewAlbum(int albumId)
        {
            var trmservice = new WebService.WCFWebServiceJson();
            var album = trmservice.GetAllAlbums().FirstOrDefault(a => a.AlbumId == albumId);
            ViewBag.AlbumCoverPath = MusicManagerBase.StreamingUrl + album.AlbumCover;
            ViewBag.ArtistName = trmservice.GetArtist(WebSecurity.CurrentUserId).ArtistName;

            return PartialView(album);
        }
Ejemplo n.º 18
0
        // Artist management
        // GET: /Account/ManageArtist
        public PartialViewResult ArtistDetails()
        {
            var TrmWcfWebServiceJson = new WebService.WCFWebServiceJson();
            var artist = TrmWcfWebServiceJson.GetArtist(WebSecurity.CurrentUserId);
            var countyCity = TrmWcfWebServiceJson.GetAllCountyCities();

            ViewBag.Counties = countyCity.Select(x => x.County).ToList();
            ViewBag.Cities = countyCity.Select(x => x.City).ToList();

            var artistRegisterModel = new ManageArtistModel
            {
                ArtistName = artist.ArtistName,
                Email = artist.Email,
                Facebook = artist.Facebook,
                GenreCollection = artist.GenreCollection,
                MySpace = artist.MySpace,
                ProfileImagePath = artist.ProfileImage,
                SoundCloud = artist.SoundCloud,
                Twitter = artist.Twitter,
                Website = artist.Website,
                PRS = artist.PRS,
                CreativeCommonsLicence = artist.CreativeCommonsLicence,
                Bio = artist.Bio,
                CountyCityId = artist.CountyCityId
            };

            return PartialView(artistRegisterModel);
        }
Ejemplo n.º 19
0
        public ActionResult RegisterBusiness(BusinessRegisterModel model)
        {
            ViewBag.Register = "Register as a business";
            ViewBag.RegisterAction = "Register";
            ViewBag.Message = "Business.";

            if (!model.TermsAndConditions)
            {
                ModelState.AddModelError("TermsAndConditions", "You must agree to the terms and conditions to register.");
            }

            if (ModelState.IsValid)
            {
                if (model.Logo != null)
                {
                    // Attempt to register the user
                    try
                    {
                        var trmservice = new WebService.WCFWebServiceJson();
                        var util = new Utilities();

                        var business = new BusinessUser
                        {
                            Logo= util.RemoveSpaces(model.BusinessName) + "/" + model.Logo.FileName,
                            UserName = model.UserName,
                            Password = model.Password,
                            UserType = DomainModel.Entities.User.UserTypeList.Business,
                            BusinessName = model.BusinessName,
                            BusinessType = trmservice.GetAllBusinessTypes().Where(x => x.BusinessTypeId == model.BusinessType).FirstOrDefault(),
                            BusinessTypeId = model.BusinessType,
                            Address1 = model.Address1,
                            Address2 = model.Address2,
                            City = model.City,
                            PostCode = model.PostCode,
                            Country = model.Country,
                            TermsAndConditionsAccepted = model.TermsAndConditions,
                            CreatedDate = DateTime.Now
                        };

                        if (trmservice.RegisterBusiness(business, model.Logo))
                        {
                            WebSecurity.Login(model.UserName, model.Password);
                            return RedirectToAction("RegisterBusinessSuccess", "Account");
                        }
                    }
                    catch (MembershipCreateUserException e)
                    {
                        ModelState.AddModelError("Error registering business", ErrorCodeToString(e.StatusCode));
                    }
                    catch (Exception e)
                    {
                        ModelState.AddModelError("Generic Error", e.ToString());
                    }
                }
                else
                {
                    ModelState.AddModelError("MissingProfileImage", "Please select a profile image.");
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
Ejemplo n.º 20
0
        public ActionResult ExternalLoginConfirmation(RegisterExternalLoginModel model, string returnUrl)
        {
            string provider = null;
            string providerUserId = null;

            if (User.Identity.IsAuthenticated || !OAuthWebSecurity.TryDeserializeProviderUserId(model.ExternalLoginData, out provider, out providerUserId))
            {
                return RedirectToAction("Manage");
            }

            if (!model.TermsAndConditions)
            {
                ModelState.AddModelError("TermsAndConditions", "You must agree to the terms and conditions to register.");
            }

            if (ModelState.IsValid)
            {
                // Insert a new user into the database
                using (UsersContext db = new UsersContext())
                {
                    UserProfile user = db.UserProfiles.FirstOrDefault(u => u.UserName.ToLower() == model.UserName.ToLower());
                    // Check if user already exists
                    if (user == null)
                    {
                        // Insert name into the profile table
                        db.UserProfiles.Add(new UserProfile { UserName = model.UserName });
                        db.SaveChanges();

                        var artist = new Artist
                        {
                            UserName = model.UserName,
                            UserType = DomainModel.Entities.User.UserTypeList.Artist,
                            TermsAndConditionsAccepted = model.TermsAndConditions,
                        };

                        var trmwebservice = new WebService.WCFWebServiceJson();
                        if (trmwebservice.RegisterArtistSocial(artist, provider, providerUserId))
                        {
                            OAuthWebSecurity.Login(provider, providerUserId, createPersistentCookie: false);
                            return RedirectToAction("RegisterSuccess", "Account");
                        }
                        else
                        {
                            ModelState.AddModelError("ArtistRegistrationError", "There was an issue registering you. If the problemt persists, please contact us at [email protected]");
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("UserName", "User name already exists. Please enter a different user name.");
                    }
                }
            }

            ViewBag.ProviderDisplayName = OAuthWebSecurity.GetOAuthClientData(provider).DisplayName;
            ViewBag.ReturnUrl = returnUrl;
            return View(model);
        }
Ejemplo n.º 21
0
        // Artist management
        // GET: /Account/ArtistAlbums
        public PartialViewResult ArtistProfile()
        {
            var trmwebservice = new WebService.WCFWebServiceJson();
            var artist = trmwebservice.GetArtist(WebSecurity.CurrentUserId);

            ViewBag.ImagePath = MusicManagerBase.StreamingUrl + artist.ProfileImage;

            return PartialView(artist);
        }
Ejemplo n.º 22
0
        public string DeleteAlbum(int albumId)
        {
            var result = "There was a problem deleting this album. Please try again. If the problem persists, please contact [email protected]";

            try
            {
                var trmservice = new WebService.WCFWebServiceJson();
                var artist = trmservice.GetArtist(WebSecurity.CurrentUserId);
                var album = trmservice.GetArtistAlbumDetails(albumId);

                trmservice.DeleteArtistAlbum(album, artist);
                result = "The album " + album.AlbumTitle + " has been successfully removed.";
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            return result;
        }
Ejemplo n.º 23
0
        // Artist management
        public ActionResult ManageArtist(ManageMessageId? message)
        {
            var trmservice = new WebService.WCFWebServiceJson();
            var artist = trmservice.GetArtist(WebSecurity.CurrentUserId);

            return View(artist);
        }
Ejemplo n.º 24
0
        // Artist management
        // GET: /Account/ArtistSongs
        public PartialViewResult ArtistSongs(int albumId)
        {
            var trmservice = new WebService.WCFWebServiceJson();
            var artist = trmservice.GetArtist(WebSecurity.CurrentUserId);
            ViewBag.ArtistAlbums = trmservice.GetArtistAlbums(artist);
            ViewBag.AlbumId = albumId;

            return PartialView();
        }