Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added .vs/MorseCode/v15/.suo
Binary file not shown.
Binary file added .vs/MorseCode/v15/sqlite3/storage.ide
Binary file not shown.
997 changes: 997 additions & 0 deletions .vs/config/applicationhost.config

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions MorseCode.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 15
VisualStudioVersion = 15.0.26730.16
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MorseCode", "MorseCode\MorseCode.csproj", "{7C07D2F6-278A-454E-A6A6-9436EF3731D9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7C07D2F6-278A-454E-A6A6-9436EF3731D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C07D2F6-278A-454E-A6A6-9436EF3731D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C07D2F6-278A-454E-A6A6-9436EF3731D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7C07D2F6-278A-454E-A6A6-9436EF3731D9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {ED2D793A-E6B9-4723-982A-76D2136EFF66}
EndGlobalSection
EndGlobal
3 changes: 3 additions & 0 deletions MorseCode/.bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "wwwroot/lib"
}
35 changes: 35 additions & 0 deletions MorseCode/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace MorseCode.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
}

public IActionResult About()
{
ViewData["Message"] = "Your application description page.";

return View();
}

public IActionResult Contact()
{
ViewData["Message"] = "Your contact page.";

return View();
}

public IActionResult Error()
{
return View();
}
}
}
140 changes: 140 additions & 0 deletions MorseCode/Controllers/MorseCodeController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using MorseCode.MorseCode;
using System.IO;

namespace MorseCode.Controllers
{
public class MorseCodeController : Controller
{
private readonly AppSettings _appSettings;

public MorseCodeController(IOptions<AppSettings> appSettings)
{
_appSettings = appSettings.Value;
}

// GET: MorseCode
public ActionResult Index()
{
return View();
}

// GET: MorseCode/Details/5
public ActionResult Details(int id)
{
return View();
}

//Get Alphabet
public ActionResult ViewAlphabet()
{
//Get Configuration
var alphabet = new MorseCodeModel().MorseCodeAlphabet;
return View(alphabet);
}

public ActionResult CreateJSonFile()
{
return View();
}

[HttpGet]
public ActionResult UploadFile()
{
return View(new FileUpload());
}

[HttpPost]
public IActionResult UploadFile(FileUpload model)
{
var file = model.MorseCodeFile;

//Move the file to a string
StreamReader reader = new StreamReader(file.OpenReadStream());

MorseCodeFile fileParser = new MorseCodeFile();
model.MorseCode = fileParser.ConvertToPlainText(reader);

return View(model);
}

// GET: MorseCode/Create
[HttpPost, ValidateAntiForgeryToken]
public ActionResult CreateFile(IFormCollection forms)
{
MorseCode.MorseCodeFile fileCreator = new MorseCode.MorseCodeFile();
fileCreator.Save(forms["Plaintext"]);

return RedirectToAction("CreateJSonFile");
}

// POST: MorseCode/Create
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(IFormCollection collection)
{
try
{
// TODO: Add insert logic here

return RedirectToAction("Index");
}
catch
{
return View();
}
}

// GET: MorseCode/Edit/5
public ActionResult Edit(int id)
{
return View();
}

// POST: MorseCode/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(int id, IFormCollection collection)
{
try
{
// TODO: Add update logic here

return RedirectToAction("Index");
}
catch
{
return View();
}
}

// GET: MorseCode/Delete/5
public ActionResult Delete(int id)
{
return View();
}

// POST: MorseCode/Delete/5
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Delete(int id, IFormCollection collection)
{
try
{
// TODO: Add delete logic here

return RedirectToAction("Index");
}
catch
{
return View();
}
}
}
}
31 changes: 31 additions & 0 deletions MorseCode/MorseCode.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
</ItemGroup>

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" />
</ItemGroup>

<ItemGroup>
<Folder Include="Upload\" />
</ItemGroup>

</Project>
14 changes: 14 additions & 0 deletions MorseCode/MorseCode.csproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebStackScaffolding_DependencyDialogWidth>600</WebStackScaffolding_DependencyDialogWidth>
<WebStackScaffolding_ControllerDialogWidth>600</WebStackScaffolding_ControllerDialogWidth>
<WebStackScaffolding_IsLayoutPageSelected>True</WebStackScaffolding_IsLayoutPageSelected>
<WebStackScaffolding_IsPartialViewSelected>False</WebStackScaffolding_IsPartialViewSelected>
<WebStackScaffolding_IsReferencingScriptLibrariesSelected>False</WebStackScaffolding_IsReferencingScriptLibrariesSelected>
<WebStackScaffolding_LayoutPageFile />
<WebStackScaffolding_IsAsyncSelected>False</WebStackScaffolding_IsAsyncSelected>
<WebStackScaffolding_ViewDialogWidth>600</WebStackScaffolding_ViewDialogWidth>
<NameOfLastUsedPublishProfile>FolderProfile</NameOfLastUsedPublishProfile>
</PropertyGroup>
</Project>
14 changes: 14 additions & 0 deletions MorseCode/MorseCode/FileUpload.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Http;

namespace MorseCode.MorseCode
{
public class FileUpload
{
[Required]
[Display(Name = "Select a file:")]
public IFormFile MorseCodeFile { get; set; }
[Display(Name = "Translated Text:")]
public string MorseCode { get; set; }
}
}
39 changes: 39 additions & 0 deletions MorseCode/MorseCode/MorseCode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.IO;
using Newtonsoft.Json;

namespace MorseCode
{
public class MorseCodeModel
{
public MorseCodeModel()
{

}

public List<MorseCodeLetter> MorseCodeAlphabet
{
get
{
//Load json file into list
string json = File.ReadAllText("./MorseCode/MorseCodeAlphabet.json");
List<MorseCodeLetter> alphabet = JsonConvert.DeserializeObject<List<MorseCodeLetter>>(json);
return (alphabet);
}
}

}

//Normal I would add another file for another class.
public class MorseCodeLetter
{

[JsonProperty("Letter")]
public string Letter { get; set; }
[JsonProperty("Code")]
public string Code { get; set; }
}
}
Loading