public async Task <IActionResult> DeleteRecommendation(int id) { var recommendation = await _repo.GetRecommendation(id); _repo.Delete(recommendation); if (await _repo.SaveAll()) { return(NoContent()); } return(BadRequest("Failed to Delete recommendation")); }
public async Task <IActionResult> BlacklistInvite(int id, bool blacklist = true) { var inviteFromRepo = await _repo.GetInviteDetails(id); inviteFromRepo.IsBlacklisted = blacklist; if (await _repo.SaveAll()) { return(NoContent()); } return(BadRequest("Failed to Blacklist User")); }
public async Task <IActionResult> SaveSong(int userId, int songId) { if (userId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized()); } var savedSong = await _repo.GetSavedSong(userId, songId); if (savedSong != null) { return(BadRequest("You already saved this song")); } if (await _repo.GetSong(songId) == null) { return(NotFound()); } savedSong = new SavedSong { UserId = userId, SongId = songId }; _repo.Add <SavedSong>(savedSong); if (await _repo.SaveAll()) { return(Ok()); } return(BadRequest("Failed to save song")); }
public async Task <IActionResult> UpdateInvite(int id, InviteUpdateDto inviteDetails) { var invite = await _repo.GetInviteDetails(id); invite.fromUpdateDto(inviteDetails, _mapper); if (await _repo.SaveAll()) { return(NoContent()); } return(BadRequest("Failed to Post RSVP")); }
public async Task <IActionResult> UpdateLineup(int id, LineupForUpdateDto lineupForUpdateDto) { if (id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized()); } var lineupFromRepo = await _repo.GetLineup(id); _mapper.Map(lineupForUpdateDto, lineupFromRepo); if (await _repo.SaveAll()) { return(NoContent()); } throw new Exception($"Updating lineup {id} failed on save"); }