Beispiel #1
0
        public IHttpActionResult AddTransactionsForDifferentBank(TransactionsDto transactionsDto)
        {
            transaction addTransaction       = new transaction();
            string      currentSenderBalance = "";

            try
            {
                var checkSenderTransactions = entity.users.Where(x => x.accountnumber == transactionsDto.senderaccountnumber).OrderByDescending(x => x.id).First();
                currentSenderBalance = checkSenderTransactions.accountbalance;
            }
            catch (Exception ex)
            {
                currentSenderBalance = "0";
            }
            finally
            {
                addTransaction.name                  = transactionsDto.name;
                addTransaction.nickname              = transactionsDto.nickName;
                addTransaction.senderaccountnumber   = transactionsDto.senderaccountnumber;
                addTransaction.receiveraccountnumber = transactionsDto.receiveraccountnumber;
                addTransaction.ifsccode              = transactionsDto.ifscCode;
                addTransaction.transactiondate       = DateTime.Now;
                addTransaction.creditamount          = transactionsDto.creditamount;
                addTransaction.debitamount           = transactionsDto.debitamount;
                addTransaction.senderbalanceamount   = ((Convert.ToDouble(currentSenderBalance) + Convert.ToDouble(transactionsDto.creditamount)) - Convert.ToDouble(transactionsDto.debitamount)).ToString();
                entity.transactions.Add(addTransaction);
                entity.SaveChanges();

                var userAccount = entity.users.First(x => x.accountnumber == transactionsDto.senderaccountnumber);
                userAccount.accountbalance = addTransaction.senderbalanceamount;
                entity.SaveChanges();
            }
            return(Ok(addTransaction));
        }
        public async Task <IActionResult> Create(TransactionActionViewModel model)
        {
            if (ModelState.IsValid)
            {
                var username = User.Identity.Name;
                var user     = await _userManager.FindByNameAsync(username);

                var profile = await _profileService.GetProfileByUserId(user.Id);

                var transactionDto = new TransactionsDto
                {
                    Description = model.Description,
                    Comment     = model.Comment,
                    Amount      = model.Amount,
                    //Currency
                    CurrencyType = 933,
                    CreationTime = DateTime.Now,
                    ProfileId    = profile.Id,
                    GroupId      = model.GroupId,
                };

                await _transactionsService.AddAsync(transactionDto);

                return(RedirectToAction("Detail", "Group", new { id = model.GroupId }));
            }

            return(View(model));
        }
        public async Task DeleteTransactionAsync(TransactionsDto transactionDto)
        {
            var transactionsProfile = await _repositoryTransactionProfiles
                                      .GetAll()
                                      .AsNoTracking()
                                      .Where(transaction => transaction.TransactionId == transactionDto.Id)
                                      .ToListAsync();

            if (transactionsProfile.Any())
            {
                foreach (var transactionProfile in transactionsProfile)
                {
                    _repositoryTransactionProfiles.Delete(transactionProfile);
                    await _repositoryTransactionProfiles.SaveChangesAsync();
                }
            }

            var transactionModel = await _repository.GetEntityAsync(transactionModel => transactionModel.Id == transactionDto.Id);

            if (transactionModel is null)
            {
                return;
            }

            _repository.Delete(transactionModel);
            await _repositoryTransactionProfiles.SaveChangesAsync();
        }
Beispiel #4
0
        public IHttpActionResult AddFirstTransactions(TransactionsDto transactionsDto)
        {
            transaction addTransaction = new transaction();

            try
            {
                addTransaction.name                  = transactionsDto.name;
                addTransaction.nickname              = transactionsDto.nickName;
                addTransaction.senderaccountnumber   = transactionsDto.senderaccountnumber;
                addTransaction.receiveraccountnumber = transactionsDto.receiveraccountnumber;
                addTransaction.ifsccode              = transactionsDto.ifscCode;
                addTransaction.transactiondate       = DateTime.Now;
                addTransaction.creditamount          = transactionsDto.creditamount;
                addTransaction.debitamount           = transactionsDto.debitamount;
                addTransaction.senderbalanceamount   = transactionsDto.creditamount;
                addTransaction.receiverbalanceamount = "0";
                entity.transactions.Add(addTransaction);
                entity.SaveChanges();
                return(Ok(addTransaction));
            }
            catch (Exception ex)
            {
                return(Ok("Error"));
            }
        }
        public async Task AddAsync(TransactionsDto transaction)
        {
            if (transaction is null)
            {
                throw new ArgumentNullException(nameof(transaction));
            }

            var transactionGuid = Guid.NewGuid();

            var transactionModel = new Transactions
            {
                Description  = transaction.Description,
                Comment      = transaction.Comment,
                Amount       = transaction.Amount,
                CurrencyType = Convert.ToInt32(transaction.CurrencyType),
                CreationTime = transaction.CreationTime,
                ProfileId    = transaction.ProfileId,
                GroupId      = transaction.GroupId,
                Guid         = transactionGuid
            };

            await _repository.AddAsync(transactionModel);

            await _repository.SaveChangesAsync();
        }
 public TransactionsItemViewModel(TransactionsDto transactionsDto, bool isSectionVisible)
 {
     ExpenseDescription = transactionsDto.Description;
     DateDay            = transactionsDto.Date.Day;
     DateMonth          = transactionsDto.Date.ToString("MMM", CultureInfo.InvariantCulture);
     ExpenseAmount      = transactionsDto.ExpenseAmount + " $";
     SectionName        = transactionsDto.Date.Year.ToString();
     IsFirstInSection   = isSectionVisible;
     PartyName          = transactionsDto.PartyName;
     PartyAccount       = transactionsDto.PartyAccount;
 }
