-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from Learnathon-By-Geeky-Solutions/frontend/debug
User module Controllers seperated
- Loading branch information
Showing
14 changed files
with
249 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
backend/Modules/Users/MentorConnect.Users.API/Controllers/AdminControllers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using MentorConnect.BuildingBlocks.SharedKernel.DTOs.Users; | ||
using MentorConnect.Users.Application.Contracts; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace MentorConnect.Users.API.Controllers; | ||
|
||
[Route("api/admins")] | ||
[ApiController] | ||
public class AdminControllers(IUserServices userServices) : ControllerBase | ||
{ | ||
private readonly IUserServices _userServices = userServices; | ||
[HttpGet] | ||
public async Task<ActionResult<List<GetAdminDto>>> GetAdmins() | ||
{ | ||
return await _userServices.GetAllAdmins(); | ||
} | ||
[HttpGet("{id:guid}")] | ||
public async Task<ActionResult<GetAdminDto>> GetAdminById([FromRoute] Guid id) | ||
{ | ||
var allAdmins = await _userServices.GetAllAdmins(); | ||
var result = allAdmins.FirstOrDefault(admin => admin.Id == id); | ||
if (result == null) | ||
{ | ||
return NotFound(); | ||
} | ||
return result; | ||
} | ||
[HttpPost] | ||
public async Task<ActionResult<GetAdminDto>> AddAdmin([FromBody] CreateUpdateAdminDto admin) | ||
{ | ||
var result = await _userServices.AddAdmin(admin); | ||
return result; | ||
} | ||
[HttpPut("{id:guid}")] | ||
public async Task<ActionResult> UpdateAdmin([FromRoute] Guid id, [FromBody] CreateUpdateAdminDto admin) | ||
{ | ||
if (id != admin.Id) | ||
{ | ||
return BadRequest(); | ||
} | ||
await _userServices.UpdateAdmin(admin); | ||
return NoContent(); | ||
} | ||
[HttpDelete("{id:guid}")] | ||
public async Task<ActionResult> DeleteAdmin([FromRoute] Guid id) | ||
{ | ||
await _userServices.DeleteAdmin(id); | ||
return NoContent(); | ||
} | ||
} |
74 changes: 0 additions & 74 deletions
74
backend/Modules/Users/MentorConnect.Users.API/Controllers/Controllers.cs
This file was deleted.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
backend/Modules/Users/MentorConnect.Users.API/Controllers/MenteeControllers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using MentorConnect.BuildingBlocks.SharedKernel.DTOs.Users; | ||
using MentorConnect.Users.Application.Contracts; | ||
using Microsoft.AspNetCore.Mvc; | ||
namespace MentorConnect.Users.API.Controllers; | ||
|
||
[Route("api/mentees")] | ||
[ApiController] | ||
public class MenteeControllers(IUserServices userServices) : ControllerBase | ||
{ | ||
private readonly IUserServices _userServices = userServices; | ||
[HttpGet] | ||
public async Task<ActionResult<List<GetMenteeDto>>> GetMentees() | ||
{ | ||
return await _userServices.GetAllMentees(); | ||
} | ||
[HttpGet("{id:guid}")] | ||
public async Task<ActionResult<GetMenteeDto>> GetMenteeById([FromRoute] Guid id) | ||
{ | ||
var allMentees = await _userServices.GetAllMentees(); | ||
var result = allMentees.FirstOrDefault(mentee => mentee.Id == id); | ||
if (result == null) | ||
{ | ||
return NotFound(); | ||
} | ||
return result; | ||
} | ||
[HttpPost] | ||
public async Task<ActionResult<GetMenteeDto>> AddMentee([FromBody] CreateUpdateMenteeDto mentee) | ||
{ | ||
var result = await _userServices.AddMentee(mentee); | ||
return result; | ||
} | ||
[HttpPut("{id:guid}")] | ||
public async Task<ActionResult> UpdateMentee([FromRoute] Guid id, [FromBody] CreateUpdateMenteeDto mentee) | ||
{ | ||
if (id != mentee.Id) | ||
{ | ||
return BadRequest(); | ||
} | ||
await _userServices.UpdateMentee(mentee); | ||
return NoContent(); | ||
} | ||
[HttpDelete("{id:guid}")] | ||
public async Task<ActionResult> DeleteMentee([FromRoute] Guid id) | ||
{ | ||
await _userServices.DeleteMentee(id); | ||
return NoContent(); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
backend/Modules/Users/MentorConnect.Users.API/Controllers/MentorControllers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using MentorConnect.BuildingBlocks.SharedKernel.DTOs.Users; | ||
using MentorConnect.Users.Application.Contracts; | ||
using Microsoft.AspNetCore.Mvc; | ||
namespace MentorConnect.Users.API.Controllers; | ||
[Route("api/mentors")] | ||
[ApiController] | ||
public class MentorControllers(IUserServices userServices) : ControllerBase | ||
{ | ||
private readonly IUserServices _userServices = userServices; | ||
[HttpGet] | ||
public async Task<ActionResult<List<GetMentorDto>>> GetMentors() | ||
{ | ||
return await _userServices.GetAllMentors(); | ||
} | ||
[HttpGet("{id:guid}")] | ||
public async Task<ActionResult<GetMentorDto>> GetMentorById([FromRoute] Guid id) | ||
{ | ||
var allMentors = await _userServices.GetAllMentors(); | ||
var result = allMentors.FirstOrDefault(mentor => mentor.Id == id); | ||
if (result == null) | ||
{ | ||
return NotFound(); | ||
} | ||
return result; | ||
} | ||
[HttpPost] | ||
public async Task<ActionResult<GetMentorDto>> AddMentor([FromBody] CreateUpdateMentorDto mentor) | ||
{ | ||
var result = await _userServices.AddMentor(mentor); | ||
return result; | ||
} | ||
[HttpPut("{id:guid}")] | ||
public async Task<ActionResult> UpdateMentor([FromRoute] Guid id, [FromBody] CreateUpdateMentorDto mentor) | ||
{ | ||
if (id != mentor.Id) | ||
{ | ||
return BadRequest(); | ||
} | ||
await _userServices.UpdateMentor(mentor); | ||
return NoContent(); | ||
} | ||
[HttpDelete("{id:guid}")] | ||
public async Task<ActionResult> DeleteMentor([FromRoute] Guid id) | ||
{ | ||
await _userServices.DeleteMentor(id); | ||
return NoContent(); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
backend/Modules/Users/MentorConnect.Users.API/Controllers/UserControllers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using MentorConnect.BuildingBlocks.SharedKernel.DTOs.Users; | ||
using MentorConnect.Users.Application.Contracts; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace MentorConnect.Users.API.Controllers; | ||
|
||
[Route("api/users")] | ||
[ApiController] | ||
public class UserController(IUserServices userServices) : ControllerBase | ||
{ | ||
private readonly IUserServices _userServices = userServices; | ||
[HttpGet] | ||
public async Task<ActionResult<List<GetUserDto>>> GetUsers() | ||
{ | ||
return await _userServices.GetAllUsers(); | ||
} | ||
|
||
[HttpGet("{id:guid}")] | ||
public async Task<ActionResult<GetUserDto>> GetUserById([FromRoute] Guid id) | ||
{ | ||
GetUserDto? user = await _userServices.GetUserById(id); | ||
if (user == null) | ||
{ | ||
return NotFound(); | ||
} | ||
return user; | ||
} | ||
[HttpPost] | ||
public async Task<ActionResult<GetUserDto>> AddUser([FromBody] CreateUserDto user) | ||
{ | ||
var result = await _userServices.AddUser(user); | ||
return result; | ||
} | ||
[HttpPut("{id:guid}")] | ||
public async Task<ActionResult> UpdateUser([FromRoute] Guid id, [FromBody] UpdateUserDto user) | ||
{ | ||
if (id != user.Id) | ||
{ | ||
return BadRequest(); | ||
} | ||
await _userServices.UpdateUser(user); | ||
return NoContent(); | ||
} | ||
[HttpDelete("{id:guid}")] | ||
public async Task<ActionResult> DeleteUser([FromRoute] Guid id) | ||
{ | ||
await _userServices.DeleteUser(id); | ||
return NoContent(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.