<form class="is-small select" id="FilterForm" method="post" asp-page-handler="FilterGenerated">
<select asp-for="SelectedOptions" asp-items="@Model.Options" onchange="this.form.submit()"></select>
</form>
<a asp-page="Edit" asp-route-id="@item.Id">Изменить</a>
a asp-page="Edit" asp-route-id="@item.Id">Изменить</a>
) значит a asp-page="Edit" asp-route-id="@item.Id">Изменить?(Я новичок в ASP.NET) a asp-page="Edit" asp-route-id="@item.Id">Изменить</a>
?@using Inst_Post_Searcher.Pages.Shared
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Inst-Post Searcher</title>
<style>
body {
background: -moz-linear-gradient(to bottom, #333 20%, #2a2929 90%, #808080);
background: -webkit-gradient(linear, 0 0, 0 100%, from(#333), to(#808080), color-stop(0.5, #2a2929));
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#333', endColorstr='#808080');
background-repeat: no-repeat;
height: 950px;
}
.new {
top: 830px;
font-size: 1.0vw;
color: darkorange;
background: none;
border: none;
}
</style>
</head>
<body>
<div align="center" style="position:relative;">
<h1 style="color: darkorange">Inst-Post Searcher</h1>
<hr width="1900" size="2" color="darkorange" />
</div>
@*<form method="post">
<div style="position: relative; top: 830px; font-size: 1.0vw; color: darkorange; background: none; border: none;">
<hr width="1900" size="5" color="#000000" style="top: 825px" />
<input class="new" align="left" style="left: 100px;" type="submit" asp-page-handler="DeveloperContacts" value="Контакты разработчика" />
<input class="new" align="centre" style="left: 570px;" type="submit" asp-page-handler="PrivacyPolicy" value="Политика конфиденциальности" />
<input class="new" align="right" style="right: 100px;" type="submit" asp-page-handler="TermsOfUse" value="Условия использования" />
</div>
</form>*@
<form class="is-small select" id="FilterForm" method="post" asp-page-handler="FilterGenerated">
<select asp-for="SelectedOptions" asp-items="@Model.Options" onchange="this.form.submit()"></select>
</form>
@RenderBody()
</body>
</html>
<a asp-page="Edit" asp-route-id="@item.Id">Изменить</a>
<a asp-page="Edit" asp-route-id="@Model.UrlString">Изменить</a>
public class _LayoutModel : PageModel
{
public void OnGet()
{
}
public void OnPostPrivacyPolicy()
{
}
public void OnPostTermsOfUse()
{
}
public void OnPostDeveloperContacts()
{
}
}
public class PolicyPrivacyModel : PageModel
{
public void OnGet()
{
}
}
<div class="navbar-start">
<a class="navbar-item" asp-area="" asp-page="/Index">
Главная
</a>
<a class="navbar-item" asp-area="" asp-page="/Privacy">
Политика конфиденциальности
</a>
</div>
<form class="is-small select" id="FilterForm" method="post" asp-page-handler="FilterGenerated">
<select asp-for="SelectedOptions" asp-items="@Model.Options" onchange="this.form.submit()"></select>
</form>
? #region License
// // Ðàçðàáîòàíî: Êîðîòåíêî Âëàäèìèðîì Íèêîëàåâè÷åì (Vladimir N. Korotenko)
// // email: koroten@ya.ru
// // skype:vladimir-korotenko
// // https://vkorotenko.ru
// // Ñîçäàíî: 09.08.2020 7:18
#endregion
using Kvn.ErrorReport.Data;
using Kvn.ErrorReport.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using Microsoft.Extensions.Options;
namespace Kvn.ErrorReport.Pages
{
/// <summary>
/// Ìîäåëü ïðîôèëÿ, ãîëîâíàÿ ìîäåëü äëÿ îòîáðàæåíèÿ àäìèíèñòðàòîðó ñèñòåìû
/// </summary>
[Authorize(Roles = "admin")]
public class ProfileModel : PageModel
{
private readonly ApplicationDbContext _ctx;
private readonly AppSettings _settings;
/// <summary>
/// Êîíñòðóêòîð ìîäåëè
/// </summary>
/// <param name="ctx"></param>
/// <param name="settings"></param>
public ProfileModel(ApplicationDbContext ctx, IOptions<AppSettings> settings)
{
_ctx = ctx;
_settings = settings.Value;
}
#region Ñâîéñòâà
/// <summary>
/// Ïðèëîæåíèå êîòîðîå ñìîòðèì.
/// </summary>
[BindProperty(SupportsGet = true)]
public int? Id { get; set; }
/// <summary>
/// Ìîäåëü ñòðàíèöû
/// </summary>
public ProfileViewModel PageViewModel { get; set; }
/// <summary>
/// Ñïèñîê ïðèëîæåíèé
/// </summary>
public List<SelectListItem> Options { get; set; }
/// <summary>
/// Âûáðàííîå ïðèëîæåíèå
/// </summary>
[BindProperty]
public string SelectedOptions { get; set; }
/// <summary>
/// Ýëåìåíòû îò÷åòà
/// </summary>
public List<ReportItemModel> ReportItems { get; set; }
#endregion
#region Îáðàáîò÷èêè
/// <summary>
/// Îáðàáîò÷èê ñòðàíèöû
/// </summary>
public async Task OnGet(int p = 1)
{
Options = await _ctx.Applications.Select(a =>
new SelectListItem
{
Value = a.Id.ToString(),
Text = a.Name
}).ToListAsync();
ApplicationDbItem app;
if (Id != null)
{
app = _ctx.Applications.FirstOrDefault(x => x.Id == Id.Value);
foreach (var item in Options.Where(item => item.Value == Id.Value.ToString()))
{
item.Selected = true;
}
}
else
{
app = _ctx.Applications.FirstOrDefault();
}
const int pageSize = 10; // êîëè÷åñòâî ýëåìåíòîâ íà ñòðàíèöå
var source = _ctx.Reports.Where(x => x.ApplicationId == app.Id);
var count = await source.CountAsync();
var items = await source.Skip((p - 1) * pageSize).Take(pageSize).ToListAsync();
var pageViewModel = new ProfileViewModel(count, p, pageSize);
PageViewModel = pageViewModel;
ReportItems = new List<ReportItemModel>();
foreach (var item in items)
{
ReportItems.Add(new ReportItemModel()
{
Application = app.Name,
Id = item.Id,
Created = item.Created,
Email = item.Email,
Hardware = item.HardwareId,
Ip = ByteToIpAddress(item.Ip),
Files = await GetFiles(item.Id)
});
}
}
private async Task<FileItemModel[]> GetFiles(int id)
{
var items = await _ctx.Files.Where(x => x.ReportId == id).ToListAsync();
return items.Select(item => new FileItemModel() { Id = item.Id, Name = item.Name }).ToArray();
}
/// <summary>
/// Âûáîðêà ïðèëîæåíèÿ
/// </summary>
/// <returns></returns>
public IActionResult OnPostFilterGenerated()
{
return RedirectToPage("Profile", new { id = SelectedOptions });
}
/// <summary>
/// Óäàëåíèå ðåïîðòà
/// </summary>
/// <param name="id"></param>
/// <param name="delid"></param>
/// <param name="p"></param>
/// <returns></returns>
public async Task<IActionResult> OnPostDeleteAsync(int delid, int id, int p)
{
var item = await _ctx.Reports.FindAsync(delid);
if (item == null) return RedirectToPage("Profile", new { id = id, p = p });
_ctx.Reports.Remove(item);
await _ctx.SaveChangesAsync();
var dirPath = Path.Combine(_settings.StoreDir, delid.ToString());
if (Directory.Exists(dirPath)) Directory.Delete(dirPath, true);
return RedirectToPage("Profile", new { id = id, p = p });
}
#endregion
private static string ByteToIpAddress(byte[] bytes)
{
var ip = new IPAddress(bytes).ToString();
ip = ip.Replace("::ffff:", "");
return ip;
}
}
}