예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("id,ReferenceNo,AccountBankAccountID,Amount,ActualDate,Reference,DateTimeModified,DateTimeAdded")] AccountAdjust accountAdjust)
        {
            if (id != accountAdjust.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    accountAdjust.DateTimeModified = Utility.GetLocalDateTime();
                    _context.Update(accountAdjust);

                    /////////////////////////////////////////////////////////////////////////////
                    //update AccountTxn
                    var accountTxn = await _context.AccountTxn.AsNoTracking().SingleOrDefaultAsync(m => m.Type == "A" && m.ReferenceID == id);

                    if (accountTxn != null)
                    {
                        accountTxn.AccountBankAccountID = accountAdjust.AccountBankAccountID;
                        if (accountAdjust.Amount >= 0)
                        {
                            accountTxn.AmountCredit = accountAdjust.Amount;
                            accountTxn.AmountDebit  = null;
                        }
                        else
                        {
                            accountTxn.AmountCredit = null;
                            accountTxn.AmountDebit  = Math.Abs(accountAdjust.Amount);
                        }
                        accountTxn.DateTimeModified = Utility.GetLocalDateTime();
                        _context.Update(accountTxn);
                    }
                    /////////////////////////////////////////////////////////////////////////////
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccountAdjustExists(accountAdjust.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            ViewBag.AccountBankAccount = new SelectList(_context.AccountBankAccount.OrderBy(m => m.AccountName).ToList(), "id", "AccountName");

            return(View(accountAdjust));
        }
예제 #2
0
        public async Task<IActionResult> Edit(int id, [Bind("id,ClientName,ClientLegalName,ClientTypeID,DateTimeModified,DateTimeAdded")] Client client)
        {
            if (id != client.id)
            {
                return NotFound();
            }

            if (ModelState.IsValid)
            {
                try
                {
                    client.DateTimeModified = Utility.GetLocalDateTime();
                    _context.Update(client);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClientExists(client.id))
                    {
                        return NotFound();
                    }
                    else
                    {
                        throw;
                    }
                }
                return RedirectToAction(nameof(Index));
            }
            ViewBag.ClientType = new SelectList(_context.ClientType.ToList(), "id", "ClientTypeName");
            return View(client);
        }
예제 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("id,TradeDate,CurrencyPairID,Rate,DateTimeModified,DateTimeAdded")] Dfr dfr)
        {
            if (id != dfr.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    dfr.DateTimeModified = Utility.GetLocalDateTime();
                    _context.Update(dfr);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DfrExists(dfr.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewBag.CurrencyPair = new SelectList(_context.CurrencyPair.OrderBy(x => x.CurrencyPairName).ToList(), "id", "CurrencyPairName");
            return(View(dfr));
        }
예제 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("id,TradeDate,ProviderTradingProfileID,Rate,DateTimeModified,DateTimeAdded")] CostRate costRate)
        {
            if (id != costRate.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    costRate.DateTimeModified = Utility.GetLocalDateTime();
                    _context.Update(costRate);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CostRateExists(costRate.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewBag.ProviderTradingProfile = new SelectList(_context.ProviderTradingProfile.OrderBy(x => x.ProviderTradingProfileName).ToList(), "id", "ProviderTradingProfileName");

            return(View(costRate));
        }
예제 #5
0
        public async Task <IActionResult> Edit(int id, [Bind("TxnID,ProviderPayinUSD,ClientPayoutUSD,IntroducerCommissionUSD,ReferenceNo,TradeDate,ClientTradingProfileName,ClientCurrencyNameOut,ClientAmountOut,GrossProfitUSD,GrossProfitUSDPct")] ReportTxn reportTxn)
        {
            if (id != reportTxn.TxnID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(reportTxn);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReportTxnExists(reportTxn.TxnID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(reportTxn));
        }
예제 #6
0
        public async Task <IActionResult> Edit(int id, [Bind("id,UserName,Password,Role,DateTimeModified,DateTimeAdded")] User user)
        {
            if (id != user.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    user.DateTimeModified = Utility.GetLocalDateTime();
                    _context.Update(user);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewBag.Role = new SelectList(Role, "Value", "Text", user.Role);
            return(View(user));
        }
예제 #7
0
        public async Task <IActionResult> Edit(int id, [Bind("id,ProviderID,ProviderTradingProfileName,CurrencyPairID,DateTimeModified,DateTimeAdded")] ProviderTradingProfile providerTradingProfile)
        {
            if (id != providerTradingProfile.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    providerTradingProfile.DateTimeModified = Utility.GetLocalDateTime();
                    _context.Update(providerTradingProfile);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProviderTradingProfileExists(providerTradingProfile.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewBag.Provider     = new SelectList(_context.Provider.OrderBy(m => m.ProviderName).ToList(), "id", "ProviderName");
            ViewBag.CurrencyPair = new SelectList(_context.CurrencyPair.OrderBy(m => m.CurrencyPairName).ToList(), "id", "CurrencyPairName");

            return(View(providerTradingProfile));
        }
예제 #8
0
        public async Task <IActionResult> Edit(int id, [Bind("ClientTradingProfileID,ClientTradingProfileName,ClientCurrencyNameOut,TradeDate,ClientAmountUncompleted,ClientAmountUncompletedUSD,Rate")] ReportAccountPayable reportAccountPayable)
        {
            if (id != reportAccountPayable.ClientTradingProfileID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(reportAccountPayable);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReportAccountPayableExists(reportAccountPayable.ClientTradingProfileID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(reportAccountPayable));
        }
예제 #9
0
        public async Task <IActionResult> Edit(int id, [Bind("id,AccountName,DateTimeModified,DateTimeAdded")] Account account)
        {
            if (id != account.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    account.DateTimeModified = Utility.GetLocalDateTime();
                    _context.Update(account);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccountExists(account.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(account));
        }
예제 #10
0
        public async Task <IActionResult> Edit(int id, [Bind("id,IntroducerName,IntroducerLegalName,DateTimeModified,DateTimeAdded")] Introducer introducer)
        {
            if (id != introducer.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    introducer.DateTimeModified = Utility.GetLocalDateTime();
                    _context.Update(introducer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!IntroducerExists(introducer.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(introducer));
        }
예제 #11
0
        public async Task <IActionResult> Edit(byte id, [Bind("id,CurrencyName,DateTimeModified,DateTimeAdded")] Currency currency)
        {
            if (id != currency.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    currency.DateTimeModified = Utility.GetLocalDateTime();
                    _context.Update(currency);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CurrencyExists(currency.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(currency));
        }
예제 #12
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ProviderName,TotalProviderExpectedPayInAmount,TotalSlipAmount,MissingSlipAmount")] ReportProvider reportProvider)
        {
            if (id != reportProvider.ProviderTradingProfileID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(reportProvider);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReportProviderExists(reportProvider.ProviderTradingProfileID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(reportProvider));
        }
예제 #13
0
        public async Task <IActionResult> Edit(int id, [Bind("id,IntroducerID,AccountName,CurrencyID,AccountTypeID,AccountHolderName,AccountHolderAddress,AccountNo,IBAN,BSB,BankCode,BankName,SWIFT,CountryID,BranchAddress,Reference,DateTimeModified,DateTimeAdded")] IntroducerBankAccount introducerBankAccount)
        {
            if (id != introducerBankAccount.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    introducerBankAccount.DateTimeModified = Utility.GetLocalDateTime();
                    _context.Update(introducerBankAccount);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!IntroducerBankAccountExists(introducerBankAccount.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewBag.Introducer  = new SelectList(_context.Introducer.OrderBy(m => m.IntroducerName).ToList(), "id", "IntroducerName");
            ViewBag.Currency    = new SelectList(_context.Currency.OrderBy(m => m.CurrencyName).ToList(), "id", "CurrencyName");
            ViewBag.AccountType = new SelectList(_context.AccountType.ToList(), "id", "AccountTypeName");
            ViewBag.Country     = new SelectList(_context.Country.OrderBy(m => m.CountryName).ToList(), "id", "CountryName");

            return(View(introducerBankAccount));
        }
예제 #14
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,AccountName,TotalClientAmountOut")] ReportAccount reportAccount)
        {
            if (id != reportAccount.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(reportAccount);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReportAccountExists(reportAccount.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(reportAccount));
        }
예제 #15
0
        public async Task <IActionResult> Edit(int id, [Bind("ProviderTradingProfileID,ProviderTradingProfileName,AmountReceivable,CurrencyName2,AmountReceivableUSD,Rate")] ReportAccountReceivable reportAccountReceivable)
        {
            if (id != reportAccountReceivable.ProviderTradingProfileID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(reportAccountReceivable);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReportAccountReceivableExists(reportAccountReceivable.ProviderTradingProfileID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(reportAccountReceivable));
        }
예제 #16
0
        public async Task <IActionResult> Edit(int id, [Bind("id,Type,ReferenceID,AccountBankAccountID,AmountCredit,AmountDebit,DateTimeModified,DateTimeAdded")] AccountTxn accountTxn)
        {
            if (id != accountTxn.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(accountTxn);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccountTxnExists(accountTxn.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(accountTxn));
        }
예제 #17
0
        public async Task <IActionResult> Edit(int id, [Bind("id,AccountName,CurrencyName,Balance,BalanceUSD,Rate")] ReportAccountBalance reportAccountBalance)
        {
            if (id != reportAccountBalance.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(reportAccountBalance);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReportAccountBalanceExists(reportAccountBalance.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(reportAccountBalance));
        }
예제 #18
0
        public async Task <IActionResult> Edit(int id, [Bind("id,ClientTradingProfileID,IntroducerID,IntroducerCommissionTypeID,IntroducerCommissionRate,DateTimeModified,DateTimeAdded")] ClientTradingProfileIntroducerMap clientTradingProfileIntroducerMap)
        {
            if (id != clientTradingProfileIntroducerMap.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    clientTradingProfileIntroducerMap.DateTimeModified = Utility.GetLocalDateTime();
                    _context.Update(clientTradingProfileIntroducerMap);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClientTradingProfileIntroducerMapExists(clientTradingProfileIntroducerMap.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewBag.ClientTradingProfile     = new SelectList(_context.ClientTradingProfile.OrderBy(m => m.ClientTradingProfileName).ToList(), "id", "ClientTradingProfileName");
            ViewBag.Introducer               = new SelectList(_context.Introducer.OrderBy(m => m.IntroducerName).ToList(), "id", "IntroducerName");
            ViewBag.IntroducerCommissionType = new SelectList(_context.IntroducerCommissionType.ToList(), "id", "IntroducerCommissionTypeName");

            return(View(clientTradingProfileIntroducerMap));
        }
예제 #19
0
        public async Task <IActionResult> Edit(int id, [Bind("id,SenderName,ProviderID,Unit,AddressLine1,AddressLine2,City,Country,PostalCode,DirectorFirstName,DirectorLastName,DateTimeModified,DateTimeAdded")] Sender sender)
        {
            if (id != sender.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    sender.DateTimeModified = Utility.GetLocalDateTime();
                    _context.Update(sender);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SenderExists(sender.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewBag.Provider = new SelectList(_context.Provider.OrderBy(m => m.ProviderName).ToList(), "id", "ProviderName");
            return(View(sender));
        }
예제 #20
0
        public ActionResult UpdatePayoutDone(int id, bool isPayoutDone)
        {
            var payoutDoneByID   = HttpContext.Session.GetInt32("UserID");
            var payoutDoneByName = isPayoutDone ? HttpContext.Session.GetString("UserName"):"";

            var txn = _context.Txn.Where(m => m.id == id).FirstOrDefault();

            txn.PayoutDone = isPayoutDone;

            if (isPayoutDone)
            {
                txn.PayoutDoneByID = payoutDoneByID;
            }
            else
            {
                txn.PayoutDoneByID = null;
            }

            _context.Update(txn);
            _context.SaveChanges();

            //return Json(JsonConvert.SerializeObject(payoutDoneByID));
            return(Content(payoutDoneByName));
        }
예제 #21
0
        public async Task <IActionResult> Edit(int id, [Bind("id,ReferenceNo,AccountBankAccountIDFrom,AccountBankAccountIDTo,Amount,Rate,ActualDate,Reference,DateTimeModified,DateTimeAdded")] AccountTransfer accountTransfer)
        {
            if (id != accountTransfer.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    accountTransfer.DateTimeModified = Utility.GetLocalDateTime();
                    _context.Update(accountTransfer);

                    /////////////////////////////////////////////////////////////////////////////
                    //update AccountTxn
                    var accountTxn = await _context.AccountTxn.Where(m => m.Type == "T" && m.ReferenceID == id).ToListAsync();

                    if (accountTxn != null)
                    {
                        _context.AccountTxn.RemoveRange(accountTxn);
                    }

                    AccountTxn accountTxnFrom = new AccountTxn();
                    accountTxnFrom.Type                 = "T";
                    accountTxnFrom.ReferenceID          = id;
                    accountTxnFrom.AccountBankAccountID = accountTransfer.AccountBankAccountIDFrom;
                    accountTxnFrom.AmountDebit          = accountTransfer.Amount;
                    accountTxnFrom.DateTimeModified     = Utility.GetLocalDateTime();
                    accountTxnFrom.DateTimeAdded        = Utility.GetLocalDateTime();
                    _context.Add(accountTxnFrom);

                    AccountTxn accountTxnTo = new AccountTxn();
                    accountTxnTo.Type                 = "T";
                    accountTxnTo.ReferenceID          = id;
                    accountTxnTo.AccountBankAccountID = accountTransfer.AccountBankAccountIDTo;
                    accountTxnTo.AmountCredit         = accountTransfer.Amount * accountTransfer.Rate;
                    accountTxnTo.DateTimeModified     = Utility.GetLocalDateTime();
                    accountTxnTo.DateTimeAdded        = Utility.GetLocalDateTime();
                    _context.Add(accountTxnTo);
                    /////////////////////////////////////////////////////////////////////////////

                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccountTransferExists(accountTransfer.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            ViewBag.AccountBankAccount = new SelectList(_context.AccountBankAccount.OrderBy(m => m.AccountName).ToList(), "id", "AccountName");

            return(View(accountTransfer));
        }
예제 #22
0
        public async Task <IActionResult> Create([Bind("id,ReferenceNo,TxnID,ClientPayoutAmount,ClientPayoutUSDRate,ProviderPayinUSDRate,UsedCurrencyID,UsedAmount,UsedClientPayoutFXRate,UsedUSDRate,AccountBankAccountID,DateTimeModified,DateTimeAdded")] Payout payout)
        {
            if (ModelState.IsValid)
            {
                payout.DateTimeModified = Utility.GetLocalDateTime();
                payout.DateTimeAdded    = Utility.GetLocalDateTime();

                _context.Add(payout);
                await _context.SaveChangesAsync();

                ///////////////////////////////////////////////////////////////////////////////////////////////////////////
                //check ClientPayoutMissing, update Status
                var reportTxn = await _context.ReportTxnOriginal.AsNoTracking().SingleOrDefaultAsync(m => m.TxnID == payout.TxnID);

                if (reportTxn != null)
                {
                    var txn = await _context.Txn.AsNoTracking().SingleOrDefaultAsync(m => m.id == payout.TxnID);

                    if (txn != null)
                    {
                        if (reportTxn.ClientPayoutMissing < reportTxn.ClientAmountOut && reportTxn.ClientPayoutMissing > 0)
                        {
                            txn.Status = "P";
                        }
                        else if (reportTxn.ClientPayoutMissing <= 0)
                        {
                            txn.Status = "C";
                        }
                        else
                        {
                            txn.Status = "";
                        }

                        _context.Update(txn);
                        await _context.SaveChangesAsync();
                    }
                }
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////
                //update AccountTxn
                AccountTxn accountTxn = new AccountTxn();
                accountTxn.Type                 = "P";
                accountTxn.ReferenceID          = payout.id;
                accountTxn.AccountBankAccountID = payout.AccountBankAccountID;
                accountTxn.AmountDebit          = payout.ClientPayoutAmount;
                accountTxn.DateTimeModified     = Utility.GetLocalDateTime();
                accountTxn.DateTimeAdded        = Utility.GetLocalDateTime();
                _context.Add(accountTxn);
                await _context.SaveChangesAsync();

                /////////////////////////////////////////////////////////////////////////////
                return(RedirectToAction(nameof(Index)));
            }

            ViewBag.ClientTradingProfile = new SelectList(_context.TxnView.Where(t => t.Type != "D" && t.Status != "C" && t.PayoutDone)
                                                          .Select(t => new
            {
                id   = t.ClientTradingProfileID,
                text = t.ClientTradingProfileName
            }).Distinct().OrderBy(t => t.text).ToList(), "id", "text");

            ViewBag.Txn = new SelectList(_context.TxnView.Where(t => t.Type != "D" && t.Status != "C" && t.PayoutDone).OrderBy(m => m.ReferenceNo)
                                         .Select(t => new
            {
                id   = t.id,
                text = t.ClientTradingProfileName + ", " + t.TradeDate.ToString() + ", " + (t.ClientAmountOut.ToString() ?? "") + ", " + (t.ClientCurrencyNameOut ?? "") + ", " + t.ReferenceNo
            }).ToList(), "id", "text");
            ViewBag.Currency           = new SelectList(_context.Currency.OrderBy(m => m.CurrencyName).ToList(), "id", "CurrencyName");
            ViewBag.AccountBankAccount = new SelectList(_context.AccountBankAccount.OrderBy(x => x.AccountName).ToList(), "id", "AccountName");

            return(View(payout));
        }
예제 #23
0
        public async Task <IActionResult> Edit(int id, [Bind("id,ReferenceNo,SlipDate,ProviderTradingProfileID,TxnID,AccountBankAccountID,SenderID,SlipAmount,ActualAmount,DateTimeModified,DateTimeAdded")] Slip slip)
        {
            if (id != slip.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    slip.DateTimeModified = Utility.GetLocalDateTime();
                    _context.Update(slip);

                    ///////////////////////////////////////////////////////////////////////////////////////////////////////////
                    //update AccountTxn
                    var accountTxn = await _context.AccountTxn.AsNoTracking().SingleOrDefaultAsync(m => m.Type == "S" && m.ReferenceID == id);

                    if (accountTxn != null)
                    {
                        _context.AccountTxn.Remove(accountTxn);
                    }

                    if (slip.ActualAmount != null && slip.ActualAmount > 0)
                    {
                        accountTxn                      = new AccountTxn();
                        accountTxn.Type                 = "S";
                        accountTxn.ReferenceID          = id;
                        accountTxn.AccountBankAccountID = slip.AccountBankAccountID;
                        accountTxn.AmountCredit         = slip.ActualAmount;
                        accountTxn.DateTimeModified     = Utility.GetLocalDateTime();
                        accountTxn.DateTimeAdded        = Utility.GetLocalDateTime();
                        _context.Add(accountTxn);
                    }
                    ///////////////////////////////////////////////////////////////////////////////////////////////////////////

                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SlipExists(slip.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewBag.ProviderTradingProfile = new SelectList(_context.TxnView.ToList().Where(x => x.Type != "L").GroupBy(x => x.ProviderTradingProfileID).Select(x => x.First()).OrderBy(x => x.ProviderTradingProfileName), "ProviderTradingProfileID", "ProviderTradingProfileName");
            ViewBag.AccountBankAccount     = new SelectList(_context.AccountBankAccount.OrderBy(x => x.AccountName).ToList(), "id", "AccountName");

            var providerTradingProfile = _context.ProviderTradingProfile.FirstOrDefault(x => x.id == slip.ProviderTradingProfileID);

            ViewBag.Sender = new SelectList(_context.Sender.ToList().Where(x => x.ProviderID == providerTradingProfile.ProviderID).OrderBy(x => x.SenderName), "id", "SenderName");
            ViewBag.Txn    = new SelectList(_context.Txn.ToList().Where(x => x.ProviderTradingProfileID == slip.ProviderTradingProfileID).OrderBy(x => x.ReferenceNo), "id", "ReferenceNo");

            return(View(slip));
        }