private TagInfo GetTag(Models.Recording recording) { using (File file = File.Create(_fileAbstractionFactory(recording.Path, false))) { return(new TagInfo { Tag = file.Tag, Properties = file.Properties }); } }
public object Get(Download download) { if (download.Uid == null) { throw new ArgumentNullException("id"); } Models.Recording recording = _recordingRepository.GetById(download.Uid); var isAuthenticated = UserSession.IsAuthenticated; if (recording.Restricted && !isAuthenticated) { return(HttpResult.Redirect("/Login".AddQueryParam("redirect", Request.AbsoluteUri))); } FileInfo fileInfo = new FileInfo(recording.Path); string contentType = GetMimeType(fileInfo.Name); return(new HttpResult(fileInfo, contentType, true)); }
//public object Get(SpeakersPartial speakersPartial) //{ // return new SpeakersPartialResponse {Speakers = _recordingRepository.GetSpeakers(UserSession.IsAuthenticated), Selected = speakersPartial.Selected}; //} public object Get(Stream stream) { if (stream.Id == null) { throw new ArgumentNullException("id"); } string[] idParts = stream.Id.Split('/'); Models.Recording recording = _recordingRepository.GetById(idParts[0]); var isAuthenticated = UserSession.IsAuthenticated; if (recording.Restricted && !isAuthenticated) { return(HttpResult.Redirect("/Login".AddQueryParam("redirect", Request.AbsoluteUri))); } FileInfo fileInfo = new FileInfo(recording.Path); string contentType = GetMimeType(fileInfo.Name); return(new HttpResult(fileInfo, contentType)); }
public async Task<IHttpActionResult> Update( [FromBody] RecordingEditCore newData ) { // Create var recording = new Models.Recording { Description = GetEmptyAsNull( newData.Description ), RentTo = GetEmptyAsNull( newData.RentTo ), Name = GetEmptyAsNull( newData.Name ), Store = GetOrCreateStore( newData ), SeriesIdentifier = newData.Series, CreationTime = DateTime.UtcNow, }; // Remember it - must be done before we try to add links or EF will not be able to create the foreign key reference correctly Database.Recordings.Add( recording ); // Multi-value collections recording.Languages = Database.Languages.Where( l => newData.Languages.Contains( l.UniqueIdentifier ) ).ToList(); recording.Genres = Database.Genres.Where( g => newData.Genres.Contains( g.UniqueIdentifier ) ).ToList(); recording.Links = newData.Links.Select( l => l.ToModel() ).ToList(); // Process update await Database.SaveChangesAsync(); // Done return Ok(); }