public void AddAccount(int clientId, Currency currency, decimal amount, decimal rate = 0)
 {
     using var transaction = context.Database.BeginTransaction();
     try
     {
         var account = new LegalPersonAccount(clientId, currency, amount, rate);
         context.LegalPersonAccounts.Add(account);
         context.SaveChanges();
         context.LegalPersonAccountArchives.Add(new LegalPersonAccountArchive(amount, Operation.AddAccount,
                                                                              account.Id));
         context.SaveChanges();
         transaction.Commit();
     }
     catch (Exception e)
     {
         throw new Exception($"Произошла ошибка при добавлении счета: {e.Message}");
     }
 }
Beispiel #2
0
        /// <summary>
        /// Тестовые данные для заполнения таблиц.
        /// </summary>
        public void FillAllTables()
        {
            using (BankContext context = new BankContext())
            {
                context.PhysicalPersonClients.Add(
                    new PhysicalPersonClient("Леонид", "Кравцов", "Григорьевич", new DateTime(1990, 02, 28),
                                             ClientType.Vip)
                    );
                context.PhysicalPersonClients.Add(
                    new PhysicalPersonClient("Николай", "Савелин", "Константинович", new DateTime(1987, 4, 22),
                                             ClientType.Usual)
                    );

                context.LegalPersonClients.Add(
                    new LegalPersonClient("ОАО Прогрессивные технологии", ClientType.Usual)
                    );
                context.LegalPersonClients.Add(
                    new LegalPersonClient("ООО Сельхозстрой", ClientType.Vip)
                    );
                context.SaveChanges();
            }
        }