public Models.Command GetById(int id) { Models.Command foundedCommand = commands .Where(current => current.Id == id) .FirstOrDefault(); return(foundedCommand); }
/* these are not Async so... * public System.Collections.Generic.IEnumerable<Models.Command> GetAll() * { * return Commands; * * } * * public Models.Command GetId(int Id) * { * Models.Command foundedCommand = * Commands. * Where(current => current.Id == Id). * FirstOrDefault(); * * return foundedCommand; * } */ public async System.Threading.Tasks.Task <Models.Command> GetIdAsync(int Id) { /* this is for Async database * Models.Command foundedCommand = * await Mydatabasecontext.Commands. * Where(current => current.Id == Id). * FirstOrDefaultAsnc(); */ Models.Command foundedCommand = null; await System.Threading.Tasks.Task.Run(() => { foundedCommand = Commands .Where(current => current.Id == Id) .FirstOrDefault(); }); return(foundedCommand); }