Example #1
0
        public async Task <IActionResult> OnPostAsync(string paymentCode)
        {
            try
            {
                if (paymentCode == null)
                {
                    return(NotFound());
                }

                Cash_TransfersUnposted = await NodeContext.Cash_TransfersUnposted.FindAsync(paymentCode);

                if (Cash_TransfersUnposted != null)
                {
                    NodeContext.Cash_TransfersUnposted.Remove(Cash_TransfersUnposted);
                    await NodeContext.SaveChangesAsync();
                }

                return(RedirectToPage("./Index"));
            }
            catch (Exception e)
            {
                NodeContext.ErrorLog(e);
                throw;
            }
        }
        public async Task <IActionResult> OnGetAsync()
        {
            try
            {
                var cashAccountList = from tb in NodeContext.Org_tbAccounts
                                      where !tb.AccountClosed && tb.AccountTypeCode == (short)NodeEnum.CashAccountType.Cash && tb.CoinTypeCode == (short)NodeEnum.CoinType.Fiat
                                      select tb.CashAccountName;

                CashAccounts = new SelectList(await cashAccountList.ToListAsync());

                CashAccounts cashAccounts    = new(NodeContext);
                string       cashAccountCode = await cashAccounts.CurrentAccount();

                CashAccountName = await NodeContext.Org_tbAccounts.Where(t => t.CashAccountCode == cashAccountCode).Select(t => t.CashAccountName).FirstOrDefaultAsync();

                var cashCodeList = from tb in NodeContext.Cash_TransferCodeLookup
                                   orderby tb.CashCode
                                   select tb.CashDescription;

                CashCodes       = new SelectList(await cashCodeList.ToListAsync());
                CashDescription = await cashCodeList.FirstOrDefaultAsync();

                Profile profile  = new(NodeContext);
                string  cashCode = await NodeContext.Cash_tbCodes.Where(t => t.CashDescription == CashDescription).Select(t => t.CashCode).FirstOrDefaultAsync();

                CashCodes cashCodes = new(NodeContext, cashCode);

                Cash_TransfersUnposted = new Cash_vwTransfersUnposted
                {
                    CashAccountCode = cashAccountCode,
                    CashCode        = cashCodes.CashCode,
                    TaxCode         = cashCodes.TaxCode,
                    PaymentCode     = await cashAccounts.NextPaymentCode(),
                    AccountCode     = await profile.CompanyAccountCode,
                    PaidOn          = DateTime.Today,
                    UserId          = await profile.UserId(UserManager.GetUserId(User)),
                    InsertedBy      = await profile.UserName(UserManager.GetUserId(User))
                };

                Cash_TransfersUnposted.UpdatedBy = Cash_TransfersUnposted.InsertedBy;

                await SetViewData();

                return(Page());
            }
            catch (Exception e)
            {
                NodeContext.ErrorLog(e);
                throw;
            }
        }
Example #3
0
        public async Task <IActionResult> OnGetAsync(string paymentCode)
        {
            try
            {
                if (paymentCode == null)
                {
                    return(NotFound());
                }

                Cash_TransfersUnposted = await NodeContext.Cash_TransfersUnposted.FirstOrDefaultAsync(m => m.PaymentCode == paymentCode);

                if (Cash_TransfersUnposted == null)
                {
                    return(NotFound());
                }
                else
                {
                    if ((User.IsInRole(Constants.ManagersRole) || User.IsInRole(Constants.AdministratorsRole)) == false)
                    {
                        var profile = new Profile(NodeContext);
                        var user    = await UserManager.GetUserAsync(User);

                        if (Cash_TransfersUnposted.UserId != await profile.UserId(user.Id))
                        {
                            return(Forbid());
                        }
                    }

                    await SetViewData();

                    return(Page());
                }
            }
            catch (Exception e)
            {
                NodeContext.ErrorLog(e);
                throw;
            }
        }