Refactoring 1
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace MyWebsite.Controllers
|
||||
{
|
||||
public class AboutController : Controller
|
||||
{
|
||||
public IActionResult Index() =>
|
||||
View();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MyWebsite.Models;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MyWebsite.Controllers
|
||||
{
|
||||
public class AdminController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Projects(int? id)
|
||||
{
|
||||
if (id == null)
|
||||
return View();
|
||||
else
|
||||
{
|
||||
Project[] projects = JsonConvert.DeserializeObject<Project[]>(await new HttpClient().GetStringAsync($"{Request.Scheme}://{Request.Host}/Projects.json"));
|
||||
|
||||
ViewData["Project"] = projects[id.Value];
|
||||
ViewData["Badges"] = new Dictionary<string, string>
|
||||
{
|
||||
{ "csharp", "C# Programming language" },
|
||||
{ "dotnet", ".NET Framework" },
|
||||
{ "xamarin", "Xamarin Framework" },
|
||||
{ "unity", "Unity Engine" },
|
||||
{ "uwp", "Universal Windows Platform" },
|
||||
{ "windows", "Windows Platform" },
|
||||
{ "win32", "Windows Platform (Win32)" },
|
||||
{ "android", "Android Platform" },
|
||||
{ "ios", "iOS Platform" }
|
||||
};
|
||||
|
||||
return View("Views/Admin/ProjectEditor.cshtml");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SelectPdf;
|
||||
|
||||
namespace MyWebsite.Controllers
|
||||
{
|
||||
public class CVController : Controller
|
||||
{
|
||||
public IActionResult Index() =>
|
||||
View();
|
||||
|
||||
public IActionResult Download()
|
||||
{
|
||||
HtmlToPdf converter = new HtmlToPdf();
|
||||
converter.Options.MarginTop = 25;
|
||||
converter.Options.MarginBottom = 25;
|
||||
PdfDocument doc = converter.ConvertUrl($"{Request.Scheme}://{Request.Host}/CV/PrintCV?pdfPreview=true");
|
||||
byte[] data = doc.Save();
|
||||
doc.Close();
|
||||
return File(data, "application/pdf", "[Michael Gordeev] CV.pdf");
|
||||
}
|
||||
|
||||
public IActionResult PrintCV(bool pdfPreview = false)
|
||||
{
|
||||
ViewData["pdfPreview"] = pdfPreview;
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MyWebsite.Models;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
|
||||
namespace MyWebsite.Controllers
|
||||
{
|
||||
public class ContactsController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
Dictionary<string, Link> links = JsonConvert.DeserializeObject<Dictionary<string, Link>>(new WebClient().DownloadString($"{Request.Scheme}://{Request.Host}/Links.json"));
|
||||
ViewData["contactLinks"] = links.Values.ToList().FindAll(i => i.CanContactMe);
|
||||
ViewData["otherLinks"] = links.Values.ToList().FindAll(i => !i.CanContactMe);
|
||||
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MyWebsite.Models;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MyWebsite.Controllers
|
||||
{
|
||||
public class GalleryController : Controller
|
||||
{
|
||||
[HttpGet("Arts")]
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
return View(JsonConvert.DeserializeObject<Image[]>(await new HttpClient().GetStringAsync($"{Request.Scheme}://{Request.Host}/Gallery.json")));
|
||||
}
|
||||
|
||||
[HttpGet("Image")]
|
||||
public async Task<IActionResult> Details(string id)
|
||||
{
|
||||
return View(JsonConvert.DeserializeObject<Image[]>(await new HttpClient().GetStringAsync($"https://{Request.Host}/Gallery.json")).First(i => i.FileName == id));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Diagnostics;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MyWebsite.Models;
|
||||
|
||||
namespace MyWebsite.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
// TODO: Add more specific OpenGraph meta tags
|
||||
// TODO: Create custom error page
|
||||
// TODO: Update Projects.json and Gallery.json (Add this site, BSI)
|
||||
// TODO: Complete About page
|
||||
// TODO: Localize application
|
||||
// TODO: Make authorization system and ability to update website through GUI
|
||||
// TODO: Consider a database connection
|
||||
// TODO: Add more detailed parsing of artwork descriptions
|
||||
public IActionResult Index() =>
|
||||
View();
|
||||
|
||||
[HttpGet("Error")]
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error() =>
|
||||
View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using MyWebsite.Models;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MyWebsite.Controllers
|
||||
{
|
||||
public class ProjectsController : Controller
|
||||
{
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
Project[] projects = JsonConvert.DeserializeObject<Project[]>(await new HttpClient().GetStringAsync($"{Request.Scheme}://{Request.Host}/Projects.json"));
|
||||
|
||||
ViewData["Projects"] = projects;
|
||||
ViewData["Badges"] = new Dictionary<string, string>
|
||||
{
|
||||
{ "csharp", "C# Programming language" },
|
||||
{ "dotnet", ".NET Framework" },
|
||||
{ "xamarin", "Xamarin Framework" },
|
||||
{ "unity", "Unity Engine" },
|
||||
{ "uwp", "Universal Windows Platform" },
|
||||
{ "windows", "Windows Platform" },
|
||||
{ "win32", "Windows Platform (Win32)" },
|
||||
{ "android", "Android Platform" },
|
||||
{ "ios", "iOS Platform" }
|
||||
};
|
||||
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user