public async Task <ActionResult> GetPocketStatus(string accountNumber, [FromQuery] GetPocketStatusDTO request) { if (string.IsNullOrEmpty(accountNumber) || accountNumber != request.MasterAccount) { ModelState.AddModelError("", AccountNotFoundException.DefaultErrorMessage); return(BadRequest(ModelState)); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var resultDTO = await PocketService.GetPocketStatusAsync(request); return(new JsonResult(resultDTO)); } catch (Exception ex) { return(HandleException(ex)); } }
public async Task <StatusResultDTO> GetPocketStatusAsync(GetPocketStatusDTO request) { var holder = await DbContext .Holders .SingleOrDefaultAsync(h => h.MasterAccount == request.MasterAccount && h.PINCode == request.PinCode); if (holder == null) { throw new AccountNotFoundException(); } await DbContext.Entry(holder).Collection(h => h.Accounts).LoadAsync(); return(new StatusResultDTO { Deposits = holder.Accounts.Select(a => new DepositItemDTO { AccountNumber = a.Number, Currency = a.Currency, Sum = a.Debit }) }); }