Exemple #1
0
        public void BankAccount_Repository_GetAll_ShouldBeOk()
        {
            //Arrange
            var quantity = 1;

            //Action
            var bankAccounts = _repository.GetAll(quantity).ToList();

            //Assert
            bankAccounts.Should().NotBeNull();
            bankAccounts.Should().HaveCount(_context.BankAccounts.Count());
            bankAccounts.First().Should().Be(_bankAccount);
        }
 public Task <List <BankAccountModel> > GetAccounts()
 {
     try
     {
         return(_bankAccountRepository.GetAll());
     }
     catch (Exception ex)
     {
         ex.Log();
         return(null);
     }
 }
        /// <summary>
        ///    <see cref="Microsoft.Samples.NLayerApp.Application.MainBoundedContext.BankingModule.Services.IBankAppService" />
        /// </summary>
        /// <returns>
        ///    <see cref="Microsoft.Samples.NLayerApp.Application.MainBoundedContext.BankingModule.Services.IBankAppService" />
        /// </returns>
        public List <BankAccountDto> FindBankAccounts()
        {
            var bankAccounts = _bankAccountRepository.GetAll();

            if (bankAccounts != null && bankAccounts.Any())
            {
                return(bankAccounts.ProjectedAsCollection <BankAccountDto>());
            }
            else // no results
            {
                return(null);
            }
        }
 // GET: BankAccounts
 public ActionResult Index(int?id)
 {
     if (id == null)
     {
         return(View(bankAccountRepository.GetAll()));
     }
     else
     {
         if (id.HasValue)
         {
             id2 = id.Value;
         }
         List <BankAccount> bankAccount = bankAccountRepository.GetAllbyid(id2);
         return(View(bankAccount));
     }
 }
Exemple #5
0
 public async Task <IList <BankAccountModel> > GetAll()
 {
     return(await _bankAccountRepository.GetAll(UserContext.UserId));
 }
 public IEnumerable <BankAccount> GetAllAccounts()
 {
     return(repository.GetAll());
 }
Exemple #7
0
        public async Task <IActionResult> GetAllBankAccounts(int idUser)
        {
            var bankAccounts = await _bankAccountRepository.GetAll(idUser);

            return(Ok(bankAccounts));
        }
 public IQueryable <BankAccount> GetAll(int quantity)
 {
     return(_repositoryBankAccount.GetAll(quantity));
 }
Exemple #9
0
        public ViewResult All()
        {
            var list = repository.GetAll();

            return(View(list.ToList()));
        }
 public List <BankAccountListViewModel> GetBankAccountsList(string search, string searchField, string orderBy, string sortOrder, int pageNumber, int pageSize)
 {
     return(mapper.Map <List <BankAccountListViewModel> >(bankAccountRepository.GetAll(search, searchField, orderBy, sortOrder, pageNumber, pageSize)));
 }
