Beispiel #1
0
        public static async void AddBankAccount(User owner, string name, decimal money)
        {
            var lockingobject = new object();

            Monitor.Enter(lockingobject);
            try
            {
                await Task.Run(() =>
                {
                    Interfaces.IDataService _dataService = DataService.GetDataService();
                    BankAccount user = new BankAccount()
                    {
                        Money = money,
                        Name  = name,
                        Owner = owner
                    };
                    _dataService.AddBankaccounts(user);
                });
            }
#pragma warning disable CS0168 // Variable is declared but never used
            catch (Exception ex)
#pragma warning restore CS0168 // Variable is declared but never used
            {
                GeneralMethods.GeneralMethods.ShowGeneralErrorMessage();
            }
            finally
            {
                Monitor.Exit(lockingobject);
            }
        }
Beispiel #2
0
        public static async Task AddBankAccount(User owner, string name, decimal money, bool dummyornot)
        {
            var lockingobject = new object();

            Monitor.Enter(lockingobject);
            try
            {
                if (dummyornot == false)
                {
                    await Task.Run(() =>
                    {
                        Interfaces.IDataService _dataService = DataService.GetDataService();
                        BankAccount user = new BankAccount()
                        {
                            Id             = Guid.NewGuid().ToString(),
                            Money          = money,
                            Name           = name,
                            Owner          = owner,
                            dummyaccount   = false,
                            dateofcreation = DateTime.Now
                        };
                        _dataService.AddBankaccounts(user);
                    });
                }
                else
                {
                    await Task.Run(() =>
                    {
                        Interfaces.IDataService _dataService = DataService.GetDataService();
                        BankAccount user = new BankAccount()
                        {
                            Id             = Guid.NewGuid().ToString(),
                            Money          = money,
                            Name           = name,
                            Owner          = owner,
                            dummyaccount   = false,
                            dateofcreation = DateTime.Now
                        };
                        _dataService.AddBankaccounts(user);
                    });
                }
            }
#pragma warning disable CS0168 // Variable is declared but never used
            catch (Exception ex)
#pragma warning restore CS0168 // Variable is declared but never used
            {
                GeneralMethods.GeneralMethods.ShowGeneralErrorMessage();
            }
            finally
            {
                Monitor.Exit(lockingobject);
            }
        }