public ListenTo.Shared.DO.Track Adapt(TrackMetaData trackMetaData) { Track track = new Track(); track.ID = trackMetaData.ID; track.Artist = trackMetaData.Artist; track.Created = trackMetaData.Created; track.Description = trackMetaData.Description; track.Engineer = trackMetaData.Engineer; track.Name = trackMetaData.Name; track.OwnerID = trackMetaData.OwnerID; track.Studio = trackMetaData.Studio; track.Style = trackMetaData.Style; track.Producer = trackMetaData.Producer; return track; }
public RedirectToRouteResult RedirectToTrack(Track track) { return RedirectToRoute(Routes.ARTIST_MUSIC, new { id = track.ID, name = track.Artist.ProfileAddress }); }
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { HttpRequestBase request = controllerContext.HttpContext.Request; string prefix = ModelBinderHelpers.GetPrefixForCustomModelBinder(bindingContext); Track track = null; if (bindingContext.Model == null) { track = new Track(); string trackId = ModelBinderHelpers.GetValueAndUpdateModelState<string>(bindingContext, prefix + "ID"); if (FormatHelpers.IsGuid(trackId)) { track.ID = new Guid(trackId); } else { track.ID = Guid.NewGuid(); } } else { track = (Track)bindingContext.Model; } track.Name = ModelBinderHelpers.GetValueAndUpdateModelState<string>(bindingContext, prefix + "Name"); track.Description = ModelBinderHelpers.GetValueAndUpdateModelState<string>(bindingContext, prefix + "Description"); //Grab the style Guid? styleId = ModelBinderHelpers.GetValueAndUpdateModelState<Guid?>(bindingContext, "SelectedStyle"); ListenTo.Shared.DO.Style style = null; if (styleId.HasValue && styleId.Value != Guid.Empty) { style = StyleManager.GetByID(styleId.Value); track.Style = style; } //Grab the artist string artistId = ModelBinderHelpers.GetValueAndUpdateModelState<string>(bindingContext, prefix + "OwnedArtist"); ListenTo.Shared.DO.Artist artist = null; if (FormatHelpers.IsGuid(artistId)) { artist = ArtistManager.GetByID(new Guid(artistId)); track.Artist = artist; } //The following block of code can be moved into an injectable strategy once we need to use it again.... //HttpPostedFileBase file = ListenTo.Web.Helpers.FileHelpers.GetFileFromRequest(controllerContext.HttpContext.Request); //if (file != null && file.ContentLength>0) //{ // byte[] content = ListenTo.Web.Helpers.FileHelpers.GetContentFromHttpPostedFile(file); // track.Data = content; // //Create a temporary file // TemporaryFileStrategy.Create(track); //} //else //{ // //Do we have a temp file, if so repopulate...... // track = (Track)TemporaryFileStrategy.Fetch(track); //} track.Created = DateTime.Now; OwnershipHelpers.SetOwner((IOwnableDO)track, controllerContext.HttpContext.User); return track; }