public async Task <ActionResult <Track> > Post([FromBody] Track track) { track.Id = await _repo.GetNextId(); track.AirDistance = _geoService.AirDistance((double)track.StartLat, (double)track.StartLng, (double)track.EndLat, (double)track.EndLng); await _repo.Create(track); return(new OkObjectResult(track)); }
public async Task Upload(string path) { if (string.IsNullOrEmpty(path)) { return; } byte[] buffer; var file = TagLib.File.Create(path); using (var fileStream = file.FileAbstraction.ReadStream) using (var stream = new MemoryStream()) { await fileStream.CopyToAsync(stream); buffer = stream.ToArray(); } var track = new Track { Artist = file.Tag.FirstPerformer, Title = file.Tag.Title, Data = buffer }; await trackRepository.Create(track); }
public async Task <ActionResult> CreateAnalyticsResult([FromBody] SiddhiOutputModel siddhiOutput) { var analyticsResult = siddhiOutput.Event; analyticsResult.Id = await _repo.GetNextAnalyticsResultId(); await _repo.Create(analyticsResult); Console.WriteLine(analyticsResult.Id + " " + analyticsResult.RecordId + " " + analyticsResult.Status + "\n"); Command command = null; if (analyticsResult.Status == "Danger") { command = new Command(1); } else { command = new Command(0); } command.DateTime = DateTime.Now; command.RecordId = analyticsResult.RecordId; command.Status = analyticsResult.Status; //_ = _hub.Clients.Group("CommandRoom").SendAsync("commands", command); _analyticCommandSender.Send(command); return(Ok("Analytics result successfully saved to database")); }
public async Task <IActionResult> Post([FromBody] TrackCreateDTO trackCreateDTO) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var id = await repository.Create(trackCreateDTO); return(CreatedAtAction(nameof(Get), new { id }, null)); }
public TrackDto Create(TrackDto entity) { using (_trackRepository) { var entityToCreate = entity.ConvertToTrackDbModel(); _trackRepository.Create(entityToCreate); _trackRepository.SaveChanges(); return(entityToCreate.ConvertToTrackDto()); } }
public async Task UndefinedLanguageSlugTest() { await _repository.Create(new Track { ID = 5, TrackIndex = 0, Type = StreamType.Video, Language = null, EpisodeID = TestSample.Get <Episode>().ID }); Track track = await _repository.Get(5); Assert.Equal("anohana-s1e1.und.video", track.Slug); }
public string UploadTrack(UploadTrackDto trackDto) { var uploader = _userRepository.GetByName(trackDto.UploaderUserName); var track = _trackFactory.Produce(trackDto); track.Uploader = uploader; var existingUrlIds = _trackRepository.GetTrackTitles(uploader.Id); track.UrlId = UrlIdGenerator.Generate(track.Title, existingUrlIds); _trackRepository.Create(track); return(track.UrlId); }
/// <summary> /// Set track's index and ensure that every tracks is well-formed. /// </summary> /// <param name="resource">The resource to fix.</param> /// <returns>The <paramref name="resource"/> parameter is returned.</returns> private async Task <Episode> _ValidateTracks(Episode resource) { if (resource.Tracks == null) { return(resource); } resource.Tracks = await resource.Tracks.SelectAsync(x => { x.Episode = resource; return(_tracks.Create(x)); }).ToListAsync(); _database.Tracks.AttachRange(resource.Tracks); return(resource); }
public async Task <bool> Seed() { var rng = new Random(); var listaGeneros = new List <string> () { "pop", "mpb", "classical", "rock" }; _ = await _trackRepository.DeleteAll(); foreach (var genero in listaGeneros) { var recommendations = GetRecommendations(null, new List <string> () { genero }, null, null, null, null, 50, string.Empty); foreach (var item in recommendations.Tracks) { var name = item.Name; var artistName = item.Artists.First().Name; var genre = await _genreRepository.GetByNameAsync(genero); var oTrack = new Track() { Name = item.Name, NameOfArtist = item.Artists.First().Name, IdGenre = genre.Id, Price = rng.Next(1, 60) }; try { _ = _trackRepository.Create(oTrack); } catch (System.Exception) { continue; } } } return(true); }
public int Create(Track track) { return(_trackRepository.Create(track)); }