/// <inheritdoc /> public async Task <ServiceResult <Card> > AddCardAsync(int packageId, string question, string answer) { Card card = new Card() { PackageId = packageId, Question = question, Answer = answer, Proficiency = 0, UpdateTime = DateTime.MinValue }; var connection = _connectionService.GetAsyncConnection(); try { await connection.Result.InsertAsync(card); } catch (SQLiteException e) { return(new ServiceResult <Card>() { Status = ServiceResultStatusHelper.FromSQLiteResult(e.Result), Message = e.Message, Result = null }); } return(new ServiceResult <Card>() { Status = ServiceResultStatus.OK, Message = "Success", Result = card }); }
/// <inheritdoc /> public ServiceResult <SQLiteAsyncConnection> GetAsyncConnection() { SQLiteAsyncConnection connection; try { connection = new SQLiteAsyncConnection("CardsForMemory"); } catch (SQLiteException e) { return(new ServiceResult <SQLiteAsyncConnection> { Status = ServiceResultStatusHelper.FromSQLiteResult(e.Result), Message = e.Message }); } return(new ServiceResult <SQLiteAsyncConnection> { Result = connection, Status = ServiceResultStatus.OK }); }
/// <inheritdoc /> public async Task <ServiceResult> InsertAsyncCard(Card card) { var connection = _connectionService.GetAsyncConnection(); try { await connection.Result.InsertAsync(card); } catch (SQLiteException e) { return(new ServiceResult() { Status = ServiceResultStatusHelper.FromSQLiteResult(e.Result), Message = e.Message }); } return(new ServiceResult() { Status = ServiceResultStatus.OK, Message = "Success" }); }