diff --git a/src/Services/e-sender/O2NextGen.ESender.Api.sln b/src/Services/e-sender/O2NextGen.ESender.Api.sln new file mode 100644 index 00000000..767412b9 --- /dev/null +++ b/src/Services/e-sender/O2NextGen.ESender.Api.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 25.0.1700.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "O2NextGen.ESender.Api", "O2NextGen.ESender.Api\O2NextGen.ESender.Api.csproj", "{89FADD48-B8C5-4923-AA5C-D9FFF0B21E87}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {89FADD48-B8C5-4923-AA5C-D9FFF0B21E87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {89FADD48-B8C5-4923-AA5C-D9FFF0B21E87}.Debug|Any CPU.Build.0 = Debug|Any CPU + {89FADD48-B8C5-4923-AA5C-D9FFF0B21E87}.Release|Any CPU.ActiveCfg = Release|Any CPU + {89FADD48-B8C5-4923-AA5C-D9FFF0B21E87}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B0B1A6AC-DCC6-4AAB-B22C-8767ECCB3CF2} + EndGlobalSection +EndGlobal diff --git a/src/Services/e-sender/O2NextGen.ESender.Api/Controllers/EmailSenderController.cs b/src/Services/e-sender/O2NextGen.ESender.Api/Controllers/EmailSenderController.cs new file mode 100644 index 00000000..0c92b6cd --- /dev/null +++ b/src/Services/e-sender/O2NextGen.ESender.Api/Controllers/EmailSenderController.cs @@ -0,0 +1,66 @@ +using System.Collections.Generic; +using System.Linq; +using Microsoft.AspNetCore.Mvc; +using O2NextGen.ESender.Api.Models; + +namespace O2NextGen.ESender.Api.Controllers +{ + [Route("emailsender")] + public class EmailSenderController : Controller + { + private static long _currentCertificateId = 1; + + private static List _mailLetters = new List() + { + new MailViewModel() {Id = 1, From ="from@eexample.com",To = "example@eexample.com", Subject="theme", Body="

last

"}, + new MailViewModel() {Id = 2, From ="from@eexample.com",To = "example@eexample.com", Subject="theme", Body="

last

