/// <summary> /// Build and persist a new <see cref="AudioFile"/>. /// </summary> /// <param name="audioFile">A new <see cref="AudioFile"/></param> /// <returns>The persisted Audio File.</returns> public AudioFile CreateAudioFile(AudioFile audioFile) { this._persistence.GetRepository<AudioFile>().Add(audioFile); this._persistence.Commit(); return audioFile; }
public async Task<ActionResult> AddAudioFile(AudioFile audioFile, int exhibitId, int languageId, int knowledgeLevelId, HttpPostedFileBase postedAudioFile) { //upload file & return file path string filePath = Path.Combine(ConfigurationManager.AppSettings["AudioPath"], postedAudioFile.FileName); var saveTask = Task.Factory.StartNew(() => postedAudioFile.SaveAs(filePath)); audioFile.FilePath = filePath; audioFile.FileName = postedAudioFile.FileName; audioFile.Exhibit = this._exhibitService.GetExhibit(exhibitId); audioFile.Language = this._languageService.GetLanguage(languageId); audioFile.KnowledgeLevel = this._knowledgeLevelService.GetKnowledgeLevel(knowledgeLevelId); this._audioFileService.CreateAudioFile(audioFile); await saveTask; return this.RedirectToAction("Index", "Audio"); }