public async Task <ActionResult> DeleteEventMusics( [FromServices] DataContext context, [FromServices] EventRepository eventRepository, [FromServices] MusicRepository musicRepository, int eventId, int musicId) { try { var eventExists = eventRepository.CheckExistsById(eventId); if (!eventExists) { return(NotFound(new { message = "O Evento não foi localizado." })); } var musicExists = musicRepository.CheckExistsById(musicId); if (!musicExists) { return(NotFound(new { message = "A música não foi localizada." })); } eventRepository.DeleteMusic(eventId, musicId); await context.SaveChangesAsync(); return(Ok()); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, new { message = ErrorMessage.Internal })); } }
public async Task <ActionResult> DeleteEventUsers( [FromServices] DataContext context, [FromServices] EventRepository eventRepository, [FromServices] UserRepository userRepository, int eventId, int userId) { try { var eventExists = eventRepository.CheckExistsById(eventId); if (!eventExists) { return(NotFound(new { message = "O Evento não foi localizado." })); } var userExists = userRepository.CheckExistsById(userId); if (!userExists) { return(NotFound(new { message = "O integrante não foi localizado." })); } eventRepository.DeleteUser(eventId, userId); await context.SaveChangesAsync(); return(Ok()); } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError, new { message = ErrorMessage.Internal })); } }