示例#1
0
 // Default
 public Transaction()
 {
     _TypeOfTransaction = 0;
     _MoneyAmount       = 0;
     _DateOfTransaction = new DateTime(0000, 00, 00);
     _Location          = "UNKNOWN";
 }
示例#2
0
 // Regular
 public Transaction(TypeOfTransaction aTypeOfTransaction, decimal aAmountOfTransaction)
 {
     _TypeOfTransaction = aTypeOfTransaction;
     _MoneyAmount       = aAmountOfTransaction;
     _DateOfTransaction = DateTime.Now;
     _Location          = "EARTH";
 }
示例#3
0
 // Copy
 public Transaction(Transaction copyTransaction)
 {
     _TypeOfTransaction = copyTransaction._TypeOfTransaction;
     _MoneyAmount       = copyTransaction._MoneyAmount;
     _DateOfTransaction = copyTransaction._DateOfTransaction;
     _Location          = copyTransaction._Location;
 }
 public Transaction CreateTransaction(
     TypeOfTransaction typeOfTransaction,
     Guid idAccountFrom,
     Guid idAccountTo,
     string description,
     decimal amount)
 {
     return(new Transaction(
                typeOfTransaction,
                idAccountFrom,
                idAccountTo,
                description,
                amount));
 }
示例#5
0
 public Transaction(
     TypeOfTransaction typeOfTransaction,
     Guid idAccountFrom,
     Guid idAccountTo,
     string _description,
     decimal _amount)
 {
     this.Type                   = typeOfTransaction;
     this.FromAccountId          = idAccountFrom;
     this.ToAccountId            = idAccountTo;
     this.Amount                 = _amount;
     this.Timestamp              = DateTime.UtcNow.ConvertToUnixTimestamp();
     this.TransactionDescription = _description;
     this.TransactionId          = new Guid();
 }
示例#6
0
        private static void createTransaction(decimal amount,
                                              int accountNumber,
                                              TypeOfTransaction transactionType, string description = "")
        {
            var transaction = new Transaction
            {
                TransactionDate = DateTime.UtcNow,
                Description     = description,
                Amount          = amount,
                AccountNumber   = accountNumber,
                TransactionType = transactionType
            };

            db.Transactions.Add(transaction);
            db.SaveChanges();
        }
示例#7
0
        // Do wczytywania z pliku
        public Transaction(string aTypeOfTransaction, decimal aAmountOfTransaction, DateTime aDateOfTransactioin, string aLocation)
        {
            _MoneyAmount       = aAmountOfTransaction;
            _DateOfTransaction = aDateOfTransactioin;
            _Location          = aLocation;

            switch (aTypeOfTransaction)
            {
            case "Deposit":
                _TypeOfTransaction = TypeOfTransaction.DEPOSIT;
                break;

            case "Withdraw":
                _TypeOfTransaction = TypeOfTransaction.WITHDRAW;
                break;
            }
        }
        public async Task <TransactionViewModel> CreateTransactionAsync(TypeOfTransaction type, string description, decimal amount, string userId)
        {
            var balance = await balanceRepo.All()
                          .Include(b => b.User)
                          .Include(b => b.Type)
                          .Where(b => b.UserId == userId && b.Type.Name == BalanceTypes.Base.ToString())
                          .FirstOrDefaultAsync();

            if (balance is null)
            {
                throw new ArgumentNullException("Balance can`t be null");
            }

            var transactionType = await transactionTypeRepo.All()
                                  .Where(t => t.Name.ToLower() == type.ToString().ToLower())
                                  .FirstOrDefaultAsync();

            if (transactionType is null)
            {
                throw new ArgumentNullException("Transaction type can`t be null");
            }

            var transaction = new Transaction
            {
                Type           = transactionType,
                Balance        = balance,
                Date           = DateTime.Now,
                Description    = description,
                Amount         = amount,
                OpeningBalance = balance.Money - amount
            };

            transactionRepo.Add(transaction);
            await transactionRepo.SaveAsync();

            var model = mappingProvider.MapTo <TransactionViewModel>(transaction);

            return(model);
        }
        public OperationForm(int selectedTabControl, TypeOfTransaction typeOfTransaction, object classObject = null)
        {
            InitializeComponent();

            _typeOfTransaction = typeOfTransaction;
            Text = typeOfTransaction + (selectedTabControl == 0 ? " записи учета" : " услуги");

            switch (selectedTabControl)
            {
            case 0:
                groupBoxAccounting.Visible = true;
                if (_typeOfTransaction == TypeOfTransaction.едактирование)
                {
                    groupBoxAttacments.Enabled = true;
                }
                LoadFieldsAccounting(classObject);
                break;

            case 1:
                groupBoxService.Visible = true;
                LoadFieldsService(classObject);
                break;
            }
        }