diff --git a/.vs/StudyLib/DesignTimeBuild/.dtbcache.v2 b/.vs/StudyLib/DesignTimeBuild/.dtbcache.v2 index 49c74c2..012535f 100644 Binary files a/.vs/StudyLib/DesignTimeBuild/.dtbcache.v2 and b/.vs/StudyLib/DesignTimeBuild/.dtbcache.v2 differ diff --git a/.vs/StudyLib/v16/.suo b/.vs/StudyLib/v16/.suo index 4632310..477fa7a 100644 Binary files a/.vs/StudyLib/v16/.suo and b/.vs/StudyLib/v16/.suo differ diff --git a/API/Controllers/GroupCandidatesController.cs b/API/Controllers/GroupCandidatesController.cs index 6c74876..d9331b8 100644 --- a/API/Controllers/GroupCandidatesController.cs +++ b/API/Controllers/GroupCandidatesController.cs @@ -47,8 +47,33 @@ namespace StudyLib.API.Controllers return NoContent(); } - [HttpDelete("delete/{groupId}/{userId}")] - public async Task DeleteGroupCandidate(long groupId, string userId) + [HttpGet("accept/{groupId}/{userId}")] + public async Task AcceptGroupCandidate(long groupId, string userId) + { + var groupCandidate = await _context.GroupCandidates.Where(g => g.Group.ID == groupId && g.User.Id == userId).FirstAsync(); + if (groupCandidate == null) + { + return NotFound(); + } + + _context.GroupCandidates.Remove(groupCandidate); + + var user = await _context.Users.FindAsync(userId); + var group = await _context.Groups.Where(g => g.ID == groupId).Include(g => g.Users).FirstAsync(); + + if (!group.Users.Contains(user)) + { + group.Users.Add(user); + _context.Entry(group).State = EntityState.Modified; + } + + await _context.SaveChangesAsync(); + + return NoContent(); + } + + [HttpDelete("decline/{groupId}/{userId}")] + public async Task DeclineGroupCandidate(long groupId, string userId) { var groupCandidate = await _context.GroupCandidates.Where(g => g.Group.ID == groupId && g.User.Id == userId).FirstAsync(); if (groupCandidate == null) diff --git a/bin/Debug/net5.0/StudyLib.dll b/bin/Debug/net5.0/StudyLib.dll index 7f7a556..fba0460 100644 Binary files a/bin/Debug/net5.0/StudyLib.dll and b/bin/Debug/net5.0/StudyLib.dll differ diff --git a/bin/Debug/net5.0/StudyLib.pdb b/bin/Debug/net5.0/StudyLib.pdb index 4b9d631..cd94d79 100644 Binary files a/bin/Debug/net5.0/StudyLib.pdb and b/bin/Debug/net5.0/StudyLib.pdb differ diff --git a/bin/Debug/net5.0/ref/StudyLib.dll b/bin/Debug/net5.0/ref/StudyLib.dll index 0938268..8e3dd95 100644 Binary files a/bin/Debug/net5.0/ref/StudyLib.dll and b/bin/Debug/net5.0/ref/StudyLib.dll differ diff --git a/obj/Debug/net5.0/StudyLib.csprojAssemblyReference.cache b/obj/Debug/net5.0/StudyLib.csprojAssemblyReference.cache index 3e12f52..1e87a93 100644 Binary files a/obj/Debug/net5.0/StudyLib.csprojAssemblyReference.cache and b/obj/Debug/net5.0/StudyLib.csprojAssemblyReference.cache differ diff --git a/obj/Debug/net5.0/StudyLib.dll b/obj/Debug/net5.0/StudyLib.dll index 7f7a556..fba0460 100644 Binary files a/obj/Debug/net5.0/StudyLib.dll and b/obj/Debug/net5.0/StudyLib.dll differ diff --git a/obj/Debug/net5.0/StudyLib.pdb b/obj/Debug/net5.0/StudyLib.pdb index 4b9d631..cd94d79 100644 Binary files a/obj/Debug/net5.0/StudyLib.pdb and b/obj/Debug/net5.0/StudyLib.pdb differ diff --git a/obj/Debug/net5.0/ref/StudyLib.dll b/obj/Debug/net5.0/ref/StudyLib.dll index 0938268..8e3dd95 100644 Binary files a/obj/Debug/net5.0/ref/StudyLib.dll and b/obj/Debug/net5.0/ref/StudyLib.dll differ