Example #1
0
        private async Task <List <MEMBER> > GetMembersByBookIdAsync(int bookId, CancellationToken ct = default(CancellationToken))
        {
            return(await Task.Run(() =>
            {
                List <MEMBER> output = new List <MEMBER>();
                string methodName = MethodBase.GetCurrentMethod().GetName();
                var sw = Stopwatch.StartNew();

                try
                {
                    var dbResponse = _membersRepository.GetMembersByBookId(bookId);
                    if (dbResponse?.Success ?? false)
                    {
                        output = dbResponse.Items;
                    }

                    return output;
                }
                catch (Exception ex)
                {
                    LogEngine.CLILogger.WriteToLog(LogLevels.Error, $"DAL.Exception: {JsonConvert.SerializeObject(ex)}");
                    return output = new List <MEMBER>();
                }
                finally
                {
                    sw.Stop();
                    LogEngine.CLILogger.WriteToLog(LogLevels.Debug, $"BLL.{methodName}(OUT={output}) in {sw.ElapsedMilliseconds}ms");
                }
            }, ct).ConfigureAwait(true));
        }