-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ivan Porta
committed
Jan 8, 2018
1 parent
6add795
commit bb6a745
Showing
339 changed files
with
54,928 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Code-First has two commands for code based migration: | ||
Add-migration: It will scaffold the next migration for the changes you have made to your domain classes | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.27130.2010 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Origin", "Origin\Origin.csproj", "{7D961D12-2D09-4D7F-8594-A9DD3284AE94}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Documentation", "Documentation", "{06E04FB5-D6E4-4506-9EC4-F2E273252647}" | ||
ProjectSection(SolutionItems) = preProject | ||
Documentation.txt = Documentation.txt | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{7D961D12-2D09-4D7F-8594-A9DD3284AE94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{7D961D12-2D09-4D7F-8594-A9DD3284AE94}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{7D961D12-2D09-4D7F-8594-A9DD3284AE94}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{7D961D12-2D09-4D7F-8594-A9DD3284AE94}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {7137D9C3-EC56-4FB3-89ED-ACD954103900} | ||
EndGlobalSection | ||
GlobalSection(TeamFoundationVersionControl) = preSolution | ||
SccNumberOfProjects = 2 | ||
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C} | ||
SccTeamFoundationServer = https://ivanportaweb.visualstudio.com/ | ||
SccLocalPath0 = . | ||
SccProjectUniqueName1 = Origin\\Origin.csproj | ||
SccProjectName1 = Origin | ||
SccLocalPath1 = Origin | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"" | ||
{ | ||
"FILE_VERSION" = "9237" | ||
"ENLISTMENT_CHOICE" = "NEVER" | ||
"PROJECT_FILE_RELATIVE_PATH" = "" | ||
"NUMBER_OF_EXCLUDED_FILES" = "0" | ||
"ORIGINAL_PROJECT_FILE_PATH" = "" | ||
"NUMBER_OF_NESTED_PROJECTS" = "0" | ||
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Authentication; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Origin.Models.Store; | ||
using Origin.ViewModels.Requests; | ||
|
||
namespace Origin.Controllers | ||
{ | ||
[Authorize] | ||
public class AccountController : Controller | ||
{ | ||
|
||
private readonly UserManager<OR_User> _userManager; | ||
|
||
private readonly SignInManager<OR_User> _signInManager; | ||
|
||
#region Constructor | ||
|
||
public AccountController(UserManager<OR_User> userManager, SignInManager<OR_User> signInManager) | ||
{ | ||
_userManager = userManager; | ||
_signInManager = signInManager; | ||
} | ||
|
||
#endregion | ||
|
||
#region Public Methods | ||
|
||
[HttpGet] | ||
[AllowAnonymous] | ||
public IActionResult Register(string returnUrl = null) | ||
{ | ||
ViewData["ReturnUrl"] = returnUrl; | ||
return View(); | ||
} | ||
|
||
[HttpPost] | ||
[AllowAnonymous] | ||
[ValidateAntiForgeryToken] | ||
public async Task<IActionResult> Register(RegisterRequest model, string returnUrl = null) | ||
{ | ||
ViewData["ReturnUrl"] = returnUrl; | ||
if (ModelState.IsValid) | ||
{ | ||
var user = new OR_User { UserName = model.Email, Email = model.Email }; | ||
var result = await _userManager.CreateAsync(user, model.Password); | ||
if (result.Succeeded) | ||
{ | ||
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); | ||
//var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme); | ||
//await _emailSender.SendEmailConfirmationAsync(model.Email, callbackUrl); | ||
|
||
await _signInManager.SignInAsync(user, isPersistent: false); | ||
return RedirectToLocal(returnUrl); | ||
} | ||
AddErrors(result); | ||
} | ||
|
||
// If we got this far, something failed, redisplay form | ||
return View(model); | ||
} | ||
|
||
[HttpGet] | ||
[AllowAnonymous] | ||
public async Task<IActionResult> Login(string returnUrl = null) | ||
{ | ||
// Clear the existing external cookie to ensure a clean login process | ||
await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme); | ||
|
||
ViewData["ReturnUrl"] = returnUrl; | ||
return View(); | ||
} | ||
|
||
[HttpPost] | ||
[AllowAnonymous] | ||
[ValidateAntiForgeryToken] | ||
public async Task<IActionResult> Login(LoginRequest model, string returnUrl = null) | ||
{ | ||
ViewData["ReturnUrl"] = returnUrl; | ||
if (ModelState.IsValid) | ||
{ | ||
// This doesn't count login failures towards account lockout | ||
// To enable password failures to trigger account lockout, set lockoutOnFailure: true | ||
var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure: false); | ||
if (result.Succeeded) | ||
{ | ||
return RedirectToLocal(returnUrl); | ||
} | ||
if (result.IsLockedOut) | ||
{ | ||
return View("Lockout"); | ||
} | ||
else | ||
{ | ||
ModelState.AddModelError("Error", "Invalid login attempt."); | ||
return View(model); | ||
} | ||
} | ||
|
||
// If we got this far, something failed, redisplay form | ||
return View(model); | ||
} | ||
|
||
[HttpGet] | ||
public async Task<IActionResult> LogOut() | ||
{ | ||
await _signInManager.SignOutAsync(); | ||
return RedirectToAction(nameof(HomeController.Index), "Home"); | ||
} | ||
|
||
#endregion | ||
|
||
#region Private Methods | ||
|
||
private void AddErrors(IdentityResult result) | ||
{ | ||
foreach (var error in result.Errors) | ||
{ | ||
ModelState.AddModelError(string.Empty, error.Description); | ||
} | ||
} | ||
|
||
private ActionResult RedirectToLocal(string returnUrl) | ||
{ | ||
if (Url.IsLocalUrl(returnUrl)) | ||
{ | ||
return Redirect(returnUrl); | ||
} | ||
return RedirectToAction("Index", "Home"); | ||
} | ||
|
||
#endregion | ||
} | ||
|
||
|
||
} |
141 changes: 141 additions & 0 deletions
141
.NET Core/Origin/Controllers/ConfigurationController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Caching.Memory; | ||
using Origin.Models; | ||
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) | ||
{ | ||
_cacheService = new CacheService(cache, ConfigurationManager.GetConfigurationByPath("Paths:Localization")); | ||
_context = context; | ||
} | ||
|
||
#endregion | ||
|
||
#region Public Methods | ||
|
||
[HttpGet] | ||
public JsonResult GetLocalizations() | ||
{ | ||
var viewModel = _cacheService.GetLocalizations(); | ||
return Json(viewModel); | ||
} | ||
|
||
[HttpGet] | ||
public JsonResult GetConfiguration() | ||
{ | ||
var viewModel = _cacheService.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; | ||
} | ||
|
||
return Json(viewModel); | ||
} | ||
|
||
[HttpPost] | ||
// TODO: Implement server side | ||
public JsonResult GetTable(string name) | ||
{ | ||
//TODO: find a different way from a switch | ||
//GetTableResponse viewModel = new GetTableResponse(); | ||
|
||
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); | ||
} | ||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Origin.Controllers | ||
{ | ||
public class ErrorController : Controller | ||
{ | ||
public IActionResult Index() | ||
{ | ||
return View(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Origin.ViewModels.Requests; | ||
|
||
namespace Origin.Controllers | ||
{ | ||
[Authorize] | ||
public class FormController : Controller | ||
{ | ||
//IFormService service = new FormService(); | ||
|
||
[HttpPost] | ||
public JsonResult GetForm(GetFormRequest request) | ||
{ | ||
//var viewModel = service.GetForm(request); | ||
//return Json(viewModel, JsonRequestBehavior.DenyGet); | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Origin.Controllers | ||
{ | ||
[Authorize] | ||
public class HomeController : Controller | ||
{ | ||
public IActionResult Index() | ||
{ | ||
return View(); | ||
} | ||
} | ||
} |
Oops, something went wrong.