dev
This commit is contained in:
68
ZpcBulletinBoard/Pages/BoardsLinks/Index.cshtml
Normal file
68
ZpcBulletinBoard/Pages/BoardsLinks/Index.cshtml
Normal file
@@ -0,0 +1,68 @@
|
||||
@page
|
||||
@model ZpcBulletinBoard.Pages.BoardsLinks.IndexModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Oglasne deske - Povezave";
|
||||
Layout = "~/Pages/Shared/_Layout.cshtml";
|
||||
}
|
||||
|
||||
@section Styles
|
||||
{
|
||||
<link rel="stylesheet" href="~/css/boards-links/index.css" asp-append-version="true" />
|
||||
}
|
||||
|
||||
<h4 class="d-flex justify-content-between align-items-center w-100 font-weight-bold py-1 mb-4">
|
||||
<span>
|
||||
<span class="text-muted font-weight-light">
|
||||
<i>Oglasne deske</i>
|
||||
/</span> Povezave
|
||||
</span>
|
||||
</h4>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="div-content">
|
||||
<div class="div-content-boards">
|
||||
<h6>Oglasne deske</h6>
|
||||
</div>
|
||||
<div class="div-content-pages">
|
||||
<h6>Strani</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="div-content main-content">
|
||||
<div class="div-content-boards boards-content">
|
||||
@* @foreach (var board in Model.Boards)
|
||||
{
|
||||
<div class="div-board">
|
||||
<h5>@board.Name</h5>
|
||||
</div>
|
||||
<div class="div-pages" ondrop="dropPage(event, this)" ondragover="allowDropPage(event, this)" data-idboard="@board.IdBulletinBoard">
|
||||
|
||||
</div>
|
||||
<hr/>
|
||||
} *@
|
||||
</div>
|
||||
<div class="div-content-pages">
|
||||
<div class="div-available-pages">
|
||||
@foreach (var tmpPage in Model.Pages)
|
||||
{
|
||||
<div class="div-page available-page" draggable="true" ondragstart="dragPage(event, this)" data-id="@tmpPage.IdBulletinBoardPage">
|
||||
<img class="img-thumbnail rounded" src="/bulletin-board-images/pages/@tmpPage.Image" alt="page image" />
|
||||
<small>@tmpPage.Name</small>
|
||||
<div class="tools">
|
||||
<a href="javascript:;" class="btn btn-xs icon-btn btn-outline-primary borderless"><i class="fas fa-reply"></i></a>
|
||||
<a href="javascript:;" class="btn btn-xs icon-btn btn-outline-secondary borderless"><i class="fas fa-reply-all"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
@section Scripts {
|
||||
<script src="~/js/boards-links/index.js" asp-append-version="true"></script>
|
||||
}
|
||||
72
ZpcBulletinBoard/Pages/BoardsLinks/Index.cshtml.cs
Normal file
72
ZpcBulletinBoard/Pages/BoardsLinks/Index.cshtml.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using ZpcBulletinBoard.Data;
|
||||
using ZpcBulletinBoard.Models.Editor;
|
||||
|
||||
namespace ZpcBulletinBoard.Pages.BoardsLinks
|
||||
{
|
||||
[Authorize]
|
||||
public class IndexModel(ApplicationDbContext context) : PageModel
|
||||
{
|
||||
public IList<BulletinBoardPage> Pages { get;set; }
|
||||
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
Pages = await context.BulletinBoardPage.OrderBy(x => x.Name).ToListAsync();
|
||||
}
|
||||
|
||||
//Get
|
||||
public IActionResult OnGetBoards()
|
||||
{
|
||||
var boards = context.BulletinBoards
|
||||
.Include(x => x.Links.OrderBy(y => y.Order))
|
||||
.ThenInclude(x => x.BulletinBoardPage)
|
||||
.ToList();
|
||||
|
||||
foreach (var board in boards)
|
||||
{
|
||||
foreach (var link in board.Links)
|
||||
{
|
||||
link.BulletinBoardPage.Links = null;
|
||||
link.BulletinBoard = null;
|
||||
}
|
||||
}
|
||||
|
||||
return new JsonResult(new { successful = true, error = $"", boards });
|
||||
}
|
||||
|
||||
|
||||
//Post
|
||||
public IActionResult OnPostAddLink(int idBoard, int idPage)
|
||||
{
|
||||
var order = 1;
|
||||
var links = context.BulletinBoardPageLinks.Where(x => x.IdBulletinBoardFk == idBoard).ToList();
|
||||
if (links.Any())
|
||||
order = links.Max(x => x.IdLink) + 1;
|
||||
|
||||
var link = new BulletinBoardPageLink
|
||||
{
|
||||
Duration = 30,
|
||||
IdBulletinBoardFk = idBoard,
|
||||
IdBulletinBoardPageFk = idPage,
|
||||
Order = order
|
||||
};
|
||||
|
||||
context.BulletinBoardPageLinks.Add(link);
|
||||
|
||||
context.SaveChanges();
|
||||
|
||||
link = context.BulletinBoardPageLinks.Include(x => x.BulletinBoardPage).First(x => x.IdLink == link.IdLink);
|
||||
|
||||
link.BulletinBoardPage.Links = null;
|
||||
|
||||
return new JsonResult(new { successful = true, error = $"", link });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user