using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Auth.Contracts.DTOs.Users; using Auth.Core.Services; using Auth.Core.Services.HR.Users; using Microsoft.AspNetCore.Mvc; namespace Auth.API.Endpoints.v1.UserEndpoints; public static class UserMap { public static RouteGroupBuilder UserEndpoints(this RouteGroupBuilder group) { // group.MapGet( // "location", // async (UserService userService, HttpContext httpContext) => // { // var userId = httpContext.User.Claims.FirstOrDefault(x => x.Type == "uid").Value; // return await userService.GetLocation(userId); // } // ); // group.MapPut( // "location", // async (Location location, UserService userService, HttpContext httpContext) => // { // var userId = httpContext.User.Claims.FirstOrDefault(x => x.Type == "uid").Value; // return await userService.UpdateLocation(location, userId); // } // ); // // group.MapGet("user_realestates/{id}", ( // // string id, // // UserService userService // // ) => // // { // // return userService.GetUserView(id); // // }); //get your own profile/settings group.MapGet( "user", async (UserService userService, HttpContext httpContext) => { var userId = httpContext.User.Claims.FirstOrDefault(x => x.Type == "uid").Value; return await userService.GetUser(userId); } ); //get user id (for admins) group.MapGet( "user/{id}", async (string id, UserService userService) => { return await userService.GetUser(id); } ); //get all users information group .MapGet( "users", async (UserService userService) => { return await userService.GetAllUsers(); } ) ; //update user info group.MapPut( "user", async ( [FromBody] UserInfoUpdate userVM, HttpContext httpContext, UserService userService ) => { var userId = httpContext.User.Claims.FirstOrDefault(x => x.Type == "uid").Value; await userService.UpdateUserInfo(userVM, userId); } ); return group; } }