Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/Services/e-sender/O2NextGen.ESender.Api.sln
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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<MailViewModel> _mailLetters = new List<MailViewModel>()
{
new MailViewModel() {Id = 1, From ="from@eexample.com",To = "example@eexample.com", Subject="theme", Body="<h1>last</h1>"},
new MailViewModel() {Id = 2, From ="from@eexample.com",To = "example@eexample.com", Subject="theme", Body="<h1>last</h1>"},
};

[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");
}
}
}

Original file line number Diff line number Diff line change
@@ -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<IEnumerable<string>> Get()
{
return new string[] { "value1", "value2" };
}

// GET api/values/5
[HttpGet("{id}")]
public ActionResult<string> 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)
{
}
}
}

Original file line number Diff line number Diff line change
@@ -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; }
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Folder Include="wwwroot\" />
<Folder Include="Models\" />
<Folder Include="Views\" />
<Folder Include="Views\EmailSender\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<None Remove="Models\" />
<None Remove="Views\" />
<None Remove="Views\EmailSender\" />
</ItemGroup>
</Project>
18 changes: 18 additions & 0 deletions src/Services/e-sender/O2NextGen.ESender.Api/Program.cs
Original file line number Diff line number Diff line change
@@ -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<Startup>();
}
}

Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}

39 changes: 39 additions & 0 deletions src/Services/e-sender/O2NextGen.ESender.Api/Startup.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@model MailViewModel

<form asp-controller="EmailSender" asp-action="CreateReally" method="post">
<label asp-for="From">From</label>
<input asp-for="From" />
<label asp-for="To">To</label>
<input asp-for="To" />
<label asp-for="Subject">Subject</label>
<input asp-for="Subject" />
<label asp-for="Body">Body</label>
<input asp-for="Body" />
<button type="submit">Save</button>
</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

@model MailViewModel

<form asp-controller="EmailSender" asp-action="Edit" asp-route-id="@Model.Id">
<label asp-for="From">From</label>
<input asp-for="From" />
<label asp-for="To">To</label>
<input asp-for="To" />
<label asp-for="Subject">Subject</label>
<input asp-for="Subject" />
<label asp-for="Body">Body</label>
<input asp-for="Body" />
<button type="submit">Save</button>
</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@model IEnumerable<MailViewModel>

@foreach (var certificate in Model)
{
<li>
@certificate.Id @certificate.From @certificate.To @certificate.Subject @certificate.Body | <a asp-controller="EmailSender" asp-action="Detail" asp-route-id="@certificate.Id">Edit</a>
</li>
}

<a asp-controller="EmailSender" asp-action="Create">Create</a>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@using O2NextGen.ESender.Api.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}

9 changes: 9 additions & 0 deletions src/Services/e-sender/O2NextGen.ESender.Api/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*"
}