From 72f52474ff19cb6313a82c886a885a670257f439 Mon Sep 17 00:00:00 2001 From: Mohammad Shabeer Date: Sun, 22 Sep 2024 01:31:22 +0530 Subject: [PATCH] mod:fixedProjStruct --- Controllers/TestController.cs | 2 +- Controllers/UserController.cs | 2 +- Helpers/GenerateJwtToken.cs | 1 + {dto => Models/Dto}/ApiRes.cs | 2 +- {dto => Models/Dto}/UserDto/UserReqDto.cs | 2 +- {dto => Models/Dto}/UserDto/UserResDto.cs | 2 +- {dto => Models/Dto}/UserDto/UserTokenResDto.cs | 2 +- Program.cs | 4 ++-- Repositories/UserRepository.cs | 2 +- Services/IUserService.cs | 4 ++-- Services/Impl/UserService.cs | 6 +++--- configuration/MapperConfig.cs | 2 +- configuration/ServiceConfiguration.cs | 2 +- 13 files changed, 17 insertions(+), 16 deletions(-) rename {dto => Models/Dto}/ApiRes.cs (84%) rename {dto => Models/Dto}/UserDto/UserReqDto.cs (91%) rename {dto => Models/Dto}/UserDto/UserResDto.cs (89%) rename {dto => Models/Dto}/UserDto/UserTokenResDto.cs (77%) diff --git a/Controllers/TestController.cs b/Controllers/TestController.cs index 61fc624..71f4bb8 100644 --- a/Controllers/TestController.cs +++ b/Controllers/TestController.cs @@ -1,5 +1,5 @@ using Microsoft.AspNetCore.Mvc; -using apekade.Dto; +using apekade.Models.Dto; using Microsoft.AspNetCore.Authorization; namespace apekade.Controllers; diff --git a/Controllers/UserController.cs b/Controllers/UserController.cs index 09f5530..416d9dd 100644 --- a/Controllers/UserController.cs +++ b/Controllers/UserController.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Mvc; using apekade.Enums; using apekade.Services; -using apekade.Dto.UserDto; +using apekade.Models.Dto.UserDto; namespace apekade.Controllers; diff --git a/Helpers/GenerateJwtToken.cs b/Helpers/GenerateJwtToken.cs index 78950eb..44a5b5d 100644 --- a/Helpers/GenerateJwtToken.cs +++ b/Helpers/GenerateJwtToken.cs @@ -28,6 +28,7 @@ public string GenerateJwt(User user) Subject = new ClaimsIdentity(new[] { new Claim(ClaimTypes.NameIdentifier, user.Id), + new Claim(ClaimTypes.Email, user.Email), new Claim(ClaimTypes.Role, user.Role.ToString()) }), Expires = DateTime.UtcNow.AddHours(1), diff --git a/dto/ApiRes.cs b/Models/Dto/ApiRes.cs similarity index 84% rename from dto/ApiRes.cs rename to Models/Dto/ApiRes.cs index ef59c1b..95029c3 100644 --- a/dto/ApiRes.cs +++ b/Models/Dto/ApiRes.cs @@ -1,4 +1,4 @@ -namespace apekade.Dto; +namespace apekade.Models.Dto; public class ApiRes{ public Boolean? Status {get;set;} diff --git a/dto/UserDto/UserReqDto.cs b/Models/Dto/UserDto/UserReqDto.cs similarity index 91% rename from dto/UserDto/UserReqDto.cs rename to Models/Dto/UserDto/UserReqDto.cs index bbbeaef..18da596 100644 --- a/dto/UserDto/UserReqDto.cs +++ b/Models/Dto/UserDto/UserReqDto.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using apekade.Enums; -namespace apekade.Dto.UserDto; +namespace apekade.Models.Dto.UserDto; public class UserReqtDto { diff --git a/dto/UserDto/UserResDto.cs b/Models/Dto/UserDto/UserResDto.cs similarity index 89% rename from dto/UserDto/UserResDto.cs rename to Models/Dto/UserDto/UserResDto.cs index 0de9dbc..c455751 100644 --- a/dto/UserDto/UserResDto.cs +++ b/Models/Dto/UserDto/UserResDto.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using apekade.Enums; -namespace apekade.Dto.UserDto; +namespace apekade.Models.Dto.UserDto; public class UserResDto { diff --git a/dto/UserDto/UserTokenResDto.cs b/Models/Dto/UserDto/UserTokenResDto.cs similarity index 77% rename from dto/UserDto/UserTokenResDto.cs rename to Models/Dto/UserDto/UserTokenResDto.cs index 08437ac..4a221d9 100644 --- a/dto/UserDto/UserTokenResDto.cs +++ b/Models/Dto/UserDto/UserTokenResDto.cs @@ -1,4 +1,4 @@ -namespace apekade.Dto.UserDto; +namespace apekade.Models.Dto.UserDto; public class UserTokenResDto { diff --git a/Program.cs b/Program.cs index 2667653..46690f3 100644 --- a/Program.cs +++ b/Program.cs @@ -1,5 +1,5 @@ using apekade.Configuration; -using apekade.Dto; +using apekade.Models.Dto; var builder = WebApplication.CreateBuilder(args); @@ -30,7 +30,7 @@ { Status = true, Code = 200, - Data = new { Message = "Server Online" } + Data = new { Message = "server_online" } }); app.Run(); \ No newline at end of file diff --git a/Repositories/UserRepository.cs b/Repositories/UserRepository.cs index 796df39..2e37ce1 100644 --- a/Repositories/UserRepository.cs +++ b/Repositories/UserRepository.cs @@ -12,7 +12,7 @@ public UserRepository(IMongoDatabase database) _usersCollection = database.GetCollection("Users"); } - public async Task save(User user) + public async Task Save(User user) { await _usersCollection.InsertOneAsync(user); } diff --git a/Services/IUserService.cs b/Services/IUserService.cs index c425381..1aaf014 100644 --- a/Services/IUserService.cs +++ b/Services/IUserService.cs @@ -1,5 +1,5 @@ -using apekade.Dto; -using apekade.Dto.UserDto; +using apekade.Models.Dto; +using apekade.Models.Dto.UserDto; namespace apekade.Services; diff --git a/Services/Impl/UserService.cs b/Services/Impl/UserService.cs index 71a1c9f..1302466 100644 --- a/Services/Impl/UserService.cs +++ b/Services/Impl/UserService.cs @@ -1,10 +1,10 @@ using AutoMapper; using apekade.Models; -using apekade.Dto; +using apekade.Models.Dto; using apekade.Repositories; using apekade.Helpers; using apekade.Services.Impl; -using apekade.Dto.UserDto; +using apekade.Models.Dto.UserDto; namespace apekade.Services.Impl; @@ -34,7 +34,7 @@ public async Task> CreateNewUser(UserReqtDto userRequest newUser.PasswordHash = passwordHash; newUser.PasswordSalt = passwordSalt; - await _userRepository.save(newUser); + await _userRepository.Save(newUser); var token = _generateJwtToken.GenerateJwt(newUser); diff --git a/configuration/MapperConfig.cs b/configuration/MapperConfig.cs index 41f2444..43e2312 100644 --- a/configuration/MapperConfig.cs +++ b/configuration/MapperConfig.cs @@ -1,6 +1,6 @@ using AutoMapper; using apekade.Models; -using apekade.Dto.UserDto; +using apekade.Models.Dto.UserDto; namespace apekade.Configuration; diff --git a/configuration/ServiceConfiguration.cs b/configuration/ServiceConfiguration.cs index e309cd4..585ce0a 100644 --- a/configuration/ServiceConfiguration.cs +++ b/configuration/ServiceConfiguration.cs @@ -1,5 +1,5 @@ using System.Reflection; -using apekade.Dto.UserDto; +using apekade.Models.Dto.UserDto; using apekade.Helpers; using apekade.Repositories; using apekade.Services;