"}, + }; + + [HttpGet] + [Route("")] + public IActionResult Index() => View(_mailLetters); + + [HttpGet] + [Route("{id}")] + public IActionResult Detail(long id) + { + var certificate = _mailLetters.SingleOrDefault(_ => _.Id == id); + if (certificate == null) + return NotFound(); + return View(certificate); + } + + [HttpPost] + [Route("id")] + [ValidateAntiForgeryToken] + public IActionResult Edit(long id, MailViewModel model) + { + var certificate = _mailLetters.SingleOrDefault(_ => _.Id == id); + if (certificate == null) + return NotFound(); + certificate.From = model.From; + certificate.To = model.To; + certificate.Subject = model.Subject; + certificate.Body = model.Body; + + return RedirectToAction("Index"); + } + + [HttpGet] + [Route("create")] + public IActionResult Create() + { + return View(); + } + + [HttpPost] + [Route("")] + public IActionResult CreateReally(MailViewModel model) + { + model.Id = _currentCertificateId++; + _mailLetters.Add(model); + return RedirectToAction("Index"); + } + } +} + diff --git a/src/Services/e-sender/O2NextGen.ESender.Api/Controllers/ValuesController.cs b/src/Services/e-sender/O2NextGen.ESender.Api/Controllers/ValuesController.cs new file mode 100644 index 00000000..4272947e --- /dev/null +++ b/src/Services/e-sender/O2NextGen.ESender.Api/Controllers/ValuesController.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc; + +namespace O2NextGen.ESender.Api.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class ValuesController : ControllerBase + { + // GET api/values + [HttpGet] + public ActionResult> Get() + { + return new string[] { "value1", "value2" }; + } + + // GET api/values/5 + [HttpGet("{id}")] + public ActionResult Get(int id) + { + return "value"; + } + + // POST api/values + [HttpPost] + public void Post([FromBody] string value) + { + } + + // PUT api/values/5 + [HttpPut("{id}")] + public void Put(int id, [FromBody] string value) + { + } + + // DELETE api/values/5 + [HttpDelete("{id}")] + public void Delete(int id) + { + } + } +} + diff --git a/src/Services/e-sender/O2NextGen.ESender.Api/Models/MailViewModel.cs b/src/Services/e-sender/O2NextGen.ESender.Api/Models/MailViewModel.cs new file mode 100644 index 00000000..105c3306 --- /dev/null +++ b/src/Services/e-sender/O2NextGen.ESender.Api/Models/MailViewModel.cs @@ -0,0 +1,13 @@ +using System; +namespace O2NextGen.ESender.Api.Models +{ + public class MailViewModel + { + public long Id { get; set; } + public string From { get; set; } + public string To { get; set; } + public string Body { get; set; } + public string Subject { get; set; } + } +} + diff --git a/src/Services/e-sender/O2NextGen.ESender.Api/O2NextGen.ESender.Api.csproj b/src/Services/e-sender/O2NextGen.ESender.Api/O2NextGen.ESender.Api.csproj new file mode 100644 index 00000000..047a8a83 --- /dev/null +++ b/src/Services/e-sender/O2NextGen.ESender.Api/O2NextGen.ESender.Api.csproj @@ -0,0 +1,24 @@ + + + + netcoreapp2.1 + + + + + + + + + + + + + + + + + + + + diff --git a/src/Services/e-sender/O2NextGen.ESender.Api/Program.cs b/src/Services/e-sender/O2NextGen.ESender.Api/Program.cs new file mode 100644 index 00000000..0402e0fe --- /dev/null +++ b/src/Services/e-sender/O2NextGen.ESender.Api/Program.cs @@ -0,0 +1,18 @@ +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; + +namespace O2NextGen.ESender.Api +{ + public class Program + { + public static void Main(string[] args) + { + CreateWebHostBuilder(args).Build().Run(); + } + + public static IWebHostBuilder CreateWebHostBuilder(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup(); + } +} + diff --git a/src/Services/e-sender/O2NextGen.ESender.Api/Properties/launchSettings.json b/src/Services/e-sender/O2NextGen.ESender.Api/Properties/launchSettings.json new file mode 100644 index 00000000..8db78e4b --- /dev/null +++ b/src/Services/e-sender/O2NextGen.ESender.Api/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:26083", + "sslPort": 44314 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "api/values", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "O2NextGen.ESender.Api": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "api/values", + "applicationUrl": "https://localhost:5001;http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} + diff --git a/src/Services/e-sender/O2NextGen.ESender.Api/Startup.cs b/src/Services/e-sender/O2NextGen.ESender.Api/Startup.cs new file mode 100644 index 00000000..805f5d5a --- /dev/null +++ b/src/Services/e-sender/O2NextGen.ESender.Api/Startup.cs @@ -0,0 +1,39 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; + +namespace O2NextGen.ESender.Api +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + public void ConfigureServices(IServiceCollection services) + { + services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + } + + public void Configure(IApplicationBuilder app, IHostingEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + else + { + app.UseHsts(); + } + + app.UseHttpsRedirection(); + app.UseMvc(); + } + } +} + diff --git a/src/Services/e-sender/O2NextGen.ESender.Api/Views/EmailSender/Create.cshtml b/src/Services/e-sender/O2NextGen.ESender.Api/Views/EmailSender/Create.cshtml new file mode 100644 index 00000000..1c406818 --- /dev/null +++ b/src/Services/e-sender/O2NextGen.ESender.Api/Views/EmailSender/Create.cshtml @@ -0,0 +1,13 @@ +@model MailViewModel + +
+ + + + + + + + + +
\ No newline at end of file diff --git a/src/Services/e-sender/O2NextGen.ESender.Api/Views/EmailSender/Detail.cshtml b/src/Services/e-sender/O2NextGen.ESender.Api/Views/EmailSender/Detail.cshtml new file mode 100644 index 00000000..084d6d08 --- /dev/null +++ b/src/Services/e-sender/O2NextGen.ESender.Api/Views/EmailSender/Detail.cshtml @@ -0,0 +1,14 @@ + +@model MailViewModel + +
+ + + + + + + + + +
diff --git a/src/Services/e-sender/O2NextGen.ESender.Api/Views/EmailSender/Index.cshtml b/src/Services/e-sender/O2NextGen.ESender.Api/Views/EmailSender/Index.cshtml new file mode 100644 index 00000000..017c8792 --- /dev/null +++ b/src/Services/e-sender/O2NextGen.ESender.Api/Views/EmailSender/Index.cshtml @@ -0,0 +1,10 @@ +@model IEnumerable + +@foreach (var certificate in Model) +{ +
  • + @certificate.Id @certificate.From @certificate.To @certificate.Subject @certificate.Body | Edit +
  • +} + +Create \ No newline at end of file diff --git a/src/Services/e-sender/O2NextGen.ESender.Api/Views/_ViewImports.cshtml b/src/Services/e-sender/O2NextGen.ESender.Api/Views/_ViewImports.cshtml new file mode 100644 index 00000000..6f948c43 --- /dev/null +++ b/src/Services/e-sender/O2NextGen.ESender.Api/Views/_ViewImports.cshtml @@ -0,0 +1,2 @@ +@using O2NextGen.ESender.Api.Models +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers \ No newline at end of file diff --git a/src/Services/e-sender/O2NextGen.ESender.Api/appsettings.Development.json b/src/Services/e-sender/O2NextGen.ESender.Api/appsettings.Development.json new file mode 100644 index 00000000..11a51145 --- /dev/null +++ b/src/Services/e-sender/O2NextGen.ESender.Api/appsettings.Development.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + } +} + diff --git a/src/Services/e-sender/O2NextGen.ESender.Api/appsettings.json b/src/Services/e-sender/O2NextGen.ESender.Api/appsettings.json new file mode 100644 index 00000000..013120d6 --- /dev/null +++ b/src/Services/e-sender/O2NextGen.ESender.Api/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning" + } + }, + "AllowedHosts": "*" +} +