Beispiel #7
0
        internal static void MapToTransactions(TransactionsDto dto, Transactions domain = null)
        {
            if (domain == null)
            {
                domain = new Transactions();
            }

            domain.Sku      = dto.Sku;
            domain.Amount   = dto.Amount;
            domain.Currency = dto.Currency;
        }
        /// <summary>
        /// Delete transaction
        /// </summary>
        /// <param name="id"></param>
        /// <returns>result delete transaction</returns>
        public async Task <IActionResult> Delete(int transactionId)
        {
            var transactionsDto = new TransactionsDto
            {
                Id = transactionId,
            };

            var transaction = await _transactionsService.GetTransactionAsync(transactionId);

            await _transactionsService.DeleteTransactionAsync(transactionsDto);

            return(RedirectToAction("Detail", "Group", new { id = transaction.GroupId }));
        }
Beispiel #9
0
        public async Task <ActionResult <AppTransactions> > Transaction(TransactionsDto transactionsDto)
        {
            var transactions = new AppTransactions {
                CardId      = transactionsDto.Id,
                StationFrom = transactionsDto.StationFrom,
                Date_In     = transactionsDto.Date_In
            };

            _context.Transactions.Add(transactions);
            await _context.SaveChangesAsync();

            return(transactions);
        }
        public async Task EditAsync(TransactionsDto transaction)
        {
            var transactionModel = await _repository.GetEntityAsync(transactionModel => transactionModel.Id == transaction.Id);

            if (transaction is null)
            {
                return;
            }
            transactionModel.Description = transaction.Description;
            transactionModel.Comment     = transaction.Comment;
            transactionModel.Amount      = transaction.Amount;
            _repository.Update(transactionModel);
            await _repositoryTransactionProfiles.SaveChangesAsync();
        }
Beispiel #11
0
        internal static TransactionsDto MapToTransactionsDto(Transactions domain)
        {
            var dto = new TransactionsDto();

            if (domain != null)
            {
                dto = new TransactionsDto()
                {
                    Sku      = domain.Sku,
                    Amount   = domain.Amount,
                    Currency = domain.Currency
                }
            }
            ;
            return(dto);
        }
Beispiel #12
0
        public async Task <ActionResult <AppTransactions> > UpdateTrasaction(TransactionsDto transactionsDto)
        {
            var no_transactions = await _context.Transactions.FirstOrDefaultAsync(nt => nt.CardId == transactionsDto.CardId && nt.Date_In == transactionsDto.Date_In);

            var transactions = new AppTransactions {
                Id        = transactionsDto.Id,
                CardId    = transactionsDto.CardId,
                StationTo = transactionsDto.StationTo,
                Date_Out  = transactionsDto.Date_Out
            };


            _context.Transactions.Update(transactions);
            await _context.SaveChangesAsync();

            return(transactions);
        }
        public async Task <IActionResult> Edit(TransactionActionViewModel model)
        {
            if (ModelState.IsValid)
            {
                var transactionDto = new TransactionsDto
                {
                    Id          = model.Id,
                    Description = model.Description,
                    Comment     = model.Comment,
                    Amount      = model.Amount
                };

                await _transactionsService.EditAsync(transactionDto);

                return(RedirectToAction("Index", "Transaction", new { id = transactionDto.Id }));
            }
            return(View(model));
        }
        public async Task <TransactionsDto> GetTransactionAsync(int id)
        {
            var transactionModel = await _repository.GetEntityAsync(transactionModel => transactionModel.Id == id);

            if (transactionModel is null)
            {
                return(new TransactionsDto());
            }

            var transactionDto = new TransactionsDto
            {
                Id           = transactionModel.Id,
                Description  = transactionModel.Description,
                Comment      = transactionModel.Comment,
                Amount       = transactionModel.Amount,
                CurrencyType = transactionModel.CurrencyType,
                CreationTime = transactionModel.CreationTime,
                ProfileId    = transactionModel.ProfileId,
                GroupId      = transactionModel.GroupId,
                Guid         = transactionModel.Guid
            };

            return(transactionDto);
        }