public async Task <ActionResult <MusicRecords> > PostMusicRecord(MusicRecords musicRecords) { _context.InMemoryMusicRecords.Add(musicRecords); await _context.SaveChangesAsync(); return(CreatedAtAction("GetInMemoryRecord", new { id = musicRecords.Id }, musicRecords)); }
public async Task <IActionResult> PutMusicRecord(int id, MusicRecords musicRecords) { if (id != musicRecords.Id) { return(BadRequest()); } _context.Entry(musicRecords).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MusicRecordsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void Delete(int id) { MusicRecords music = Get(id); //musicList.Remove(music); _context.InMemoryMusicRecords.ToList().Remove(music); }
private static MusicRecordsDTO RecordsToDTO(MusicRecords musicRecords) => new MusicRecordsDTO { Id = musicRecords.Id, Duration = musicRecords.Duration, YearOfPublication = musicRecords.YearOfPublication, Artist = musicRecords.Artist, Title = musicRecords.Title };
public void Delete(string title) { MusicRecords mr = Get(title); if (mr != null) { mList.Remove(mr); } }
public void Post([FromBody] MusicRecords value) { MusicRecords newRecord = Get(value.Id); if (newRecord == null) { _context.InMemoryMusicRecords.ToList().Add(value); } //musicList.Add(value) }
public void Put(string title, [FromBody] MusicRecords value) { MusicRecords mr = Get(title); if (mr != null) { mr.Title = value.Title; mr.Artist = value.Artist; mr.Duration = value.Duration; mr.PublishDate = value.PublishDate; mr.Genre = value.Genre; } }
public async Task <ActionResult <MusicRecords> > PostMusicRecords(MusicRecordsDTO musicRecordsDTO) { var todoRecords = new MusicRecords { Artist = musicRecordsDTO.Artist, Title = musicRecordsDTO.Title, Duration = musicRecordsDTO.Duration, YearOfPublication = musicRecordsDTO.YearOfPublication }; _context.MusicRecordsList.Add(todoRecords); await _context.SaveChangesAsync(); return(CreatedAtAction("GetMusicRecords", new { id = todoRecords.Id }, RecordsToDTO(todoRecords))); }
public void Put(int id, [FromBody] MusicRecords value) { MusicRecords music = Get(id); if (music != null) { //music.Id = value.Id; //music.Title = value.Title; //music.Artist = value.Artist; //music.Album = value.Album; //music.DurationInSeconds = value.DurationInSeconds; //music.RecordLabel = value.RecordLabel; //music.YearOfPublication = value.YearOfPublication; _context.Entry(value).State = EntityState.Modified; } }
public void Post([FromBody] MusicRecords value) { mList.Add(value); }
public void InitTestMusic() { _testMusicController = new MusicRecordsController(dbContext); _testMusic = new MusicRecords(8, "UnitTest", "Test", "Test", "Test Records", 69, 2020); _testMusicController.PostMusicRecords(_testMusic); }