示例#1
0
        public async Task <IActionResult> OnGetAsync(string accountCode, string cashCode)
        {
            try
            {
                if (accountCode == null || cashCode == null)
                {
                    return(NotFound());
                }

                Entry = await NodeContext.Invoice_Entries.FirstOrDefaultAsync(m => m.AccountCode == accountCode && m.CashCode == cashCode);

                if (Entry == null)
                {
                    return(NotFound());
                }
                else
                {
                    var isAuthorized = User.IsInRole(Constants.ManagersRole) || User.IsInRole(Constants.AdministratorsRole);

                    if (!isAuthorized)
                    {
                        var profile = new Profile(NodeContext);
                        var user    = await UserManager.GetUserAsync(User);

                        string userId = await profile.UserId(user.Id);

                        if (userId != Entry.UserId)
                        {
                            return(Forbid());
                        }
                    }

                    await SetViewData();

                    return(Page());
                }
            }
            catch (Exception e)
            {
                NodeContext.ErrorLog(e);
                throw;
            }
        }
示例#2
0
        public async Task <IActionResult> OnGetAsync(string accountCode, string cashCode)
        {
            if (accountCode == null || cashCode == null)
            {
                return(NotFound());
            }

            Entry = await NodeContext.Invoice_Entries.FirstOrDefaultAsync(m => m.AccountCode == accountCode && m.CashCode == cashCode);

            if (Entry == null)
            {
                return(NotFound());
            }
            else
            {
                await SetViewData();

                return(Page());
            }
        }