Guest User

Untitled

a guest
Mar 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. public class MembersController : ApiController
  2. {
  3. public HttpResponseMessage GetAllMembersByIdentifiers(string[] ids) {
  4. using (sampleEntities entities = new sampleEntities()){
  5. var numbers = entities.tblmembers
  6. .Where(p => ids.Contains(p.identify) ).ToList();
  7.  
  8. if (numbers != null)
  9. {
  10. return Request.CreateResponse(HttpStatusCode.OK, numbers);
  11. }
  12. else
  13. {
  14. return Request.CreateErrorResponse(HttpStatusCode.NotFound, "Member with id: " + ids + " not found");
  15. }
  16. }
  17. }
  18. }
  19.  
  20. 98989794, //<---
  21. 4343545345
  22.  
  23. public class MembersController : ApiController
  24. {
  25.  
  26. [HttpGet]
  27. [Route("api/Members/Find/{ids}")]
  28. public HttpResponseMessage FindMemebers([FromUri]string[] ids) {
  29.  
  30.  
  31. // CHECK THE ARRAY NOT EMPTY
  32. if(!ids.Any() || ids.All(xx=> string.isNullOrEmpty(xx)) return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "empty params");
  33.  
  34. using (sampleEntities entities = new sampleEntities()){
  35. var numbers = entities.tblmembers
  36. .Where(p => ids.Contains(p.identify) ).ToList();
  37.  
  38. if (numbers != null)
  39. {
  40. return Request.CreateResponse(HttpStatusCode.OK, numbers);
  41. }
  42. else
  43. {
  44. return Request.CreateErrorResponse(HttpStatusCode.NotFound, "Member with id: " + ids + " not found");
  45. }
  46. }
  47. }
  48. }
  49.  
  50. public HttpResponseMessage FindMemebers([FromUri]List<string> ids) { ...
Add Comment
Please, Sign In to add comment