generated from egmont11/ASP.Net-Core-MVC-Template
44 lines
1.1 KiB
C#
44 lines
1.1 KiB
C#
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 });
|
|
}
|
|
} |