Skip to content

Instantly share code, notes, and snippets.

@samueleresca
Created December 3, 2015 21:12
Show Gist options
  • Save samueleresca/c334ed754e3507e52d81 to your computer and use it in GitHub Desktop.
Save samueleresca/c334ed754e3507e52d81 to your computer and use it in GitHub Desktop.
//CharacterController.cs
public class CharacterController : ApiController
{
public IEnumerable GetCharacters()
{
return DataRepository.Characters;
}
public IEnumerabl GetCharacter(int characterId)
{
return DataRepository.Characters.Where(
cus => cus.TelefilmId == characterId);
}
public IEnumerable GetCharacter(string lastName)
{
return DataRepository.Characters.Where(
cus => cus.LastName.ToLower().Contains(lastName.ToLower()));
}
}
//TelefilmController.cs
public class TelefilmController : ApiController
{
public IEnumerable GetTelefilms() {
return DataRepository.Telefilms;
}
public Telefilm GetTelefilm(int telefilmId)
{
Telefilm result = DataRepository.Telefilms.SingleOrDefault(
acc => acc.TelefilmId == telefilmId);
if (result == null)
{
throw new HttpResponseException(HttpStatusCode.NotFound);
}
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment