public ActionResult SongEditor(int ArtistPageId) { if (ArtistPageId == 0) return RedirectToRoute("HomePage"); var model = new SongModel() { ArtistPageId = ArtistPageId, DateCreated = DateTime.Now, DateUpdated = DateTime.Now }; return View(ControllerUtil.MobSocialViewsFolder + "/SongPage/SongEditor.cshtml", model); }
public ActionResult SaveSong(SongModel model) { if (!ModelState.IsValid) return Json(new { Success = true }); if (!_workContext.CurrentCustomer.IsRegistered()) return InvokeHttp404(); //every song should be mapped to a downloadable product. downloads are added using upload song action from song page var product = new Product() { Name = model.Name, Price = model.Price, IsDownload = true, UnlimitedDownloads = true, ProductType = ProductType.SimpleProduct, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow, OrderMaximumQuantity = 1, OrderMinimumQuantity = 1, DownloadActivationType = DownloadActivationType.WhenOrderIsPaid }; _productService.InsertProduct(product); //now that product has been saved, let's create a song var song = new Song() { ArtistPageId = model.ArtistPageId, Description = model.Description, AssociatedProductId = product.Id, RemoteEntityId = "", RemoteArtistId = "", RemoteSourceName = "", PageOwnerId = _workContext.CurrentCustomer.Id, Name = model.Name, Published = false }; _songService.Insert(song); return Json( new { Success = true, RedirectTo = Url.RouteUrl("SongUrl", new { SeName = song.GetSeName(_workContext.WorkingLanguage.Id, true, false) }) }); }
public ActionResult ShareSong(int TrackId, string RemoteTrackId = "") { if (!_workContext.CurrentCustomer.IsRegistered()) { //ask user to login if he is logged out return View(ControllerUtil.MobSocialViewsFolder + "_MustLogin.cshtml"); } //check if song exists var song = _songService.GetById(TrackId); SongModel model; if (song == null) { //song is not there. let's first import the song //TODO: Find a way to import the song before it can be shared. The code below slows down the process. so just comment it for now /* if (!string.IsNullOrWhiteSpace(RemoteTrackId)) { //we need to create a new song now var remoteSong = _artistPageApiService.GetRemoteSong(RemoteTrackId); if (remoteSong == null) return InvokeHttp404(); song = SaveRemoteSongToDB(remoteSong); } * */ model = new SongModel() { Name = "", SeName = RemoteTrackId, Id = 0, RemoteEntityId = RemoteTrackId, RemoteSourceName = "", }; } else { model = new SongModel() { Name = song.Name, SeName = song.GetSeName(_workContext.WorkingLanguage.Id, true, false), Id = song.Id, RemoteEntityId = song.RemoteEntityId, RemoteSourceName = song.RemoteSourceName, }; } return View(ControllerUtil.MobSocialViewsFolder + "/SongPage/ShareSong.cshtml", model); }
public IHttpActionResult Index(int id) { var song = _songService.Get(id); if (song == null || (!CanEdit(song) && !song.Published)) return InvokeHttp404(); //not found string affiliateUrl = ""; int trackId; if (int.TryParse(song.TrackId, out trackId)) affiliateUrl = _musicService.GetTrackAffiliateUrl(trackId); var product = _productService.GetProductById(song.AssociatedProductId); var model = new SongModel() { Description = song.Description, Name = song.Name, RemoteEntityId = song.RemoteEntityId, RemoteSourceName = song.RemoteSourceName, TrackId = song.TrackId, Id = song.Id, PreviewUrl = string.IsNullOrEmpty(song.RemoteEntityId) ? song.PreviewUrl : _musicService.GetTrackPreviewUrl(int.Parse(song.TrackId)), AffiliateUrl = affiliateUrl, AssociatedProductId = song.AssociatedProductId, Published = song.Published, Price = product != null ? product.Price : 0, FormattedPrice = product != null ? _priceFormatter.FormatPrice(product.Price, true, _workContext.WorkingCurrency) : "" }; //images for song foreach (var picture in song.Pictures) { model.Pictures.Add(new PictureModel { Id = picture.Id, EntityId = song.Id, PictureId = picture.PictureId, DisplayOrder = picture.DisplayOrder, DateCreated = picture.DateCreated, DateUpdated = picture.DateUpdated, PictureUrl = _pictureService.GetPictureUrl(picture.PictureId, 0, true), }); } if (model.Pictures.Count > 0) model.MainPictureUrl = model.Pictures[0].PictureUrl; else model.MainPictureUrl = _pictureService.GetDefaultPictureUrl(); model.CanEdit = CanEdit(song); model.CanDelete = CanDelete(song); //seo model.MetaTitle = model.Name; model.MetaKeywords = model.Name; model.MetaDescription = string.IsNullOrWhiteSpace(model.Description) ? model.Name : model.Description; return View(ControllerUtil.MobSocialViewsFolder + "/SongPage/Index.cshtml", model); }