Skip to content

Commit

Permalink
Refactor website
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Porta committed May 1, 2018
1 parent 9e338a8 commit 376af6f
Show file tree
Hide file tree
Showing 57 changed files with 2,235 additions and 1,535 deletions.
990 changes: 990 additions & 0 deletions .NET Core/.vs/config/applicationhost.config

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions .NET Core/Documentation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@ Add-migration: It will scaffold the next migration for the changes you have made
Update-database: It will apply pending changes to the database based on latest scaffolding code file you created using "Add-Migration" command

example:
Add-migration -context ApplicationDbContext
Add-migration -context OriginContext
update-database -context ApplicationDbContext
update-database -context OriginContext
Add-migration -context OriginDbContext
update-database -context OriginDbContext
1 change: 1 addition & 0 deletions .NET Core/Origin/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public async Task<IActionResult> Login(LoginRequest model, string returnUrl = nu
}
else
{
// TODO: Localize this fucking string
ModelState.AddModelError("Error", "Invalid login attempt.");
return View(model);
}
Expand Down
112 changes: 12 additions & 100 deletions .NET Core/Origin/Controllers/ConfigurationController.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using Origin.Models;
using Microsoft.Extensions.Configuration;
using Origin.Service.Implementation;
using Origin.ViewModels;
using Origin.ViewModels.Responses;


namespace Origin.Controllers
{
public class ConfigurationController : Controller
{
private readonly CacheService _cacheService;

private readonly OriginContext _context;

#region Constructor

public ConfigurationController(OriginContext context, IMemoryCache cache)
public ConfigurationController(IMemoryCache cache)
{
_cacheService = new CacheService(cache, ConfigurationManager.GetConfigurationByPath("Paths:Localization"));
_context = context;
_cacheService = new CacheService(cache, GetConfigurationByPath("Paths:Localization"));
}

#endregion
Expand All @@ -42,100 +36,18 @@ public JsonResult GetConfiguration()
return Json(viewModel);
}

[HttpGet]
// TODO: Implement server side
public JsonResult GetTables()
{
GetTablesResponse viewModel = new GetTablesResponse();

try
{
if (User.IsInRole("Administrator"))
{
viewModel.Tables = new List<GetTablesResponse.Table>()
{
new GetTablesResponse.Table() { Name = "OR_Forms",
Columns = new List<GetTablesResponse.Column> {
new GetTablesResponse.Column() { Name = "Name" },
new GetTablesResponse.Column() { Name = "Type" } } },
new GetTablesResponse.Table() { Name = "OR_Inputs",
Columns = new List<GetTablesResponse.Column> {
new GetTablesResponse.Column() { Name = "Name" },
new GetTablesResponse.Column() { Name = "Type" },
new GetTablesResponse.Column() { Name = "RelatedOriginId" } } },
new GetTablesResponse.Table() { Name = "OR_ItemTypes",
Columns = new List<GetTablesResponse.Column> {
new GetTablesResponse.Column() { Name = "Name" } } },
new GetTablesResponse.Table() { Name = "OR_Lookups",
Columns = new List<GetTablesResponse.Column> {
new GetTablesResponse.Column() { Name = "Name" },
new GetTablesResponse.Column() { Name = "Type" } } },
new GetTablesResponse.Table() { Name = "OR_LookupValues",
Columns = new List<GetTablesResponse.Column> {
new GetTablesResponse.Column() { Name = "Name" },
new GetTablesResponse.Column() { Name = "RelatedOriginId" } } },
new GetTablesResponse.Table() { Name = "OR_Roles",
Columns = new List<GetTablesResponse.Column> {
new GetTablesResponse.Column() { Name = "Name" } } },
new GetTablesResponse.Table() { Name = "OR_Users",
Columns = new List<GetTablesResponse.Column> {
new GetTablesResponse.Column() { Name = "Name" },
new GetTablesResponse.Column() { Name = "Surname" },
new GetTablesResponse.Column() { Name = "Email" },
new GetTablesResponse.Column() { Name = "PhoneNumber" } } },
};
}
}
catch (Exception exc)
{
viewModel.ResultInfo.Result = Base.ResultInfoDto.ResultEnum.Error;
viewModel.ResultInfo.ErrorMessage = exc.Message;
}
#endregion

return Json(viewModel);
}
#region Private Methods

[HttpPost]
// TODO: Implement server side
public JsonResult GetTable(string name)
public string GetConfigurationByPath(string path)
{
//TODO: find a different way from a switch
//GetTableResponse viewModel = new GetTableResponse();
var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");
IConfigurationRoot Configuration; Configuration = builder.Build();

try
{
if (User.IsInRole("Administrator"))
{
switch(name)
{
case "OR_Forms":
var forms = _context.OR_Forms.Select(f => f).ToList();
return Json(forms);
//break;
case "OR_Inputs":
break;
case "OR_ItemTypes":
break;
case "OR_Lookups":
break;
case "OR_LookupValues":
break;
case "OR_Roles":
break;
case "OR_Users":
break;
}
}
}
catch (Exception exc)
{
//viewModel.ResultInfo.Result = Base.ResultInfoDto.ResultEnum.Error;
//viewModel.ResultInfo.ErrorMessage = exc.Message;
}

return Json(null);
//return Json(viewModel);
return Configuration.GetValue<string>(path);
}

#endregion
}
}
24 changes: 17 additions & 7 deletions .NET Core/Origin/Controllers/ItemController.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Origin.Models;
using Origin.Service.Implementation;
using Origin.ViewModels.Requests;

