aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Web
diff options
context:
space:
mode:
authorKamen Mladenov <kamen.d.mladenov@protonmail.com>2021-04-09 19:51:35 +0300
committerGitHub <noreply@github.com>2021-04-09 19:51:35 +0300
commit233f38915ba0079079233eff55434ef349c05c45 (patch)
tree6c5f69017865bcab87355e910c87339453da1406 /src/DevHive.Web
parentf4a70c6430db923af9fa9958a11c2d6612cb52cc (diff)
parenta992357efcf1bc1ece81b95ecee5e05a0b73bfdc (diff)
downloadDevHive-0.2.tar
DevHive-0.2.tar.gz
DevHive-0.2.zip
Merge pull request #28 from Team-Kaleidoscope/devHEADv0.2mainheroku/main
Second stage: Complete
Diffstat (limited to 'src/DevHive.Web')
-rw-r--r--src/DevHive.Web/Attributes/GoodPasswordModelValidation.cs24
-rw-r--r--src/DevHive.Web/Attributes/OnlyLettersModelValidation.cs20
-rw-r--r--src/DevHive.Web/Configurations/Extensions/ConfigureAutoMapper.cs24
-rw-r--r--src/DevHive.Web/Configurations/Extensions/ConfigureDatabase.cs70
-rw-r--r--src/DevHive.Web/Configurations/Extensions/ConfigureDependencyInjection.cs38
-rw-r--r--src/DevHive.Web/Configurations/Extensions/ConfigureExceptionHandlerMiddleware.cs16
-rw-r--r--src/DevHive.Web/Configurations/Extensions/ConfigureJWT.cs54
-rw-r--r--src/DevHive.Web/Configurations/Extensions/ConfigureSwagger.cs23
-rw-r--r--src/DevHive.Web/Configurations/Mapping/CommentMappings.cs17
-rw-r--r--src/DevHive.Web/Configurations/Mapping/FeedMappings.cs18
-rw-r--r--src/DevHive.Web/Configurations/Mapping/LanguageMappings.cs23
-rw-r--r--src/DevHive.Web/Configurations/Mapping/PostMappings.cs17
-rw-r--r--src/DevHive.Web/Configurations/Mapping/RatingMappings.cs16
-rw-r--r--src/DevHive.Web/Configurations/Mapping/RoleMappings.cs21
-rw-r--r--src/DevHive.Web/Configurations/Mapping/TechnologyMappings.cs23
-rw-r--r--src/DevHive.Web/Configurations/Mapping/UserMappings.cs33
-rw-r--r--src/DevHive.Web/Controllers/CommentController.cs83
-rw-r--r--src/DevHive.Web/Controllers/FeedController.cs54
-rw-r--r--src/DevHive.Web/Controllers/LanguageController.cs87
-rw-r--r--src/DevHive.Web/Controllers/PostController.cs89
-rw-r--r--src/DevHive.Web/Controllers/RateController.cs40
-rw-r--r--src/DevHive.Web/Controllers/RoleController.cs77
-rw-r--r--src/DevHive.Web/Controllers/TechnologyController.cs87
-rw-r--r--src/DevHive.Web/Controllers/UserController.cs140
-rw-r--r--src/DevHive.Web/DevHive.Web.csproj27
-rw-r--r--src/DevHive.Web/Middleware/ExceptionMiddleware.cs50
-rw-r--r--src/DevHive.Web/Models/Comment/CreateCommentWebModel.cs17
-rw-r--r--src/DevHive.Web/Models/Comment/ReadCommentWebModel.cs21
-rw-r--r--src/DevHive.Web/Models/Comment/UpdateCommentWebModel.cs13
-rw-r--r--src/DevHive.Web/Models/Feed/GetPageWebModel.cs19
-rw-r--r--src/DevHive.Web/Models/Feed/ReadPageWebModel.cs10
-rw-r--r--src/DevHive.Web/Models/Identity/Role/CreateRoleWebModel.cs14
-rw-r--r--src/DevHive.Web/Models/Identity/Role/RoleWebModel.cs14
-rw-r--r--src/DevHive.Web/Models/Identity/Role/UpdateRoleWebModel.cs15
-rw-r--r--src/DevHive.Web/Models/Identity/User/BaseUserWebModel.cs34
-rw-r--r--src/DevHive.Web/Models/Identity/User/LoginWebModel.cs20
-rw-r--r--src/DevHive.Web/Models/Identity/User/ProfilePictureWebModel.cs7
-rw-r--r--src/DevHive.Web/Models/Identity/User/RegisterWebModel.cs14
-rw-r--r--src/DevHive.Web/Models/Identity/User/TokenWebModel.cs12
-rw-r--r--src/DevHive.Web/Models/Identity/User/UpdateProfilePictureWebModel.cs9
-rw-r--r--src/DevHive.Web/Models/Identity/User/UpdateUserWebModel.cs34
-rw-r--r--src/DevHive.Web/Models/Identity/User/UserWebModel.cs33
-rw-r--r--src/DevHive.Web/Models/Identity/User/UsernameWebModel.cs15
-rw-r--r--src/DevHive.Web/Models/Language/CreateLanguageWebModel.cs14
-rw-r--r--src/DevHive.Web/Models/Language/LanguageWebModel.cs13
-rw-r--r--src/DevHive.Web/Models/Language/ReadLanguageWebModel.cs11
-rw-r--r--src/DevHive.Web/Models/Language/UpdateLanguageWebModel.cs14
-rw-r--r--src/DevHive.Web/Models/Post/CreatePostWebModel.cs16
-rw-r--r--src/DevHive.Web/Models/Post/Rating/RatePostWebModel.cs11
-rw-r--r--src/DevHive.Web/Models/Post/Rating/ReadPostRatingWebModel.cs15
-rw-r--r--src/DevHive.Web/Models/Post/ReadPostWebModel.cs26
-rw-r--r--src/DevHive.Web/Models/Post/UpdatePostWebModel.cs21
-rw-r--r--src/DevHive.Web/Models/Technology/CreateTechnologyWebModel.cs14
-rw-r--r--src/DevHive.Web/Models/Technology/ReadTechnologyWebModel.cs11
-rw-r--r--src/DevHive.Web/Models/Technology/TechnologyWebModel.cs13
-rw-r--r--src/DevHive.Web/Models/Technology/UpdateTechnologyWebModel.cs15
-rw-r--r--src/DevHive.Web/Program.cs23
-rw-r--r--src/DevHive.Web/Properties/launchSettings.json36
-rw-r--r--src/DevHive.Web/Startup.cs70
-rw-r--r--src/DevHive.Web/appsettings.json20
60 files changed, 0 insertions, 1815 deletions
diff --git a/src/DevHive.Web/Attributes/GoodPasswordModelValidation.cs b/src/DevHive.Web/Attributes/GoodPasswordModelValidation.cs
deleted file mode 100644
index 7d6a1ea..0000000
--- a/src/DevHive.Web/Attributes/GoodPasswordModelValidation.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-using System.ComponentModel.DataAnnotations;
-
-namespace DevHive.Web.Attributes
-{
- public class GoodPassword : ValidationAttribute
- {
- public override bool IsValid(object value)
- {
- var stringValue = (string)value;
-
- for (int i = 0; i < stringValue.Length; i++)
- {
- if (Char.IsDigit(stringValue[i]))
- {
- base.ErrorMessage = "Password must be atleast 5 characters long!";
- return stringValue.Length >= 5;
- }
- }
- base.ErrorMessage = "Password must contain atleast 1 digit!";
- return false;
- }
- }
-}
diff --git a/src/DevHive.Web/Attributes/OnlyLettersModelValidation.cs b/src/DevHive.Web/Attributes/OnlyLettersModelValidation.cs
deleted file mode 100644
index 07afee9..0000000
--- a/src/DevHive.Web/Attributes/OnlyLettersModelValidation.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-using System.ComponentModel.DataAnnotations;
-
-namespace DevHive.Web.Attributes
-{
- public class OnlyLetters : ValidationAttribute
- {
- public override bool IsValid(object value)
- {
- var stringValue = (string)value;
-
- foreach (char ch in stringValue)
- {
- if (!Char.IsLetter(ch))
- return false;
- }
- return true;
- }
- }
-}
diff --git a/src/DevHive.Web/Configurations/Extensions/ConfigureAutoMapper.cs b/src/DevHive.Web/Configurations/Extensions/ConfigureAutoMapper.cs
deleted file mode 100644
index 8b7d657..0000000
--- a/src/DevHive.Web/Configurations/Extensions/ConfigureAutoMapper.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-using AutoMapper;
-//using AutoMapper.Configuration;
-using Microsoft.AspNetCore.Builder;
-using Microsoft.Extensions.DependencyInjection;
-
-namespace DevHive.Web.Configurations.Extensions
-{
- public static class ConfigureAutoMapper
- {
- public static void AutoMapperConfiguration(this IServiceCollection services)
- {
- services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
- }
-
- public static void UseAutoMapperConfiguration(this IApplicationBuilder app)
- {
- var config = new MapperConfiguration(cfg =>
- {
- cfg.AllowNullCollections = true;
- });
- }
- }
-} \ No newline at end of file
diff --git a/src/DevHive.Web/Configurations/Extensions/ConfigureDatabase.cs b/src/DevHive.Web/Configurations/Extensions/ConfigureDatabase.cs
deleted file mode 100644
index 9f02dd7..0000000
--- a/src/DevHive.Web/Configurations/Extensions/ConfigureDatabase.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.Extensions.Configuration;
-using DevHive.Data.Models;
-using Microsoft.AspNetCore.Identity;
-using Microsoft.AspNetCore.Builder;
-using System;
-using Microsoft.AspNetCore.Authentication.JwtBearer;
-using DevHive.Data;
-
-namespace DevHive.Web.Configurations.Extensions
-{
- public static class DatabaseExtensions
- {
- public static void DatabaseConfiguration(this IServiceCollection services, IConfiguration configuration)
- {
- services.AddDbContext<DevHiveContext>(options =>
- {
- options.EnableSensitiveDataLogging(true);
- options.UseNpgsql(configuration.GetConnectionString("DEV"));
- });
-
- services.AddIdentity<User, Role>()
- .AddRoles<Role>()
- .AddEntityFrameworkStores<DevHiveContext>();
-
- services.Configure<IdentityOptions>(options =>
- {
- options.User.RequireUniqueEmail = true;
-
- options.Password.RequireDigit = true;
- options.Password.RequiredLength = 5;
- options.Password.RequiredUniqueChars = 0;
- options.Password.RequireLowercase = false;
- options.Password.RequireNonAlphanumeric = false;
- options.Password.RequireUppercase = false;
-
- options.Lockout.AllowedForNewUsers = true;
- options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(5);
- options.Lockout.MaxFailedAccessAttempts = 5;
- });
-
- services.AddAuthorization(options =>
- {
- options.AddPolicy("User", options =>
- {
- options.RequireAuthenticatedUser();
- options.AuthenticationSchemes.Add(JwtBearerDefaults.AuthenticationScheme);
- options.RequireRole("User");
- });
-
- options.AddPolicy("Administrator", options =>
- {
- options.RequireAuthenticatedUser();
- options.AuthenticationSchemes.Add(JwtBearerDefaults.AuthenticationScheme);
- options.RequireRole("Admin");
- });
- });
- }
-
- public static void UseDatabaseConfiguration(this IApplicationBuilder app)
- {
- app.UseHttpsRedirection();
- app.UseRouting();
-
- app.UseAuthentication();
- app.UseAuthorization();
- }
- }
-}
diff --git a/src/DevHive.Web/Configurations/Extensions/ConfigureDependencyInjection.cs b/src/DevHive.Web/Configurations/Extensions/ConfigureDependencyInjection.cs
deleted file mode 100644
index 88f21d4..0000000
--- a/src/DevHive.Web/Configurations/Extensions/ConfigureDependencyInjection.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using DevHive.Data.Interfaces.Repositories;
-using DevHive.Data.Repositories;
-using DevHive.Services.Interfaces;
-using DevHive.Services.Services;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
-
-namespace DevHive.Web.Configurations.Extensions
-{
- public static class ConfigureDependencyInjection
- {
- public static void DependencyInjectionConfiguration(this IServiceCollection services, IConfiguration configuration)
- {
- services.AddTransient<ILanguageRepository, LanguageRepository>();
- services.AddTransient<IRoleRepository, RoleRepository>();
- services.AddTransient<ITechnologyRepository, TechnologyRepository>();
- services.AddTransient<IUserRepository, UserRepository>();
- services.AddTransient<IPostRepository, PostRepository>();
- services.AddTransient<ICommentRepository, CommentRepository>();
- services.AddTransient<IFeedRepository, FeedRepository>();
- services.AddTransient<IRatingRepository, RatingRepository>();
-
- services.AddTransient<ILanguageService, LanguageService>();
- services.AddTransient<IRoleService, RoleService>();
- services.AddTransient<ITechnologyService, TechnologyService>();
- services.AddTransient<IUserService, UserService>();
- services.AddTransient<IPostService, PostService>();
- services.AddTransient<ICommentService, CommentService>();
- services.AddTransient<IFeedService, FeedService>();
- services.AddTransient<ICloudService, CloudinaryService>(options =>
- new CloudinaryService(
- cloudName: configuration.GetSection("Cloud").GetSection("cloudName").Value,
- apiKey: configuration.GetSection("Cloud").GetSection("apiKey").Value,
- apiSecret: configuration.GetSection("Cloud").GetSection("apiSecret").Value));
- services.AddTransient<IRateService, RateService>();
- }
- }
-}
diff --git a/src/DevHive.Web/Configurations/Extensions/ConfigureExceptionHandlerMiddleware.cs b/src/DevHive.Web/Configurations/Extensions/ConfigureExceptionHandlerMiddleware.cs
deleted file mode 100644
index 286727f..0000000
--- a/src/DevHive.Web/Configurations/Extensions/ConfigureExceptionHandlerMiddleware.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using DevHive.Web.Middleware;
-using Microsoft.AspNetCore.Builder;
-using Microsoft.Extensions.DependencyInjection;
-
-namespace DevHive.Web.Configurations.Extensions
-{
- public static class ConfigureExceptionHandlerMiddleware
- {
- public static void ExceptionHandlerMiddlewareConfiguration(this IServiceCollection services) { }
-
- public static void UseExceptionHandlerMiddlewareConfiguration(this IApplicationBuilder app)
- {
- app.UseMiddleware<ExceptionMiddleware>();
- }
- }
-}
diff --git a/src/DevHive.Web/Configurations/Extensions/ConfigureJWT.cs b/src/DevHive.Web/Configurations/Extensions/ConfigureJWT.cs
deleted file mode 100644
index d422bc8..0000000
--- a/src/DevHive.Web/Configurations/Extensions/ConfigureJWT.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System.Text;
-using System.Threading.Tasks;
-using DevHive.Services.Options;
-using Microsoft.AspNetCore.Authentication.JwtBearer;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.IdentityModel.Tokens;
-
-namespace DevHive.Web.Configurations.Extensions
-{
- public static class JWTExtensions
- {
- public static void JWTConfiguration(this IServiceCollection services, IConfiguration configuration)
- {
- services.AddSingleton(new JWTOptions(configuration
- .GetSection("AppSettings")
- .GetSection("Secret")
- .Value));
-
- // Get key from appsettings.json
- var key = Encoding.ASCII.GetBytes(configuration
- .GetSection("AppSettings")
- .GetSection("Secret")
- .Value);
-
- // Setup Jwt Authentication
- services.AddAuthentication(x =>
- {
- x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
- x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
- })
- .AddJwtBearer(x =>
- {
- x.Events = new JwtBearerEvents
- {
- OnTokenValidated = context =>
- {
- // TODO: add more authentication
- return Task.CompletedTask;
- }
- };
- x.RequireHttpsMetadata = false;
- x.SaveToken = true;
- x.TokenValidationParameters = new TokenValidationParameters
- {
- //ValidateIssuerSigningKey = false,
- IssuerSigningKey = new SymmetricSecurityKey(key),
- ValidateIssuer = false,
- ValidateAudience = false
- };
- });
- }
- }
-} \ No newline at end of file
diff --git a/src/DevHive.Web/Configurations/Extensions/ConfigureSwagger.cs b/src/DevHive.Web/Configurations/Extensions/ConfigureSwagger.cs
deleted file mode 100644
index a0641ab..0000000
--- a/src/DevHive.Web/Configurations/Extensions/ConfigureSwagger.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using Microsoft.AspNetCore.Builder;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.OpenApi.Models;
-
-namespace DevHive.Web.Configurations.Extensions
-{
- public static class SwaggerExtensions
- {
- public static void SwaggerConfiguration(this IServiceCollection services)
- {
- services.AddSwaggerGen(c =>
- {
- c.SwaggerDoc("v1", new OpenApiInfo { Title = "API", Version = "v1" });
- });
- }
-
- public static void UseSwaggerConfiguration(this IApplicationBuilder app)
- {
- app.UseSwagger();
- app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "API v1"));
- }
- }
-} \ No newline at end of file
diff --git a/src/DevHive.Web/Configurations/Mapping/CommentMappings.cs b/src/DevHive.Web/Configurations/Mapping/CommentMappings.cs
deleted file mode 100644
index b8d6829..0000000
--- a/src/DevHive.Web/Configurations/Mapping/CommentMappings.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using AutoMapper;
-using DevHive.Services.Models.Comment;
-using DevHive.Web.Models.Comment;
-
-namespace DevHive.Web.Configurations.Mapping
-{
- public class CommentMappings : Profile
- {
- public CommentMappings()
- {
- CreateMap<CreateCommentWebModel, CreateCommentServiceModel>();
- CreateMap<UpdateCommentWebModel, UpdateCommentServiceModel>();
-
- CreateMap<ReadCommentServiceModel, ReadCommentWebModel>();
- }
- }
-}
diff --git a/src/DevHive.Web/Configurations/Mapping/FeedMappings.cs b/src/DevHive.Web/Configurations/Mapping/FeedMappings.cs
deleted file mode 100644
index 0909f6d..0000000
--- a/src/DevHive.Web/Configurations/Mapping/FeedMappings.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using AutoMapper;
-using DevHive.Services.Models;
-using DevHive.Web.Models.Comment;
-using DevHive.Web.Models.Feed;
-
-namespace DevHive.Web.Configurations.Mapping
-{
- public class FeedMappings : Profile
- {
- public FeedMappings()
- {
- CreateMap<GetPageWebModel, GetPageServiceModel>()
- .ForMember(dest => dest.FirstRequestIssued, src => src.MapFrom(p => p.FirstPageTimeIssued));
-
- CreateMap<ReadPageServiceModel, ReadPageWebModel>();
- }
- }
-}
diff --git a/src/DevHive.Web/Configurations/Mapping/LanguageMappings.cs b/src/DevHive.Web/Configurations/Mapping/LanguageMappings.cs
deleted file mode 100644
index eca0d1a..0000000
--- a/src/DevHive.Web/Configurations/Mapping/LanguageMappings.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using AutoMapper;
-using DevHive.Web.Models.Language;
-using DevHive.Services.Models.Language;
-
-namespace DevHive.Web.Configurations.Mapping
-{
- public class LanguageMappings : Profile
- {
- public LanguageMappings()
- {
- CreateMap<CreateLanguageWebModel, CreateLanguageServiceModel>();
- CreateMap<ReadLanguageWebModel, ReadLanguageServiceModel>();
- CreateMap<UpdateLanguageWebModel, UpdateLanguageServiceModel>()
- .ForMember(src => src.Id, dest => dest.Ignore());
- CreateMap<LanguageWebModel, LanguageServiceModel>();
-
- CreateMap<LanguageServiceModel, LanguageWebModel>();
- CreateMap<ReadLanguageServiceModel, ReadLanguageWebModel>();
- CreateMap<CreateLanguageServiceModel, CreateLanguageWebModel>();
- CreateMap<UpdateLanguageServiceModel, UpdateLanguageWebModel>();
- }
- }
-}
diff --git a/src/DevHive.Web/Configurations/Mapping/PostMappings.cs b/src/DevHive.Web/Configurations/Mapping/PostMappings.cs
deleted file mode 100644
index a5b46ee..0000000
--- a/src/DevHive.Web/Configurations/Mapping/PostMappings.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using AutoMapper;
-using DevHive.Services.Models.Post;
-using DevHive.Web.Models.Post;
-
-namespace DevHive.Web.Configurations.Mapping
-{
- public class PostMappings : Profile
- {
- public PostMappings()
- {
- CreateMap<CreatePostWebModel, CreatePostServiceModel>();
- CreateMap<UpdatePostWebModel, UpdatePostServiceModel>();
-
- CreateMap<ReadPostServiceModel, ReadPostWebModel>();
- }
- }
-}
diff --git a/src/DevHive.Web/Configurations/Mapping/RatingMappings.cs b/src/DevHive.Web/Configurations/Mapping/RatingMappings.cs
deleted file mode 100644
index 4e071de..0000000
--- a/src/DevHive.Web/Configurations/Mapping/RatingMappings.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using AutoMapper;
-using DevHive.Services.Models.Post.Rating;
-using DevHive.Web.Models.Post.Rating;
-
-namespace DevHive.Web.Configurations.Mapping
-{
- public class RatingMappings : Profile
- {
- public RatingMappings()
- {
- CreateMap<RatePostWebModel, RatePostServiceModel>();
-
- CreateMap<ReadPostRatingServiceModel, ReadPostRatingWebModel>();
- }
- }
-}
diff --git a/src/DevHive.Web/Configurations/Mapping/RoleMappings.cs b/src/DevHive.Web/Configurations/Mapping/RoleMappings.cs
deleted file mode 100644
index 2ea2742..0000000
--- a/src/DevHive.Web/Configurations/Mapping/RoleMappings.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using AutoMapper;
-using DevHive.Web.Models.Identity.Role;
-using DevHive.Services.Models.Identity.Role;
-
-namespace DevHive.Web.Configurations.Mapping
-{
- public class RoleMappings : Profile
- {
- public RoleMappings()
- {
- CreateMap<CreateRoleWebModel, CreateRoleServiceModel>();
- CreateMap<UpdateRoleWebModel, UpdateRoleServiceModel>()
- .ForMember(src => src.Id, dest => dest.Ignore());
- CreateMap<RoleWebModel, RoleServiceModel>();
-
- CreateMap<CreateRoleServiceModel, CreateRoleWebModel>();
- CreateMap<UpdateRoleServiceModel, UpdateRoleWebModel>();
- CreateMap<RoleServiceModel, RoleWebModel>();
- }
- }
-}
diff --git a/src/DevHive.Web/Configurations/Mapping/TechnologyMappings.cs b/src/DevHive.Web/Configurations/Mapping/TechnologyMappings.cs
deleted file mode 100644
index 708b6ac..0000000
--- a/src/DevHive.Web/Configurations/Mapping/TechnologyMappings.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using AutoMapper;
-using DevHive.Web.Models.Technology;
-using DevHive.Services.Models.Technology;
-
-namespace DevHive.Web.Configurations.Mapping
-{
- public class TechnologyMappings : Profile
- {
- public TechnologyMappings()
- {
- CreateMap<CreateTechnologyWebModel, CreateTechnologyServiceModel>();
- CreateMap<ReadTechnologyWebModel, ReadTechnologyServiceModel>();
- CreateMap<UpdateTechnologyWebModel, UpdateTechnologyServiceModel>()
- .ForMember(src => src.Id, dest => dest.Ignore());
- CreateMap<TechnologyWebModel, TechnologyServiceModel>();
-
- CreateMap<CreateTechnologyServiceModel, CreateTechnologyWebModel>();
- CreateMap<ReadTechnologyServiceModel, ReadTechnologyWebModel>();
- CreateMap<UpdateTechnologyServiceModel, UpdateTechnologyWebModel>();
- CreateMap<TechnologyServiceModel, TechnologyWebModel>();
- }
- }
-}
diff --git a/src/DevHive.Web/Configurations/Mapping/UserMappings.cs b/src/DevHive.Web/Configurations/Mapping/UserMappings.cs
deleted file mode 100644
index f58e7ca..0000000
--- a/src/DevHive.Web/Configurations/Mapping/UserMappings.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using AutoMapper;
-using DevHive.Services.Models.Identity.User;
-using DevHive.Web.Models.Identity.User;
-using DevHive.Common.Models.Identity;
-
-namespace DevHive.Web.Configurations.Mapping
-{
- public class UserMappings : Profile
- {
- public UserMappings()
- {
- CreateMap<LoginWebModel, LoginServiceModel>();
- CreateMap<RegisterWebModel, RegisterServiceModel>();
- CreateMap<UserWebModel, UserServiceModel>();
- CreateMap<UpdateUserWebModel, UpdateUserServiceModel>();
-
- CreateMap<UserServiceModel, UserWebModel>();
-
- CreateMap<TokenModel, TokenWebModel>();
-
- //Update
- CreateMap<UpdateUserWebModel, UpdateUserServiceModel>();
- CreateMap<UsernameWebModel, FriendServiceModel>();
- CreateMap<UsernameWebModel, UpdateFriendServiceModel>();
-
- CreateMap<UpdateProfilePictureWebModel, UpdateProfilePictureServiceModel>();
- CreateMap<ProfilePictureServiceModel, ProfilePictureWebModel>();
-
- CreateMap<UpdateUserServiceModel, UpdateUserWebModel>();
- CreateMap<FriendServiceModel, UsernameWebModel>();
- }
- }
-}
diff --git a/src/DevHive.Web/Controllers/CommentController.cs b/src/DevHive.Web/Controllers/CommentController.cs
deleted file mode 100644
index c38e300..0000000
--- a/src/DevHive.Web/Controllers/CommentController.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Mvc;
-using AutoMapper;
-using System;
-using DevHive.Web.Models.Comment;
-using DevHive.Services.Models.Comment;
-using Microsoft.AspNetCore.Authorization;
-using DevHive.Services.Interfaces;
-
-namespace DevHive.Web.Controllers
-{
- [ApiController]
- [Route("/api/[controller]")]
- [Authorize(Roles = "User,Admin")]
- public class CommentController
- {
- private readonly ICommentService _commentService;
- private readonly IMapper _commentMapper;
-
- public CommentController(ICommentService commentService, IMapper commentMapper)
- {
- this._commentService = commentService;
- this._commentMapper = commentMapper;
- }
-
- [HttpPost]
- public async Task<IActionResult> AddComment(Guid userId, [FromBody] CreateCommentWebModel createCommentWebModel, [FromHeader] string authorization)
- {
- if (!await this._commentService.ValidateJwtForCreating(userId, authorization))
- return new UnauthorizedResult();
-
- CreateCommentServiceModel createCommentServiceModel =
- this._commentMapper.Map<CreateCommentServiceModel>(createCommentWebModel);
- createCommentServiceModel.CreatorId = userId;
-
- Guid id = await this._commentService.AddComment(createCommentServiceModel);
-
- return id == Guid.Empty ?
- new BadRequestObjectResult("Could not create comment!") :
- new OkObjectResult(new { Id = id });
- }
-
- [HttpGet]
- [AllowAnonymous]
- public async Task<IActionResult> GetCommentById(Guid id)
- {
- ReadCommentServiceModel readCommentServiceModel = await this._commentService.GetCommentById(id);
- ReadCommentWebModel readCommentWebModel = this._commentMapper.Map<ReadCommentWebModel>(readCommentServiceModel);
-
- return new OkObjectResult(readCommentWebModel);
- }
-
- [HttpPut]
- public async Task<IActionResult> UpdateComment(Guid userId, [FromBody] UpdateCommentWebModel updateCommentWebModel, [FromHeader] string authorization)
- {
- if (!await this._commentService.ValidateJwtForComment(updateCommentWebModel.CommentId, authorization))
- return new UnauthorizedResult();
-
- UpdateCommentServiceModel updateCommentServiceModel =
- this._commentMapper.Map<UpdateCommentServiceModel>(updateCommentWebModel);
- updateCommentServiceModel.CreatorId = userId;
-
- Guid id = await this._commentService.UpdateComment(updateCommentServiceModel);
-
- return id == Guid.Empty ?
- new BadRequestObjectResult("Unable to update comment!") :
- new OkObjectResult(new { Id = id });
- }
-
- [HttpDelete]
- public async Task<IActionResult> DeleteComment(Guid id, [FromHeader] string authorization)
- {
- if (!await this._commentService.ValidateJwtForComment(id, authorization))
- return new UnauthorizedResult();
-
- return await this._commentService.DeleteComment(id) ?
- new OkResult() :
- new BadRequestObjectResult("Could not delete Comment");
- }
-
- }
-}
-
diff --git a/src/DevHive.Web/Controllers/FeedController.cs b/src/DevHive.Web/Controllers/FeedController.cs
deleted file mode 100644
index abca3e4..0000000
--- a/src/DevHive.Web/Controllers/FeedController.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using AutoMapper;
-using DevHive.Services.Interfaces;
-using DevHive.Services.Models;
-using DevHive.Web.Models.Comment;
-using DevHive.Web.Models.Feed;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-
-namespace DevHive.Web.Controllers
-{
- [ApiController]
- [Route("/api/[controller]")]
- [Authorize(Roles = "User,Admin")]
- public class FeedController
- {
- private readonly IFeedService _feedService;
- private readonly IMapper _mapper;
-
- public FeedController(IFeedService feedService, IMapper mapper)
- {
- this._feedService = feedService;
- this._mapper = mapper;
- }
-
- [HttpPost]
- [Route("GetPosts")]
- public async Task<IActionResult> GetPosts(Guid userId, [FromBody] GetPageWebModel getPageWebModel)
- {
- GetPageServiceModel getPageServiceModel = this._mapper.Map<GetPageServiceModel>(getPageWebModel);
- getPageServiceModel.UserId = userId;
-
- ReadPageServiceModel readPageServiceModel = await this._feedService.GetPage(getPageServiceModel);
- ReadPageWebModel readPageWebModel = this._mapper.Map<ReadPageWebModel>(readPageServiceModel);
-
- return new OkObjectResult(readPageWebModel);
- }
-
- [HttpPost]
- [Route("GetUserPosts")]
- [AllowAnonymous]
- public async Task<IActionResult> GetUserPosts(string username, [FromBody] GetPageWebModel getPageWebModel)
- {
- GetPageServiceModel getPageServiceModel = this._mapper.Map<GetPageServiceModel>(getPageWebModel);
- getPageServiceModel.Username = username;
-
- ReadPageServiceModel readPageServiceModel = await this._feedService.GetUserPage(getPageServiceModel);
- ReadPageWebModel readPageWebModel = this._mapper.Map<ReadPageWebModel>(readPageServiceModel);
-
- return new OkObjectResult(readPageWebModel);
- }
- }
-}
diff --git a/src/DevHive.Web/Controllers/LanguageController.cs b/src/DevHive.Web/Controllers/LanguageController.cs
deleted file mode 100644
index 5b0d5de..0000000
--- a/src/DevHive.Web/Controllers/LanguageController.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using AutoMapper;
-using DevHive.Services.Interfaces;
-using DevHive.Services.Models.Language;
-using DevHive.Web.Models.Language;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-
-namespace DevHive.Web.Controllers
-{
- [ApiController]
- [Route("/api/[controller]")]
- public class LanguageController
- {
- private readonly ILanguageService _languageService;
- private readonly IMapper _languageMapper;
-
- public LanguageController(ILanguageService languageService, IMapper mapper)
- {
- this._languageService = languageService;
- this._languageMapper = mapper;
- }
-
- [HttpPost]
- [Authorize(Roles = "Admin")]
- public async Task<IActionResult> Create([FromBody] CreateLanguageWebModel createLanguageWebModel)
- {
- CreateLanguageServiceModel languageServiceModel = this._languageMapper.Map<CreateLanguageServiceModel>(createLanguageWebModel);
-
- Guid id = await this._languageService.CreateLanguage(languageServiceModel);
-
- return id == Guid.Empty ?
- new BadRequestObjectResult($"Could not create language {createLanguageWebModel.Name}") :
- new OkObjectResult(new { Id = id });
- }
-
- [HttpGet]
- [AllowAnonymous]
- public async Task<IActionResult> GetById(Guid id)
- {
- ReadLanguageServiceModel languageServiceModel = await this._languageService.GetLanguageById(id);
- ReadLanguageWebModel languageWebModel = this._languageMapper.Map<ReadLanguageWebModel>(languageServiceModel);
-
- return new OkObjectResult(languageWebModel);
- }
-
- [HttpGet]
- [Route("GetLanguages")]
- [Authorize(Roles = "User,Admin")]
- public IActionResult GetAllExistingLanguages()
- {
- HashSet<ReadLanguageServiceModel> languageServiceModels = this._languageService.GetLanguages();
- HashSet<ReadLanguageWebModel> languageWebModels = this._languageMapper.Map<HashSet<ReadLanguageWebModel>>(languageServiceModels);
-
- return new OkObjectResult(languageWebModels);
- }
-
- [HttpPut]
- [Authorize(Roles = "Admin")]
- public async Task<IActionResult> Update(Guid id, [FromBody] UpdateLanguageWebModel updateModel)
- {
- UpdateLanguageServiceModel updatelanguageServiceModel = this._languageMapper.Map<UpdateLanguageServiceModel>(updateModel);
- updatelanguageServiceModel.Id = id;
-
- bool result = await this._languageService.UpdateLanguage(updatelanguageServiceModel);
-
- if (!result)
- return new BadRequestObjectResult("Could not update Language");
-
- return new OkResult();
- }
-
- [HttpDelete]
- [Authorize(Roles = "Admin")]
- public async Task<IActionResult> Delete(Guid id)
- {
- bool result = await this._languageService.DeleteLanguage(id);
-
- if (!result)
- return new BadRequestObjectResult("Could not delete Language");
-
- return new OkResult();
- }
- }
-}
diff --git a/src/DevHive.Web/Controllers/PostController.cs b/src/DevHive.Web/Controllers/PostController.cs
deleted file mode 100644
index d3fdbf6..0000000
--- a/src/DevHive.Web/Controllers/PostController.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Mvc;
-using AutoMapper;
-using System;
-using DevHive.Web.Models.Post;
-using DevHive.Services.Models.Post;
-using Microsoft.AspNetCore.Authorization;
-using DevHive.Services.Interfaces;
-
-namespace DevHive.Web.Controllers
-{
- [ApiController]
- [Route("/api/[controller]")]
- [Authorize(Roles = "User,Admin")]
- public class PostController
- {
- private readonly IPostService _postService;
- private readonly IMapper _postMapper;
-
- public PostController(IPostService postService, IMapper postMapper)
- {
- this._postService = postService;
- this._postMapper = postMapper;
- }
-
- #region Create
- [HttpPost]
- public async Task<IActionResult> Create(Guid userId, [FromForm] CreatePostWebModel createPostWebModel, [FromHeader] string authorization)
- {
- if (!await this._postService.ValidateJwtForCreating(userId, authorization))
- return new UnauthorizedResult();
-
- CreatePostServiceModel createPostServiceModel =
- this._postMapper.Map<CreatePostServiceModel>(createPostWebModel);
- createPostServiceModel.CreatorId = userId;
-
- Guid id = await this._postService.CreatePost(createPostServiceModel);
-
- return id == Guid.Empty ?
- new BadRequestObjectResult("Could not create post!") :
- new OkObjectResult(new { Id = id });
- }
- #endregion
-
- #region Read
- [HttpGet]
- [AllowAnonymous]
- public async Task<IActionResult> GetById(Guid id)
- {
- ReadPostServiceModel postServiceModel = await this._postService.GetPostById(id);
- ReadPostWebModel postWebModel = this._postMapper.Map<ReadPostWebModel>(postServiceModel);
-
- return new OkObjectResult(postWebModel);
- }
- #endregion
-
- #region Update
- [HttpPut]
- public async Task<IActionResult> Update(Guid userId, [FromForm] UpdatePostWebModel updatePostWebModel, [FromHeader] string authorization)
- {
- if (!await this._postService.ValidateJwtForPost(updatePostWebModel.PostId, authorization))
- return new UnauthorizedResult();
-
- UpdatePostServiceModel updatePostServiceModel =
- this._postMapper.Map<UpdatePostServiceModel>(updatePostWebModel);
- updatePostServiceModel.CreatorId = userId;
-
- Guid id = await this._postService.UpdatePost(updatePostServiceModel);
-
- return id == Guid.Empty ?
- new BadRequestObjectResult("Could not update post!") :
- new OkObjectResult(new { Id = id });
- }
- #endregion
-
- #region Delete
- [HttpDelete]
- public async Task<IActionResult> Delete(Guid id, [FromHeader] string authorization)
- {
- if (!await this._postService.ValidateJwtForPost(id, authorization))
- return new UnauthorizedResult();
-
- return await this._postService.DeletePost(id) ?
- new OkResult() :
- new BadRequestObjectResult("Could not delete Post");
- }
- #endregion
- }
-}
diff --git a/src/DevHive.Web/Controllers/RateController.cs b/src/DevHive.Web/Controllers/RateController.cs
deleted file mode 100644
index 68b859b..0000000
--- a/src/DevHive.Web/Controllers/RateController.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using AutoMapper;
-using DevHive.Services.Interfaces;
-using DevHive.Services.Models.Post.Rating;
-using DevHive.Web.Models.Post.Rating;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-
-namespace DevHive.Web.Controllers
-{
- [ApiController]
- [Route("api/[controller]")]
- public class RateController
- {
- private readonly IRateService _rateService;
- private readonly IUserService _userService;
- private readonly IMapper _mapper;
-
- public RateController(IRateService rateService, IUserService userService, IMapper mapper)
- {
- this._rateService = rateService;
- this._userService = userService;
- this._mapper = mapper;
- }
-
- [HttpPost]
- [Authorize(Roles = "Admin,User")]
- public async Task<IActionResult> RatePost(Guid userId, [FromBody] RatePostWebModel ratePostWebModel, [FromHeader] string authorization)
- {
- RatePostServiceModel ratePostServiceModel = this._mapper.Map<RatePostServiceModel>(ratePostWebModel);
- ratePostServiceModel.UserId = userId;
-
- ReadPostRatingServiceModel readPostRatingServiceModel = await this._rateService.RatePost(ratePostServiceModel);
- ReadPostRatingWebModel readPostRatingWebModel = this._mapper.Map<ReadPostRatingWebModel>(readPostRatingServiceModel);
-
- return new OkObjectResult(readPostRatingWebModel);
- }
- }
-}
diff --git a/src/DevHive.Web/Controllers/RoleController.cs b/src/DevHive.Web/Controllers/RoleController.cs
deleted file mode 100644
index 0d2a2eb..0000000
--- a/src/DevHive.Web/Controllers/RoleController.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Mvc;
-using DevHive.Web.Models.Identity.Role;
-using AutoMapper;
-using System;
-using DevHive.Services.Interfaces;
-using DevHive.Services.Models.Identity.Role;
-using Microsoft.AspNetCore.Authorization;
-
-namespace DevHive.Web.Controllers
-{
- [ApiController]
- [Route("/api/[controller]")]
- public class RoleController
- {
- private readonly IRoleService _roleService;
- private readonly IMapper _roleMapper;
-
- public RoleController(IRoleService roleService, IMapper mapper)
- {
- this._roleService = roleService;
- this._roleMapper = mapper;
- }
-
- [HttpPost]
- [Authorize(Roles = "Admin")]
- public async Task<IActionResult> Create([FromBody] CreateRoleWebModel createRoleWebModel)
- {
- CreateRoleServiceModel roleServiceModel =
- this._roleMapper.Map<CreateRoleServiceModel>(createRoleWebModel);
-
- Guid id = await this._roleService.CreateRole(roleServiceModel);
-
- return id == Guid.Empty ?
- new BadRequestObjectResult($"Could not create role {createRoleWebModel.Name}") :
- new OkObjectResult(new { Id = id });
- }
-
- [HttpGet]
- [Authorize(Roles = "User,Admin")]
- public async Task<IActionResult> GetById(Guid id)
- {
- RoleServiceModel roleServiceModel = await this._roleService.GetRoleById(id);
- RoleWebModel roleWebModel = this._roleMapper.Map<RoleWebModel>(roleServiceModel);
-
- return new OkObjectResult(roleWebModel);
- }
-
- [HttpPut]
- [Authorize(Roles = "Admin")]
- public async Task<IActionResult> Update(Guid id, [FromBody] UpdateRoleWebModel updateRoleWebModel)
- {
- UpdateRoleServiceModel updateRoleServiceModel =
- this._roleMapper.Map<UpdateRoleServiceModel>(updateRoleWebModel);
- updateRoleServiceModel.Id = id;
-
- bool result = await this._roleService.UpdateRole(updateRoleServiceModel);
-
- if (!result)
- return new BadRequestObjectResult("Could not update role!");
-
- return new OkResult();
- }
-
- [HttpDelete]
- [Authorize(Roles = "Admin")]
- public async Task<IActionResult> Delete(Guid id)
- {
- bool result = await this._roleService.DeleteRole(id);
-
- if (!result)
- return new BadRequestObjectResult("Could not delete role!");
-
- return new OkResult();
- }
- }
-}
diff --git a/src/DevHive.Web/Controllers/TechnologyController.cs b/src/DevHive.Web/Controllers/TechnologyController.cs
deleted file mode 100644
index e507899..0000000
--- a/src/DevHive.Web/Controllers/TechnologyController.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using AutoMapper;
-using DevHive.Services.Interfaces;
-using DevHive.Services.Models.Technology;
-using DevHive.Web.Models.Technology;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-
-namespace DevHive.Web.Controllers
-{
- [ApiController]
- [Route("/api/[controller]")]
- public class TechnologyController
- {
- private readonly ITechnologyService _technologyService;
- private readonly IMapper _technologyMapper;
-
- public TechnologyController(ITechnologyService technologyService, IMapper technologyMapper)
- {
- this._technologyService = technologyService;
- this._technologyMapper = technologyMapper;
- }
-
- [HttpPost]
- [Authorize(Roles = "Admin")]
- public async Task<IActionResult> Create([FromBody] CreateTechnologyWebModel createTechnologyWebModel)
- {
- CreateTechnologyServiceModel technologyServiceModel = this._technologyMapper.Map<CreateTechnologyServiceModel>(createTechnologyWebModel);
-
- Guid id = await this._technologyService.CreateTechnology(technologyServiceModel);
-
- return id == Guid.Empty ?
- new BadRequestObjectResult($"Could not create technology {createTechnologyWebModel.Name}") :
- new OkObjectResult(new { Id = id });
- }
-
- [HttpGet]
- [AllowAnonymous]
- public async Task<IActionResult> GetById(Guid id)
- {
- ReadTechnologyServiceModel readTechnologyServiceModel = await this._technologyService.GetTechnologyById(id);
- ReadTechnologyWebModel readTechnologyWebModel = this._technologyMapper.Map<ReadTechnologyWebModel>(readTechnologyServiceModel);
-
- return new OkObjectResult(readTechnologyWebModel);
- }
-
- [HttpGet]
- [Route("GetTechnologies")]
- [Authorize(Roles = "User,Admin")]
- public IActionResult GetAllExistingTechnologies()
- {
- HashSet<ReadTechnologyServiceModel> technologyServiceModels = this._technologyService.GetTechnologies();
- HashSet<ReadTechnologyWebModel> languageWebModels = this._technologyMapper.Map<HashSet<ReadTechnologyWebModel>>(technologyServiceModels);
-
- return new OkObjectResult(languageWebModels);
- }
-
- [HttpPut]
- [Authorize(Roles = "Admin")]
- public async Task<IActionResult> Update(Guid id, [FromBody] UpdateTechnologyWebModel updateModel)
- {
- UpdateTechnologyServiceModel updateTechnologyServiceModel = this._technologyMapper.Map<UpdateTechnologyServiceModel>(updateModel);
- updateTechnologyServiceModel.Id = id;
-
- bool result = await this._technologyService.UpdateTechnology(updateTechnologyServiceModel);
-
- if (!result)
- return new BadRequestObjectResult("Could not update Technology");
-
- return new OkResult();
- }
-
- [HttpDelete]
- [Authorize(Roles = "Admin")]
- public async Task<IActionResult> Delete(Guid id)
- {
- bool result = await this._technologyService.DeleteTechnology(id);
-
- if (!result)
- return new BadRequestObjectResult("Could not delete Technology");
-
- return new OkResult();
- }
- }
-}
diff --git a/src/DevHive.Web/Controllers/UserController.cs b/src/DevHive.Web/Controllers/UserController.cs
deleted file mode 100644
index 109bbaa..0000000
--- a/src/DevHive.Web/Controllers/UserController.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using AutoMapper;
-using DevHive.Services.Models.Identity.User;
-using DevHive.Web.Models.Identity.User;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-using DevHive.Common.Models.Identity;
-using DevHive.Services.Interfaces;
-using Microsoft.Extensions.Hosting;
-
-namespace DevHive.Web.Controllers
-{
- [ApiController]
- [Route("/api/[controller]")]
- public class UserController : ControllerBase
- {
- private readonly IUserService _userService;
- private readonly IMapper _userMapper;
-
- public UserController(IUserService userService, IMapper mapper)
- {
- this._userService = userService;
- this._userMapper = mapper;
- }
-
- #region Authentication
- [HttpPost]
- [Route("Login")]
- [AllowAnonymous]
- public async Task<IActionResult> Login([FromBody] LoginWebModel loginModel)
- {
- LoginServiceModel loginServiceModel = this._userMapper.Map<LoginServiceModel>(loginModel);
-
- TokenModel TokenModel = await this._userService.LoginUser(loginServiceModel);
- TokenWebModel tokenWebModel = this._userMapper.Map<TokenWebModel>(TokenModel);
-
- return new OkObjectResult(tokenWebModel);
- }
-
- [HttpPost]
- [Route("Register")]
- [AllowAnonymous]
- public async Task<IActionResult> Register([FromBody] RegisterWebModel registerModel)
- {
- RegisterServiceModel registerServiceModel = this._userMapper.Map<RegisterServiceModel>(registerModel);
-
- TokenModel TokenModel = await this._userService.RegisterUser(registerServiceModel);
- TokenWebModel tokenWebModel = this._userMapper.Map<TokenWebModel>(TokenModel);
-
- return new CreatedResult("Register", tokenWebModel);
- }
- #endregion
-
- #region Read
- [HttpGet]
- [Authorize(Roles = "User,Admin")]
- public async Task<IActionResult> GetById(Guid id, [FromHeader] string authorization)
- {
- if (!await this._userService.ValidJWT(id, authorization))
- return new UnauthorizedResult();
-
- UserServiceModel userServiceModel = await this._userService.GetUserById(id);
- UserWebModel userWebModel = this._userMapper.Map<UserWebModel>(userServiceModel);
-
- return new OkObjectResult(userWebModel);
- }
-
- [HttpGet]
- [Route("GetUser")]
- [AllowAnonymous]
- public async Task<IActionResult> GetUser(string username)
- {
- UserServiceModel friendServiceModel = await this._userService.GetUserByUsername(username);
- UserWebModel friend = this._userMapper.Map<UserWebModel>(friendServiceModel);
-
- return new OkObjectResult(friend);
- }
- #endregion
-
- #region Update
- [HttpPut]
- [Authorize(Roles = "User,Admin")]
- public async Task<IActionResult> Update(Guid id, [FromBody] UpdateUserWebModel updateUserWebModel, [FromHeader] string authorization)
- {
- if (!await this._userService.ValidJWT(id, authorization))
- return new UnauthorizedResult();
-
- UpdateUserServiceModel updateUserServiceModel = this._userMapper.Map<UpdateUserServiceModel>(updateUserWebModel);
- updateUserServiceModel.Id = id;
-
- UserServiceModel userServiceModel = await this._userService.UpdateUser(updateUserServiceModel);
- UserWebModel userWebModel = this._userMapper.Map<UserWebModel>(userServiceModel);
-
- return new AcceptedResult("UpdateUser", userWebModel);
- }
-
- [HttpPut]
- [Route("ProfilePicture")]
- [Authorize(Roles = "User,Admin")]
- public async Task<IActionResult> UpdateProfilePicture(Guid userId, [FromForm] UpdateProfilePictureWebModel updateProfilePictureWebModel, [FromHeader] string authorization)
- {
- if (!await this._userService.ValidJWT(userId, authorization))
- return new UnauthorizedResult();
-
- UpdateProfilePictureServiceModel updateProfilePictureServiceModel = this._userMapper.Map<UpdateProfilePictureServiceModel>(updateProfilePictureWebModel);
- updateProfilePictureServiceModel.UserId = userId;
-
- ProfilePictureServiceModel profilePictureServiceModel = await this._userService.UpdateProfilePicture(updateProfilePictureServiceModel);
- ProfilePictureWebModel profilePictureWebModel = this._userMapper.Map<ProfilePictureWebModel>(profilePictureServiceModel);
-
- return new AcceptedResult("UpdateProfilePicture", profilePictureWebModel);
- }
- #endregion
-
- #region Delete
- [HttpDelete]
- [Authorize(Roles = "User,Admin")]
- public async Task<IActionResult> Delete(Guid id, [FromHeader] string authorization)
- {
- if (!await this._userService.ValidJWT(id, authorization))
- return new UnauthorizedResult();
-
- bool result = await this._userService.DeleteUser(id);
- if (!result)
- return new BadRequestObjectResult("Could not delete User");
-
- return new OkResult();
- }
- #endregion
-
- [HttpPost]
- [Authorize(Roles = "User,Admin")]
- [Route("SuperSecretPromotionToAdmin")]
- public async Task<IActionResult> SuperSecretPromotionToAdmin(Guid userId)
- {
- return new OkObjectResult(await this._userService.SuperSecretPromotionToAdmin(userId));
- }
- }
-}
diff --git a/src/DevHive.Web/DevHive.Web.csproj b/src/DevHive.Web/DevHive.Web.csproj
deleted file mode 100644
index 0aa2831..0000000
--- a/src/DevHive.Web/DevHive.Web.csproj
+++ /dev/null
@@ -1,27 +0,0 @@
-<Project Sdk="Microsoft.NET.Sdk.Web">
- <PropertyGroup>
- <TargetFramework>net5.0</TargetFramework>
- </PropertyGroup>
- <PropertyGroup>
- <EnableNETAnalyzers>true</EnableNETAnalyzers>
- <AnalysisLevel>latest</AnalysisLevel>
- </PropertyGroup>
- <ItemGroup>
- <PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.1" NoWarn="NU1605"/>
- <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.1" NoWarn="NU1605"/>
- <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.1">
- <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
- <PrivateAssets>all</PrivateAssets>
- </PackageReference>
- <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.1"/>
- <PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3"/>
- <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.0"/>
- <PackageReference Include="AutoMapper" Version="10.1.1"/>
- <PackageReference Include="Newtonsoft.Json" Version="12.0.3"/>
- <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.1"/>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\DevHive.Services\DevHive.Services.csproj"/>
- <ProjectReference Include="..\DevHive.Common\DevHive.Common.csproj"/>
- </ItemGroup>
-</Project>
diff --git a/src/DevHive.Web/Middleware/ExceptionMiddleware.cs b/src/DevHive.Web/Middleware/ExceptionMiddleware.cs
deleted file mode 100644
index cb6d4ca..0000000
--- a/src/DevHive.Web/Middleware/ExceptionMiddleware.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using System;
-using System.Net;
-using System.Threading.Tasks;
-using Microsoft.AspNetCore.Http;
-using Microsoft.Extensions.Logging;
-
-namespace DevHive.Web.Middleware
-{
- public class ExceptionMiddleware
- {
- private readonly RequestDelegate _next;
- // private readonly ILogger _logger;
-
- public ExceptionMiddleware(RequestDelegate next)
- {
- this._next = next;
- // this._logger = logger;
- }
- // public ExceptionMiddleware(RequestDelegate next, ILogger logger)
- // {
- // this._logger = logger;
- // this._next = next;
- // }
-
- public async Task InvokeAsync(HttpContext httpContext)
- {
- try
- {
- await this._next(httpContext);
- }
- catch (Exception ex)
- {
- // this._logger.LogError($"Something went wrong: {ex}");
- await HandleExceptionAsync(httpContext, ex);
- }
- }
-
- private Task HandleExceptionAsync(HttpContext context, Exception exception)
- {
- context.Response.ContentType = "application/json";
- context.Response.StatusCode = (int)HttpStatusCode.BadRequest;
-
- return context.Response.WriteAsync(new
- {
- StatusCode = context.Response.StatusCode,
- Message = exception.Message
- }.ToString());
- }
- }
-}
diff --git a/src/DevHive.Web/Models/Comment/CreateCommentWebModel.cs b/src/DevHive.Web/Models/Comment/CreateCommentWebModel.cs
deleted file mode 100644
index 8b2bf8d..0000000
--- a/src/DevHive.Web/Models/Comment/CreateCommentWebModel.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System;
-using System.ComponentModel.DataAnnotations;
-using System.Diagnostics.CodeAnalysis;
-
-namespace DevHive.Web.Models.Comment
-{
- public class CreateCommentWebModel
- {
- [NotNull]
- [Required]
- public Guid PostId { get; set; }
-
- [NotNull]
- [Required]
- public string Message { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Comment/ReadCommentWebModel.cs b/src/DevHive.Web/Models/Comment/ReadCommentWebModel.cs
deleted file mode 100644
index 4d3aff7..0000000
--- a/src/DevHive.Web/Models/Comment/ReadCommentWebModel.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System;
-
-namespace DevHive.Web.Models.Comment
-{
- public class ReadCommentWebModel
- {
- public Guid CommentId { get; set; }
-
- public Guid PostId { get; set; }
-
- public string IssuerFirstName { get; set; }
-
- public string IssuerLastName { get; set; }
-
- public string IssuerUsername { get; set; }
-
- public string Message { get; set; }
-
- public DateTime TimeCreated { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Comment/UpdateCommentWebModel.cs b/src/DevHive.Web/Models/Comment/UpdateCommentWebModel.cs
deleted file mode 100644
index b5d7970..0000000
--- a/src/DevHive.Web/Models/Comment/UpdateCommentWebModel.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-
-namespace DevHive.Web.Models.Comment
-{
- public class UpdateCommentWebModel
- {
- public Guid CommentId { get; set; }
-
- public Guid PostId { get; set; }
-
- public string NewMessage { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Feed/GetPageWebModel.cs b/src/DevHive.Web/Models/Feed/GetPageWebModel.cs
deleted file mode 100644
index 4ea44cc..0000000
--- a/src/DevHive.Web/Models/Feed/GetPageWebModel.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-using System.ComponentModel;
-using System.ComponentModel.DataAnnotations;
-
-namespace DevHive.Web.Models.Feed
-{
- public class GetPageWebModel
- {
- [Range(1, int.MaxValue)]
- public int PageNumber { get; set; }
-
- [Required]
- public DateTime FirstPageTimeIssued { get; set; }
-
- [DefaultValue(5)]
- [Range(1, int.MaxValue)]
- public int PageSize { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Feed/ReadPageWebModel.cs b/src/DevHive.Web/Models/Feed/ReadPageWebModel.cs
deleted file mode 100644
index f429313..0000000
--- a/src/DevHive.Web/Models/Feed/ReadPageWebModel.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System.Collections.Generic;
-using DevHive.Web.Models.Post;
-
-namespace DevHive.Web.Models.Comment
-{
- public class ReadPageWebModel
- {
- public List<ReadPostWebModel> Posts { get; set; } = new();
- }
-}
diff --git a/src/DevHive.Web/Models/Identity/Role/CreateRoleWebModel.cs b/src/DevHive.Web/Models/Identity/Role/CreateRoleWebModel.cs
deleted file mode 100644
index 859cdd9..0000000
--- a/src/DevHive.Web/Models/Identity/Role/CreateRoleWebModel.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System.ComponentModel.DataAnnotations;
-using System.Diagnostics.CodeAnalysis;
-
-namespace DevHive.Web.Models.Identity.Role
-{
- public class CreateRoleWebModel
- {
- [NotNull]
- [Required]
- [MinLength(3)]
- [MaxLength(50)]
- public string Name { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Identity/Role/RoleWebModel.cs b/src/DevHive.Web/Models/Identity/Role/RoleWebModel.cs
deleted file mode 100644
index 99b0f50..0000000
--- a/src/DevHive.Web/Models/Identity/Role/RoleWebModel.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System.ComponentModel.DataAnnotations;
-using System.Diagnostics.CodeAnalysis;
-
-namespace DevHive.Web.Models.Identity.Role
-{
- public class RoleWebModel
- {
- [NotNull]
- [Required]
- [MinLength(3)]
- [MaxLength(50)]
- public string Name { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Identity/Role/UpdateRoleWebModel.cs b/src/DevHive.Web/Models/Identity/Role/UpdateRoleWebModel.cs
deleted file mode 100644
index 3870481..0000000
--- a/src/DevHive.Web/Models/Identity/Role/UpdateRoleWebModel.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-using System.ComponentModel.DataAnnotations;
-using System.Diagnostics.CodeAnalysis;
-
-namespace DevHive.Web.Models.Identity.Role
-{
- public class UpdateRoleWebModel
- {
- [NotNull]
- [Required]
- [MinLength(3)]
- [MaxLength(50)]
- public string Name { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Identity/User/BaseUserWebModel.cs b/src/DevHive.Web/Models/Identity/User/BaseUserWebModel.cs
deleted file mode 100644
index 297e1a5..0000000
--- a/src/DevHive.Web/Models/Identity/User/BaseUserWebModel.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System.ComponentModel.DataAnnotations;
-using System.Diagnostics.CodeAnalysis;
-using DevHive.Web.Attributes;
-
-namespace DevHive.Web.Models.Identity.User
-{
- public class BaseUserWebModel
- {
- [NotNull]
- [Required]
- [MinLength(3)]
- [MaxLength(50)]
- public string UserName { get; set; }
-
- [NotNull]
- [Required]
- [EmailAddress]
- public string Email { get; set; }
-
- [NotNull]
- [Required]
- [MinLength(3)]
- [MaxLength(30)]
- [OnlyLetters(ErrorMessage = "First name can only contain letters!")]
- public string FirstName { get; set; }
-
- [NotNull]
- [Required]
- [MinLength(3)]
- [MaxLength(30)]
- [OnlyLetters(ErrorMessage = "Last name can only contain letters!")]
- public string LastName { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Identity/User/LoginWebModel.cs b/src/DevHive.Web/Models/Identity/User/LoginWebModel.cs
deleted file mode 100644
index ccd806f..0000000
--- a/src/DevHive.Web/Models/Identity/User/LoginWebModel.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System.ComponentModel.DataAnnotations;
-using System.Diagnostics.CodeAnalysis;
-using DevHive.Web.Attributes;
-
-namespace DevHive.Web.Models.Identity.User
-{
- public class LoginWebModel
- {
- [NotNull]
- [Required]
- [MinLength(3)]
- [MaxLength(50)]
- public string UserName { get; set; }
-
- [NotNull]
- [Required]
- [GoodPassword]
- public string Password { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Identity/User/ProfilePictureWebModel.cs b/src/DevHive.Web/Models/Identity/User/ProfilePictureWebModel.cs
deleted file mode 100644
index 9fb1516..0000000
--- a/src/DevHive.Web/Models/Identity/User/ProfilePictureWebModel.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace DevHive.Web.Models.Identity.User
-{
- public class ProfilePictureWebModel
- {
- public string ProfilePictureURL { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Identity/User/RegisterWebModel.cs b/src/DevHive.Web/Models/Identity/User/RegisterWebModel.cs
deleted file mode 100644
index 0fc7ec6..0000000
--- a/src/DevHive.Web/Models/Identity/User/RegisterWebModel.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System.ComponentModel.DataAnnotations;
-using System.Diagnostics.CodeAnalysis;
-using DevHive.Web.Attributes;
-
-namespace DevHive.Web.Models.Identity.User
-{
- public class RegisterWebModel : BaseUserWebModel
- {
- [NotNull]
- [Required]
- [GoodPassword]
- public string Password { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Identity/User/TokenWebModel.cs b/src/DevHive.Web/Models/Identity/User/TokenWebModel.cs
deleted file mode 100644
index 154b64b..0000000
--- a/src/DevHive.Web/Models/Identity/User/TokenWebModel.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace DevHive.Web.Models.Identity.User
-{
- public class TokenWebModel
- {
- public TokenWebModel(string token)
- {
- this.Token = token;
- }
-
- public string Token { get; set; }
- }
-} \ No newline at end of file
diff --git a/src/DevHive.Web/Models/Identity/User/UpdateProfilePictureWebModel.cs b/src/DevHive.Web/Models/Identity/User/UpdateProfilePictureWebModel.cs
deleted file mode 100644
index 6efe968..0000000
--- a/src/DevHive.Web/Models/Identity/User/UpdateProfilePictureWebModel.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using Microsoft.AspNetCore.Http;
-
-namespace DevHive.Web.Models.Identity.User
-{
- public class UpdateProfilePictureWebModel
- {
- public IFormFile Picture { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Identity/User/UpdateUserWebModel.cs b/src/DevHive.Web/Models/Identity/User/UpdateUserWebModel.cs
deleted file mode 100644
index 62901f6..0000000
--- a/src/DevHive.Web/Models/Identity/User/UpdateUserWebModel.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.Diagnostics.CodeAnalysis;
-using DevHive.Web.Attributes;
-using DevHive.Web.Models.Identity.Role;
-using DevHive.Web.Models.Language;
-using DevHive.Web.Models.Technology;
-
-namespace DevHive.Web.Models.Identity.User
-{
- public class UpdateUserWebModel : BaseUserWebModel
- {
- [NotNull]
- [Required]
- [GoodPassword]
- public string Password { get; set; }
-
- [NotNull]
- [Required]
- public HashSet<UsernameWebModel> Friends { get; set; }
-
- [NotNull]
- [Required]
- public HashSet<UpdateRoleWebModel> Roles { get; set; }
-
- [NotNull]
- [Required]
- public HashSet<UpdateLanguageWebModel> Languages { get; set; }
-
- [NotNull]
- [Required]
- public HashSet<UpdateTechnologyWebModel> Technologies { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Identity/User/UserWebModel.cs b/src/DevHive.Web/Models/Identity/User/UserWebModel.cs
deleted file mode 100644
index 7ab8cca..0000000
--- a/src/DevHive.Web/Models/Identity/User/UserWebModel.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.Diagnostics.CodeAnalysis;
-using DevHive.Common.Models.Misc;
-using DevHive.Web.Models.Identity.Role;
-using DevHive.Web.Models.Language;
-using DevHive.Web.Models.Technology;
-
-namespace DevHive.Web.Models.Identity.User
-{
- public class UserWebModel : BaseUserWebModel
- {
- public string ProfilePictureURL { get; set; }
-
- [NotNull]
- [Required]
- public HashSet<RoleWebModel> Roles { get; set; } = new();
-
- [NotNull]
- [Required]
- public HashSet<UsernameWebModel> Friends { get; set; } = new();
-
- [NotNull]
- [Required]
- public HashSet<LanguageWebModel> Languages { get; set; } = new();
-
- [NotNull]
- [Required]
- public HashSet<TechnologyWebModel> Technologies { get; set; } = new();
-
- public List<IdModel> Posts { get; set; } = new();
- }
-}
diff --git a/src/DevHive.Web/Models/Identity/User/UsernameWebModel.cs b/src/DevHive.Web/Models/Identity/User/UsernameWebModel.cs
deleted file mode 100644
index c533bba..0000000
--- a/src/DevHive.Web/Models/Identity/User/UsernameWebModel.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System.ComponentModel.DataAnnotations;
-using System.Diagnostics.CodeAnalysis;
-using DevHive.Web.Attributes;
-
-namespace DevHive.Web.Models.Identity.User
-{
- public class UsernameWebModel
- {
- [NotNull]
- [Required]
- [MinLength(3)]
- [MaxLength(50)]
- public string UserName { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Language/CreateLanguageWebModel.cs b/src/DevHive.Web/Models/Language/CreateLanguageWebModel.cs
deleted file mode 100644
index a739e7f..0000000
--- a/src/DevHive.Web/Models/Language/CreateLanguageWebModel.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System.ComponentModel.DataAnnotations;
-using System.Diagnostics.CodeAnalysis;
-
-namespace DevHive.Web.Models.Language
-{
- public class CreateLanguageWebModel
- {
- [NotNull]
- [Required]
- [MinLength(3)]
- [MaxLength(50)]
- public string Name { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Language/LanguageWebModel.cs b/src/DevHive.Web/Models/Language/LanguageWebModel.cs
deleted file mode 100644
index 7515e70..0000000
--- a/src/DevHive.Web/Models/Language/LanguageWebModel.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-using System.ComponentModel.DataAnnotations;
-using System.Diagnostics.CodeAnalysis;
-
-namespace DevHive.Web.Models.Language
-{
- public class LanguageWebModel
- {
- [NotNull]
- [Required]
- public Guid Id { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Language/ReadLanguageWebModel.cs b/src/DevHive.Web/Models/Language/ReadLanguageWebModel.cs
deleted file mode 100644
index 3d9d5b6..0000000
--- a/src/DevHive.Web/Models/Language/ReadLanguageWebModel.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System;
-
-namespace DevHive.Web.Models.Language
-{
- public class ReadLanguageWebModel
- {
- public Guid Id { get; set; }
-
- public string Name { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Language/UpdateLanguageWebModel.cs b/src/DevHive.Web/Models/Language/UpdateLanguageWebModel.cs
deleted file mode 100644
index 128d534..0000000
--- a/src/DevHive.Web/Models/Language/UpdateLanguageWebModel.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System.ComponentModel.DataAnnotations;
-using System.Diagnostics.CodeAnalysis;
-
-namespace DevHive.Web.Models.Language
-{
- public class UpdateLanguageWebModel
- {
- [NotNull]
- [Required]
- [MinLength(3)]
- [MaxLength(50)]
- public string Name { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Post/CreatePostWebModel.cs b/src/DevHive.Web/Models/Post/CreatePostWebModel.cs
deleted file mode 100644
index 237259d..0000000
--- a/src/DevHive.Web/Models/Post/CreatePostWebModel.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.Diagnostics.CodeAnalysis;
-using Microsoft.AspNetCore.Http;
-
-namespace DevHive.Web.Models.Post
-{
- public class CreatePostWebModel
- {
- [NotNull]
- [Required]
- public string Message { get; set; }
-
- public List<IFormFile> Files { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Post/Rating/RatePostWebModel.cs b/src/DevHive.Web/Models/Post/Rating/RatePostWebModel.cs
deleted file mode 100644
index 5f0e58f..0000000
--- a/src/DevHive.Web/Models/Post/Rating/RatePostWebModel.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System;
-
-namespace DevHive.Web.Models.Post.Rating
-{
- public class RatePostWebModel
- {
- public Guid PostId { get; set; }
-
- public bool Liked { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Post/Rating/ReadPostRatingWebModel.cs b/src/DevHive.Web/Models/Post/Rating/ReadPostRatingWebModel.cs
deleted file mode 100644
index a551fb8..0000000
--- a/src/DevHive.Web/Models/Post/Rating/ReadPostRatingWebModel.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-
-namespace DevHive.Web.Models.Post.Rating
-{
- public class ReadPostRatingWebModel
- {
- public Guid Id { get; set; }
-
- public Guid PostId { get; set; }
-
- public int Likes { get; set; }
-
- public int Dislikes { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Post/ReadPostWebModel.cs b/src/DevHive.Web/Models/Post/ReadPostWebModel.cs
deleted file mode 100644
index 8238f47..0000000
--- a/src/DevHive.Web/Models/Post/ReadPostWebModel.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System;
-using System.Collections.Generic;
-using DevHive.Common.Models.Misc;
-
-namespace DevHive.Web.Models.Post
-{
- public class ReadPostWebModel
- {
- public Guid PostId { get; set; }
-
- public string CreatorFirstName { get; set; }
-
- public string CreatorLastName { get; set; }
-
- public string CreatorUsername { get; set; }
-
- public string Message { get; set; }
-
- public DateTime TimeCreated { get; set; }
-
- public List<IdModel> Comments { get; set; }
-
- public List<string> FileUrls { get; set; }
- // public List<FileContentResult> Files { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Post/UpdatePostWebModel.cs b/src/DevHive.Web/Models/Post/UpdatePostWebModel.cs
deleted file mode 100644
index a0c9b61..0000000
--- a/src/DevHive.Web/Models/Post/UpdatePostWebModel.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.Diagnostics.CodeAnalysis;
-using Microsoft.AspNetCore.Http;
-
-namespace DevHive.Web.Models.Post
-{
- public class UpdatePostWebModel
- {
- [Required]
- [NotNull]
- public Guid PostId { get; set; }
-
- [NotNull]
- [Required]
- public string NewMessage { get; set; }
-
- public List<IFormFile> Files { get; set; } = new();
- }
-}
diff --git a/src/DevHive.Web/Models/Technology/CreateTechnologyWebModel.cs b/src/DevHive.Web/Models/Technology/CreateTechnologyWebModel.cs
deleted file mode 100644
index ec9ec15..0000000
--- a/src/DevHive.Web/Models/Technology/CreateTechnologyWebModel.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System.ComponentModel.DataAnnotations;
-using System.Diagnostics.CodeAnalysis;
-
-namespace DevHive.Web.Models.Technology
-{
- public class CreateTechnologyWebModel
- {
- [NotNull]
- [Required]
- [MinLength(3)]
- [MaxLength(50)]
- public string Name { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Technology/ReadTechnologyWebModel.cs b/src/DevHive.Web/Models/Technology/ReadTechnologyWebModel.cs
deleted file mode 100644
index 94542d7..0000000
--- a/src/DevHive.Web/Models/Technology/ReadTechnologyWebModel.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System;
-
-namespace DevHive.Web.Models.Technology
-{
- public class ReadTechnologyWebModel
- {
- public Guid Id { get; set; }
-
- public string Name { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Technology/TechnologyWebModel.cs b/src/DevHive.Web/Models/Technology/TechnologyWebModel.cs
deleted file mode 100644
index 6e8273b..0000000
--- a/src/DevHive.Web/Models/Technology/TechnologyWebModel.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-using System.ComponentModel.DataAnnotations;
-using System.Diagnostics.CodeAnalysis;
-
-namespace DevHive.Web.Models.Technology
-{
- public class TechnologyWebModel
- {
- [NotNull]
- [Required]
- public Guid Id { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Models/Technology/UpdateTechnologyWebModel.cs b/src/DevHive.Web/Models/Technology/UpdateTechnologyWebModel.cs
deleted file mode 100644
index 3e9fe2a..0000000
--- a/src/DevHive.Web/Models/Technology/UpdateTechnologyWebModel.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-using System.ComponentModel.DataAnnotations;
-using System.Diagnostics.CodeAnalysis;
-
-namespace DevHive.Web.Models.Technology
-{
- public class UpdateTechnologyWebModel
- {
- [NotNull]
- [Required]
- [MinLength(3)]
- [MaxLength(50)]
- public string Name { get; set; }
- }
-}
diff --git a/src/DevHive.Web/Program.cs b/src/DevHive.Web/Program.cs
deleted file mode 100644
index 6982da9..0000000
--- a/src/DevHive.Web/Program.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.Hosting;
-
-namespace DevHive.Web
-{
- public class Program
- {
- private const int HTTP_PORT = 5000;
-
- public static void Main(string[] args)
- {
- CreateHostBuilder(args).Build().Run();
- }
-
- public static IHostBuilder CreateHostBuilder(string[] args) =>
- Host.CreateDefaultBuilder(args)
- .ConfigureWebHostDefaults(webBuilder =>
- {
- webBuilder.ConfigureKestrel(opt => opt.ListenLocalhost(HTTP_PORT));
- webBuilder.UseStartup<Startup>();
- });
- }
-}
diff --git a/src/DevHive.Web/Properties/launchSettings.json b/src/DevHive.Web/Properties/launchSettings.json
deleted file mode 100644
index 2b65d0b..0000000
--- a/src/DevHive.Web/Properties/launchSettings.json
+++ /dev/null
@@ -1,36 +0,0 @@
-{
- "$schema": "http://json.schemastore.org/launchsettings.json",
- "iisSettings": {
- "windowsAuthentication": false,
- "anonymousAuthentication": true,
- "iisExpress": {
- "applicationUrl": "http://localhost:1955",
- "sslPort": 44326
- }
- },
- "profiles": {
- "IIS Express": {
- "commandName": "IISExpress",
- "launchBrowser": false,
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
- },
- "DevHive.Web": {
- "commandName": "Project",
- "dotnetRunMessages": "true",
- "launchBrowser": false,
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
- },
- "DevHive.Web Production": {
- "commandName": "Project",
- "dotnetRunMessages": "true",
- "launchBrowser": false,
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Production"
- }
- }
- }
-}
diff --git a/src/DevHive.Web/Startup.cs b/src/DevHive.Web/Startup.cs
deleted file mode 100644
index 46521cf..0000000
--- a/src/DevHive.Web/Startup.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-using Microsoft.AspNetCore.Builder;
-using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Hosting;
-using DevHive.Web.Configurations.Extensions;
-using Newtonsoft.Json;
-
-namespace DevHive.Web
-{
- public class Startup
- {
- public Startup(IConfiguration configuration)
- {
- Configuration = configuration;
- }
-
- public IConfiguration Configuration { get; }
-
- // This method gets called by the runtime. Use this method to add services to the container.
- public void ConfigureServices(IServiceCollection services)
- {
- services.AddCors();
-
- services.AddControllers()
- .AddNewtonsoftJson(x =>
- {
- x.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
- });
-
- services.DatabaseConfiguration(Configuration);
- services.SwaggerConfiguration();
- services.JWTConfiguration(Configuration);
- services.AutoMapperConfiguration();
- services.DependencyInjectionConfiguration(this.Configuration);
- }
-
- // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
- public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
- {
- app.UseCors(x => x
- .AllowAnyMethod()
- .AllowAnyHeader()
- .SetIsOriginAllowed(origin => true) // allow any origin
- .AllowCredentials()); // allow credentials
-
- if (env.IsDevelopment())
- {
- app.UseDeveloperExceptionPage();
- app.UseSwaggerConfiguration();
- }
- else
- {
- app.UseHsts();
- app.UseExceptionHandlerMiddlewareConfiguration();
- }
-
- app.UseDatabaseConfiguration();
- app.UseAutoMapperConfiguration();
-
- app.UseEndpoints(endpoints =>
- {
- endpoints.MapControllerRoute(
- name: "default",
- pattern: "api/{controller}/{action}"
- );
- });
- }
- }
-}
diff --git a/src/DevHive.Web/appsettings.json b/src/DevHive.Web/appsettings.json
deleted file mode 100644
index bcdcae7..0000000
--- a/src/DevHive.Web/appsettings.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "AppSettings": {
- "Secret": "gXfQlU6qpDleFWyimscjYcT3tgFsQg3yoFjcvSLxG56n1Vu2yptdIUq254wlJWjm"
- },
- "ConnectionStrings": {
- "DEV": "Server=localhost;Port=5432;Database=API;User Id=postgres;Password=;"
- },
- "Cloud": {
- "cloudName": "devhive",
- "apiKey": "488664116365813",
- "apiSecret": ""
- },
- "Logging": {
- "LogLevel": {
- "Default": "Information",
- "Microsoft": "Warning",
- "Microsoft.Hosting.Lifetime": "Information"
- }
- }
-}