public ActionResult <IEnumerable <EngineShow> > Get([FromQuery] EngineSearch query) { try { return(Ok(_getEngines.Execute(query))); } catch (Exception e) { Console.WriteLine(e.Message); return(StatusCode(500)); } }
public IEnumerable <EngineShow> Execute(EngineSearch request) { var engines = Context.Engines.AsQueryable(); if (request.Name != null) { engines.Where(e => e.Name.ToLower() == request.Name.ToLower()); } if (request.CC != null) { engines.Where(e => e.CC == request.CC); } return(engines.Select(e => new EngineShow { Id = e.Id, CC = e.CC, Name = e.Name })); }