generated from egmont11/ASP.Net-Core-MVC-Template
Přemístění + dodělání funkčnosti webu.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using StuzkovakWeb.Data;
|
||||
|
||||
namespace StuzkovakWeb.Controllers;
|
||||
|
||||
public class InvitesController : Controller
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public InvitesController(AppDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Accept(Guid id)
|
||||
{
|
||||
var invite = await _context.Invites.FindAsync(id);
|
||||
if (invite == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
invite.IsAccepted = true;
|
||||
_context.Invites.Update(invite);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return RedirectToAction("Index", "Home", new { Id=id });
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Refuse(Guid id)
|
||||
{
|
||||
var invite = await _context.Invites.FindAsync(id);
|
||||
if (invite == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
invite.IsAccepted = false;
|
||||
_context.Invites.Update(invite);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return RedirectToAction("Index", "Home", new { Id=id });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user