Removed unused channel controller methords

This commit is contained in:
hak8or 2018-02-23 23:15:01 -05:00
parent 8b148b1ad9
commit a37fe30b6f
1 changed files with 0 additions and 72 deletions

View File

@ -50,77 +50,5 @@ namespace YTManager.Controllers {
// Convert all the videos to what we will send back.
return Ok(converted);
}
// GET api/Channels/sdfs6DFS65f
[HttpGet("{YTchannelID}")]
public async Task<IActionResult> Get([FromQuery] string YTchannelID) {
var channel = await db.Channels.SingleOrDefaultAsync(c => c.YoutubeID == YTchannelID);
if (channel == null)
return NotFound();
else
return Ok(channel);
}
// GET: api/Channels/sdfs6DFS65f/Videos (using YouTube channel ID)
[HttpGet("{YTChannelID}/Videos")]
public async Task<IActionResult> GetVideos([FromRoute] string YTchannelID) {
if (!ModelState.IsValid)
return BadRequest(ModelState);
// Attempt to get the video from the database.
var channel = await db.Channels.SingleOrDefaultAsync(m => m.YoutubeID == YTchannelID);
// If the channel wasn't found then send back not found.
if (channel == null)
return NotFound();
// Send back the videos from the channel.
return Ok(db.Entry(channel).Collection(c => c.Videos).LoadAsync());
}
// POST api/Channels/sdfs6DFS65f
[HttpPost("{YTchannelID}")]
public async Task<IActionResult> Post([FromRoute] string YTchannelID) {
// Check if we were able to parse.
if (!ModelState.IsValid) return BadRequest(ModelState);
// Verify the channel doesn't already exist.
if (db.Channels.Any(c => c.YoutubeID == YTchannelID))
return BadRequest();
// Get the channel info.
var ch = await Tasks.FetchVideos.Get_YTChannel(YTchannelID);
// Seems good, so add it.
db.Channels.Add(ch);
await db.SaveChangesAsync();
// And all is well.
return Ok();
}
// DELETE api/Channels/5
[HttpDelete("{YTChannelID}")]
public async Task<IActionResult> Delete([FromRoute] string YTChannelID) {
// Check if we were able to parse.
if (!ModelState.IsValid) return BadRequest(ModelState);
// Attempt to find the channel.
var channel = await db.Channels.Include(c => c.Videos).SingleOrDefaultAsync(c => c.YoutubeID == YTChannelID);
// Check if such an entry exists already.
if (channel == null)
return NotFound();
// Remove all the channels videos.
channel.Videos.ForEach(v => db.Videos.Remove(v));
// Remove the channel itself.
db.Channels.Remove(channel);
// Save all the changes.
await db.SaveChangesAsync();
return Ok(channel);
}
}
}