From b38d6693476917972345397298b534af2b8b8f78 Mon Sep 17 00:00:00 2001 From: transtrike Date: Fri, 29 Jan 2021 20:39:07 +0200 Subject: File Upload implemented; Post Layers adapted to File Uploading --- .../Configurations/Extensions/ConfigureDependencyInjection.cs | 8 +++++++- src/DevHive.Web/Models/Post/Post/CreatePostWebModel.cs | 4 +++- src/DevHive.Web/Models/Post/Post/ReadPostWebModel.cs | 3 ++- src/DevHive.Web/Models/Post/Post/UpdatePostWebModel.cs | 4 ++++ src/DevHive.Web/Startup.cs | 2 +- src/DevHive.Web/appsettings.json | 7 ++++++- 6 files changed, 23 insertions(+), 5 deletions(-) (limited to 'src/DevHive.Web') diff --git a/src/DevHive.Web/Configurations/Extensions/ConfigureDependencyInjection.cs b/src/DevHive.Web/Configurations/Extensions/ConfigureDependencyInjection.cs index d7c859e..fe2c788 100644 --- a/src/DevHive.Web/Configurations/Extensions/ConfigureDependencyInjection.cs +++ b/src/DevHive.Web/Configurations/Extensions/ConfigureDependencyInjection.cs @@ -3,13 +3,14 @@ using DevHive.Data.Models; 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) + public static void DependencyInjectionConfiguration(this IServiceCollection services, IConfiguration configuration) { services.AddTransient(); services.AddTransient(); @@ -25,6 +26,11 @@ namespace DevHive.Web.Configurations.Extensions services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(options => + new CloudinaryService( + cloudName: configuration.GetSection("Cloud").GetSection("cloudName").Value, + apiKey: configuration.GetSection("Cloud").GetSection("apiKey").Value, + apiSecret: configuration.GetSection("Cloud").GetSection("apiSecret").Value)); } } } diff --git a/src/DevHive.Web/Models/Post/Post/CreatePostWebModel.cs b/src/DevHive.Web/Models/Post/Post/CreatePostWebModel.cs index b7b4cf4..e35a813 100644 --- a/src/DevHive.Web/Models/Post/Post/CreatePostWebModel.cs +++ b/src/DevHive.Web/Models/Post/Post/CreatePostWebModel.cs @@ -1,6 +1,8 @@ using System; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Diagnostics.CodeAnalysis; +using Microsoft.AspNetCore.Http; namespace DevHive.Web.Models.Post.Post { @@ -10,6 +12,6 @@ namespace DevHive.Web.Models.Post.Post [Required] public string Message { get; set; } - // public List Files { get; set; } + public List Files { get; set; } } } diff --git a/src/DevHive.Web/Models/Post/Post/ReadPostWebModel.cs b/src/DevHive.Web/Models/Post/Post/ReadPostWebModel.cs index 04c6275..5d4da31 100644 --- a/src/DevHive.Web/Models/Post/Post/ReadPostWebModel.cs +++ b/src/DevHive.Web/Models/Post/Post/ReadPostWebModel.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using DevHive.Web.Models.Post.Comment; +using Microsoft.AspNetCore.Http; namespace DevHive.Web.Models.Post.Post { @@ -20,6 +21,6 @@ namespace DevHive.Web.Models.Post.Post public List Comments { get; set; } - //public Files[] Files { get; set; } + public List Files { get; set; } } } diff --git a/src/DevHive.Web/Models/Post/Post/UpdatePostWebModel.cs b/src/DevHive.Web/Models/Post/Post/UpdatePostWebModel.cs index 685f08b..ac84d2c 100644 --- a/src/DevHive.Web/Models/Post/Post/UpdatePostWebModel.cs +++ b/src/DevHive.Web/Models/Post/Post/UpdatePostWebModel.cs @@ -1,6 +1,8 @@ using System; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Diagnostics.CodeAnalysis; +using Microsoft.AspNetCore.Http; namespace DevHive.Web.Models.Post.Post { @@ -13,5 +15,7 @@ namespace DevHive.Web.Models.Post.Post [NotNull] [Required] public string NewMessage { get; set; } + + public List Files { get; set; } = new(); } } diff --git a/src/DevHive.Web/Startup.cs b/src/DevHive.Web/Startup.cs index 92d4359..dd7e852 100644 --- a/src/DevHive.Web/Startup.cs +++ b/src/DevHive.Web/Startup.cs @@ -32,7 +32,7 @@ namespace DevHive.Web services.SwaggerConfiguration(); services.JWTConfiguration(Configuration); services.AutoMapperConfiguration(); - services.DependencyInjectionConfiguration(); + services.DependencyInjectionConfiguration(this.Configuration); services.ExceptionHandlerMiddlewareConfiguration(); } diff --git a/src/DevHive.Web/appsettings.json b/src/DevHive.Web/appsettings.json index 83932a7..bcdcae7 100644 --- a/src/DevHive.Web/appsettings.json +++ b/src/DevHive.Web/appsettings.json @@ -4,7 +4,12 @@ }, "ConnectionStrings": { "DEV": "Server=localhost;Port=5432;Database=API;User Id=postgres;Password=;" - }, + }, + "Cloud": { + "cloudName": "devhive", + "apiKey": "488664116365813", + "apiSecret": "" + }, "Logging": { "LogLevel": { "Default": "Information", -- cgit v1.2.3