Klavzule
This commit is contained in:
49
EveryThing/Pages/CodeTablePrePostText/Index.cshtml.cs
Normal file
49
EveryThing/Pages/CodeTablePrePostText/Index.cshtml.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using EveryThing.Models.Transport;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace EveryThing.Pages.CodeTablePrePostText
|
||||
{
|
||||
[Authorize(Roles = "Administrator,TransportThingUser,InvoicingUser")]
|
||||
public class IndexModel : PageModel
|
||||
{
|
||||
private readonly EveryThing.Data.ApplicationDbContext _context;
|
||||
private readonly UserManager<IdentityApplicationUser> _userManager;
|
||||
|
||||
public IndexModel(EveryThing.Data.ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager)
|
||||
{
|
||||
_context = context;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
public IList<Models.CodeTable.CodeTablePrePostText> PrePostTexts { get;set; }
|
||||
|
||||
public async Task OnGetAsync(string searchString)
|
||||
{
|
||||
ViewData["SearchString"] = searchString;
|
||||
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
PrePostTexts = await _context.CodeTablePrePostText
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk)
|
||||
.OrderByDescending(x => x.Content)
|
||||
.ToListAsync();
|
||||
|
||||
if (!string.IsNullOrEmpty(searchString))
|
||||
{
|
||||
PrePostTexts = PrePostTexts.Where(x => x.Content == searchString).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user