Compare commits
2 Commits
3906d70eca
...
6e9e819b8d
Author | SHA1 | Date | |
---|---|---|---|
6e9e819b8d | |||
c95baa32e2 |
@ -59,13 +59,54 @@ namespace BankDatabaseImplement.Implements
|
||||
using var context = new BankDatabase();
|
||||
var newWithdrawal = Withdrawal.Create(context, model);
|
||||
if (newWithdrawal == null)
|
||||
{
|
||||
return null;
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
//MakeWithdrawal(context, model);
|
||||
context.Withdrawals.Add(newWithdrawal);
|
||||
}
|
||||
context.Withdrawals.Add(newWithdrawal);
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
context.SaveChanges();
|
||||
return newWithdrawal.GetViewModel;
|
||||
}
|
||||
transaction.Commit();
|
||||
return newWithdrawal.GetViewModel;
|
||||
}
|
||||
|
||||
//private bool MakeWithdrawal(BankDatabase context, WithdrawalBindingModel model)
|
||||
//{
|
||||
// if (model == null)
|
||||
// return false;
|
||||
// var dictionary = model.WithdrawalAccounts;
|
||||
// int count = model.Sum;
|
||||
// foreach (var el in dictionary)
|
||||
// {
|
||||
// int dif = count;
|
||||
// if (el.Count < dif)
|
||||
// dif = el.Count;
|
||||
// el.Count -= dif;
|
||||
// count -= dif;
|
||||
// if (el.Count == 0)
|
||||
// {
|
||||
// dictionary.Add(el);
|
||||
// }
|
||||
// if (count == 0)
|
||||
// break;
|
||||
// }
|
||||
// if (count > 0)
|
||||
// {
|
||||
// transaction.Rollback();
|
||||
// return false;
|
||||
// }
|
||||
// foreach (var el in dictionary)
|
||||
// {
|
||||
// context.ShopManufactures.Remove(el);
|
||||
// }
|
||||
// return true;
|
||||
//}
|
||||
|
||||
public WithdrawalViewModel? Update(WithdrawalBindingModel model)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user