namespace Origin.Controllers
{
[Authorize]
public class ItemController : Controller
{
//IItemService service = new ItemService();
private readonly OriginDbContext _context;

private readonly ItemService _service;

public ItemController(OriginDbContext context)
{
_context = context;
_service = new ItemService(context);
}

//[HttpPost]
//public JsonResult AddItem(AddItemRequest request)
Expand All @@ -23,12 +33,12 @@ public class ItemController : Controller
// return Json(viewModel, JsonRequestBehavior.DenyGet);
//}

//[HttpPost]
//public JsonResult GetItems(GetItemsRequest request)
//{
// var viewModel = service.GetItems(request);
// return Json(viewModel, JsonRequestBehavior.DenyGet);
//}
[HttpPost]
public JsonResult GetItems(GetItemsRequest request)
{
var viewModel = _service.GetItemsToList(request);
return Json(viewModel);
}

//[HttpPost]
//public JsonResult DeleteItem(DeleteItemRequest request)
Expand Down
50 changes: 50 additions & 0 deletions .NET Core/Origin/Controllers/ItemTypeController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Origin.Models;
using Origin.Service.Implementation;
using Origin.ViewModels.Requests;

namespace Origin.Controllers
{
[Authorize]
public class ItemTypeController : Controller
{
private readonly OriginDbContext _context;

private readonly ItemTypeService _service;

public ItemTypeController(OriginDbContext context)
{
_context = context;
_service = new ItemTypeService(context);
}

//[HttpPost]
//public JsonResult AddItem(AddItemRequest request)
//{
// var viewModel = service.AddItem(request);
// return Json(viewModel, JsonRequestBehavior.DenyGet);
//}

//[HttpPost]
//public JsonResult GetItem(GetItemRequest request)
//{
// var viewModel = service.GetItem(request);
// return Json(viewModel, JsonRequestBehavior.DenyGet);
//}

[HttpPost]
public JsonResult GetItemTypes(GetItemTypesRequest request)
{
var viewModel = _service.GetItemTypesToList(request);
return Json(viewModel);
}

//[HttpPost]
//public JsonResult DeleteItem(DeleteItemRequest request)
//{
// var viewModel = service.DeleteItems(request);
// return Json(viewModel, JsonRequestBehavior.DenyGet);
//}
}
}
Loading

0 comments on commit 376af6f

Please sign in to comment.