Beispiel #1
0
        public async Task <Result <Customer> > GetCustomerByIdAsync(int customerId)
        {
            var customer = await _dbContext.Set <Customer>()
                           .Where(c => c.CustomerId == customerId)
                           .Include(c => c.Accounts)
                           .SingleOrDefaultAsync();

            if (customer != null)
            {
                return(new Result <Customer>()
                {
                    Code = ResultCodes.Success,
                    Data = customer
                });
            }
            else
            {
                return(new Result <Customer>()
                {
                    Code = ResultCodes.NotFound,
                    Message = $"Den vrethike pelatis me kodiko {customerId}"
                });
            }
        }
        public async Task <Result <Transaction> > GetTransactionByIdAsync(int transactionId)
        {
            var transaction = await _dBContext.Set <Transaction>()
                              .Where(t => t.TransactionId == transactionId)
                              .SingleOrDefaultAsync();

            if (transaction != null)
            {
                return(new Result <Transaction>()
                {
                    Code = ResultCodes.Success,
                    Data = transaction
                });
            }
            else
            {
                return(new Result <Transaction>()
                {
                    Code = ResultCodes.BadRequest,
                    Message = $"Den iparxei transactionId me kodiko {transactionId}."
                });
            }
        }
        public async Task <Result <Account> > GetAccountByIdAsync(int accountId)
        {
            var account = await _dBContext.Set <Account>()
                          .Where(a => a.AccountId == accountId)
                          .Include(a => a.Transactions)
                          .SingleOrDefaultAsync();

            if (account != null)
            {
                return(new Result <Account>()
                {
                    Code = ResultCodes.Success,
                    Data = account
                });
            }
            else
            {
                return(new Result <Account>()
                {
                    Code = ResultCodes.BadRequest,
                    Message = $"Den ipaxei account me kodiko {accountId}."
                });
            }
        }