From e5726c6b5ae02cc58102b0c3a0e33f22f2e38831 Mon Sep 17 00:00:00 2001 From: Denis Nutiu Date: Fri, 28 May 2021 23:52:56 +0300 Subject: [PATCH] Initial commit --- .gitignore | 347 ++++++++++++++++++ Retroactiune.Tests/Retroactiune.Tests.csproj | 15 + .../Retroactiune.WebAPI/UnitTest1.cs | 18 + .../Admin/RetroactiuneController.cs | 49 +++ .../Controllers/WeatherForecastController.cs | 41 +++ Retroactiune.WebAPI/Models/BasicResponse.cs | 7 + Retroactiune.WebAPI/Models/WeatherForecast.cs | 15 + Retroactiune.WebAPI/Program.cs | 19 + .../Properties/launchSettings.json | 30 ++ .../Retroactiune.WebAPI.csproj | 13 + Retroactiune.WebAPI/Startup.cs | 52 +++ .../appsettings.Development.json | 9 + Retroactiune.WebAPI/appsettings.json | 10 + Retroactiune.sln | 22 ++ 14 files changed, 647 insertions(+) create mode 100644 .gitignore create mode 100644 Retroactiune.Tests/Retroactiune.Tests.csproj create mode 100644 Retroactiune.Tests/Retroactiune.WebAPI/UnitTest1.cs create mode 100644 Retroactiune.WebAPI/Controllers/Admin/RetroactiuneController.cs create mode 100644 Retroactiune.WebAPI/Controllers/WeatherForecastController.cs create mode 100644 Retroactiune.WebAPI/Models/BasicResponse.cs create mode 100644 Retroactiune.WebAPI/Models/WeatherForecast.cs create mode 100644 Retroactiune.WebAPI/Program.cs create mode 100644 Retroactiune.WebAPI/Properties/launchSettings.json create mode 100644 Retroactiune.WebAPI/Retroactiune.WebAPI.csproj create mode 100644 Retroactiune.WebAPI/Startup.cs create mode 100644 Retroactiune.WebAPI/appsettings.Development.json create mode 100644 Retroactiune.WebAPI/appsettings.json create mode 100644 Retroactiune.sln diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f23edf4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,347 @@ + +# Created by https://www.toptal.com/developers/gitignore/api/rider,aspnetcore +# Edit at https://www.toptal.com/developers/gitignore?templates=rider,aspnetcore + +### ASPNETCore ### +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/ + +### Rider ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +# End of https://www.toptal.com/developers/gitignore/api/rider,aspnetcore \ No newline at end of file diff --git a/Retroactiune.Tests/Retroactiune.Tests.csproj b/Retroactiune.Tests/Retroactiune.Tests.csproj new file mode 100644 index 0000000..954cca7 --- /dev/null +++ b/Retroactiune.Tests/Retroactiune.Tests.csproj @@ -0,0 +1,15 @@ + + + + netcoreapp3.1 + + false + + + + + + + + + diff --git a/Retroactiune.Tests/Retroactiune.WebAPI/UnitTest1.cs b/Retroactiune.Tests/Retroactiune.WebAPI/UnitTest1.cs new file mode 100644 index 0000000..25dbee6 --- /dev/null +++ b/Retroactiune.Tests/Retroactiune.WebAPI/UnitTest1.cs @@ -0,0 +1,18 @@ +using NUnit.Framework; + +namespace Retroactiune.Tests +{ + public class Tests + { + [SetUp] + public void Setup() + { + } + + [Test] + public void Test1() + { + Assert.Pass(); + } + } +} \ No newline at end of file diff --git a/Retroactiune.WebAPI/Controllers/Admin/RetroactiuneController.cs b/Retroactiune.WebAPI/Controllers/Admin/RetroactiuneController.cs new file mode 100644 index 0000000..63e7390 --- /dev/null +++ b/Retroactiune.WebAPI/Controllers/Admin/RetroactiuneController.cs @@ -0,0 +1,49 @@ +using System.Collections.Generic; +using System.Linq; +using Microsoft.AspNetCore.Mvc; +using Retroactiune.Models; + +namespace Retroactiune.Controllers.Admin +{ + [ApiController] + [Route("api/v1/[controller]")] + public class RetroActiune : ControllerBase + { + + [HttpDelete("{id}")] + public NoContentResult Delete(long id) + { + return NoContent(); + } + + + [HttpPost] + public BasicResponse Post() + { + return new BasicResponse() + { + Message = "post retroactiune" + }; + } + + [HttpGet("{id}")] + public BasicResponse Get(long id) + { + return new BasicResponse() + { + Message = "hwlo" + }; + } + + [HttpGet] + public IEnumerable List() + { + return Enumerable.Range(1, 5).Select(i => + new BasicResponse() + { + Message = "hwlo" + } + ); + } + } +} \ No newline at end of file diff --git a/Retroactiune.WebAPI/Controllers/WeatherForecastController.cs b/Retroactiune.WebAPI/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..f42765a --- /dev/null +++ b/Retroactiune.WebAPI/Controllers/WeatherForecastController.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Retroactiune.Models; + +namespace Retroactiune.Controllers +{ + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet] + public IEnumerable Get() + { + var rng = new Random(); + _logger.LogInformation("endpoint hit"); + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateTime.Now.AddDays(index), + TemperatureC = rng.Next(-20, 55), + Summary = Summaries[rng.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} \ No newline at end of file diff --git a/Retroactiune.WebAPI/Models/BasicResponse.cs b/Retroactiune.WebAPI/Models/BasicResponse.cs new file mode 100644 index 0000000..116375a --- /dev/null +++ b/Retroactiune.WebAPI/Models/BasicResponse.cs @@ -0,0 +1,7 @@ +namespace Retroactiune.Models +{ + public class BasicResponse + { + public string Message { get; set; } + } +} \ No newline at end of file diff --git a/Retroactiune.WebAPI/Models/WeatherForecast.cs b/Retroactiune.WebAPI/Models/WeatherForecast.cs new file mode 100644 index 0000000..950dc7d --- /dev/null +++ b/Retroactiune.WebAPI/Models/WeatherForecast.cs @@ -0,0 +1,15 @@ +using System; + +namespace Retroactiune.Models +{ + public class WeatherForecast + { + public DateTime Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int) (TemperatureC / 0.5556); + + public string Summary { get; set; } + } +} \ No newline at end of file diff --git a/Retroactiune.WebAPI/Program.cs b/Retroactiune.WebAPI/Program.cs new file mode 100644 index 0000000..106ceab --- /dev/null +++ b/Retroactiune.WebAPI/Program.cs @@ -0,0 +1,19 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Console; + +namespace Retroactiune +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); }); + } +} \ No newline at end of file diff --git a/Retroactiune.WebAPI/Properties/launchSettings.json b/Retroactiune.WebAPI/Properties/launchSettings.json new file mode 100644 index 0000000..db82e76 --- /dev/null +++ b/Retroactiune.WebAPI/Properties/launchSettings.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:5857", + "sslPort": 44307 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Retroactiune": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "", + "applicationUrl": "https://localhost:5001;http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Retroactiune.WebAPI/Retroactiune.WebAPI.csproj b/Retroactiune.WebAPI/Retroactiune.WebAPI.csproj new file mode 100644 index 0000000..a8f9e54 --- /dev/null +++ b/Retroactiune.WebAPI/Retroactiune.WebAPI.csproj @@ -0,0 +1,13 @@ + + + + netcoreapp3.1 + Retroactiune + + + + + + + + diff --git a/Retroactiune.WebAPI/Startup.cs b/Retroactiune.WebAPI/Startup.cs new file mode 100644 index 0000000..9dde286 --- /dev/null +++ b/Retroactiune.WebAPI/Startup.cs @@ -0,0 +1,52 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace Retroactiune +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + private 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.AddControllers(); + services.AddSwaggerGen(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger logger) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseSwagger(); + app.UseSwaggerUI(c => + { + c.SwaggerEndpoint("/swagger/v1/swagger.json", "Retroactiune API"); + c.RoutePrefix = ""; + }); + + app.UseHttpsRedirection(); + + app.UseRouting(); + + app.UseAuthorization(); + + app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); + + logger.LogInformation("Running"); + } + } +} \ No newline at end of file diff --git a/Retroactiune.WebAPI/appsettings.Development.json b/Retroactiune.WebAPI/appsettings.Development.json new file mode 100644 index 0000000..8983e0f --- /dev/null +++ b/Retroactiune.WebAPI/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/Retroactiune.WebAPI/appsettings.json b/Retroactiune.WebAPI/appsettings.json new file mode 100644 index 0000000..d9d9a9b --- /dev/null +++ b/Retroactiune.WebAPI/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +} diff --git a/Retroactiune.sln b/Retroactiune.sln new file mode 100644 index 0000000..f61628e --- /dev/null +++ b/Retroactiune.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Retroactiune.WebAPI", "Retroactiune.WebAPI\Retroactiune.WebAPI.csproj", "{A40A0DBB-42D4-4619-9B80-120517561DF1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Retroactiune.Tests", "Retroactiune.Tests\Retroactiune.Tests.csproj", "{08AE3560-A324-4843-90DB-17DFC54600B5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A40A0DBB-42D4-4619-9B80-120517561DF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A40A0DBB-42D4-4619-9B80-120517561DF1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A40A0DBB-42D4-4619-9B80-120517561DF1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A40A0DBB-42D4-4619-9B80-120517561DF1}.Release|Any CPU.Build.0 = Release|Any CPU + {08AE3560-A324-4843-90DB-17DFC54600B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {08AE3560-A324-4843-90DB-17DFC54600B5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {08AE3560-A324-4843-90DB-17DFC54600B5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {08AE3560-A324-4843-90DB-17DFC54600B5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal