Created
December 3, 2015 21:12
-
-
Save samueleresca/c334ed754e3507e52d81 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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