Exemple #11
0
 public IEnumerable <BankAccount> GetAll([FromServices] IBankAccountRepository bankAccountRepository)
 {
     return(bankAccountRepository.GetAll());
 }
 public List <BankAccount> GetBankAccounts(string userId)
 {
     return(_bankAccountRepository.GetAll(userId).ToList());
 }
        public IActionResult DownloadAccountsInfo()
        {
            var          webPath        = _hostEnvironment.WebRootPath;
            var          user           = _userService.GetCurrent();
            var          path           = Path.Combine(webPath, "TempFile", $"{user.Id}.docx");
            var          pathIntroImage = Path.Combine(webPath, "image/bank/bank_cards.png");
            var          pathLineImage  = Path.Combine(webPath, "image/separatingLine.png");
            var          countRows      = 6;
            var          accounts       = _bankAccountRepository.GetAll().Where(x => x.Owner.Id == user.Id).ToList();
            var          accountsNumber = 1;
            var          colorNow       = 0;
            Border       slimLine       = new Border(BorderStyle.Tcbs_single, BorderSize.one, 0, Color.Black);
            Border       boldLine       = new Border(BorderStyle.Tcbs_single, BorderSize.seven, 0, Color.Black);
            List <Color> colorList      = new List <Color>()
            {
                Color.OrangeRed,
                Color.CadetBlue,
                Color.LightGreen,
                Color.PeachPuff,
                Color.Aqua,
                Color.RosyBrown
            };

            using (var doc = DocX.Create(path))
            {
                var picIntro = doc.AddImage(pathIntroImage, "image/png").CreatePicture();
                picIntro.Width  = 600;
                picIntro.Height = 150;
                doc.InsertParagraph().InsertPicture(picIntro);

                doc.InsertParagraph($"Детали всех счетов (всего: {accounts.Count})")
                .Font("Comic Sans MS")
                .Bold()
                .FontSize(25)
                .Alignment = Alignment.center;
                doc.InsertParagraph("");

                var picLine = doc.AddImage(pathLineImage, "image/png").CreatePicture();
                picLine.Width  = 600;
                picLine.Height = 50;
                doc.InsertParagraph().InsertPicture(picLine);
                doc.InsertParagraph("");

                foreach (var account in accounts)
                {
                    doc.InsertParagraph().Append($"Счет №{accountsNumber++} - {account.Name}").Bold().FontSize(16).Italic().Alignment = Alignment.center;

                    var table = doc.InsertTable(countRows, 2);

                    table.Rows[0].Cells[0].Paragraphs.First().Append("Account name").Bold().FontSize(14).Italic();
                    table.Rows[1].Cells[0].Paragraphs.First().Append("Currency").Bold().FontSize(14).Italic();
                    table.Rows[2].Cells[0].Paragraphs.First().Append("Amount").Bold().FontSize(14).Italic();
                    table.Rows[3].Cells[0].Paragraphs.First().Append("Account number").Bold().FontSize(14).Italic();
                    table.Rows[4].Cells[0].Paragraphs.First().Append("Creation date").Bold().FontSize(14).Italic();
                    table.Rows[5].Cells[0].Paragraphs.First().Append("Expiry date").Bold().FontSize(14).Italic();


                    for (int i = 0; i < countRows; i++)
                    {
                        table.Rows[i].Cells[0].FillColor = colorList[colorNow];
                    }
                    if (++colorNow == colorList.Count())
                    {
                        colorNow = 0;
                    }

                    table.Rows[0].Cells[1].Paragraphs.First().Append(account.Name).FontSize(12).Alignment = Alignment.center;
                    table.Rows[1].Cells[1].Paragraphs.First().Append(account.Currency.ToString()).FontSize(12).Alignment     = Alignment.center;
                    table.Rows[2].Cells[1].Paragraphs.First().Append(account.Amount.ToString()).FontSize(12).Alignment       = Alignment.center;
                    table.Rows[3].Cells[1].Paragraphs.First().Append(account.AccountNumber).FontSize(12).Alignment           = Alignment.center;
                    table.Rows[4].Cells[1].Paragraphs.First().Append(account.CreationDate.ToString()).FontSize(12).Alignment = Alignment.center;
                    table.Rows[5].Cells[1].Paragraphs.First().Append(account.ExpireDate.ToString()).FontSize(12).Alignment   = Alignment.center;

                    table.SetBorder(TableBorderType.InsideH, slimLine);
                    table.SetBorder(TableBorderType.InsideV, slimLine);
                    table.SetBorder(TableBorderType.Bottom, boldLine);
                    table.SetBorder(TableBorderType.Top, boldLine);
                    table.SetBorder(TableBorderType.Left, boldLine);
                    table.SetBorder(TableBorderType.Right, boldLine);

                    table.Alignment = Alignment.center;
                    doc.InsertParagraph();
                }

                doc.Save();
            }

            var contentTypeDocx = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
            var fileName        = "Info about accounts.docx";

            return(PhysicalFile(path, contentTypeDocx, fileName));
        }