WebApi + ClientApp, GraphQL, Reflection

This commit is contained in:
Boris Milašinović
2026-05-06 20:55:05 +02:00
parent 8f7c704a90
commit 4fb3de19f6
196 changed files with 10395 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
using Events.EF.Data.MSSQL;
using Events.EF.Models;
namespace GraphQLServer.SetupGraphQL;
public partial class Mutations
{
public async Task<Event> AddEvent([Service] EventsContext ctx, EventInput input)
{
var item = new Event
{
Name = input.Name,
EventDate = input.EventDate
};
ctx.Events.Add(item);
await ctx.SaveChangesAsync();
return item;
}
public async Task<Event?> UpdateEvent([Service] EventsContext ctx, int id, EventInput input)
{
var item = await ctx.Events.FindAsync(id);
if (item is null)
{
return null;
}
item.Name = input.Name;
item.EventDate = input.EventDate;
await ctx.SaveChangesAsync();
return item;
}
public async Task<bool> DeleteEvent([Service] EventsContext ctx, int id)
{
var item = await ctx.Events.FindAsync(id);
if (item is null)
{
return false;
}
ctx.Events.Remove(item);
await ctx.SaveChangesAsync();
return true;
}
}