This repository has been archived by the owner on Jan 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simplified bootstrap setup + updated server project with a base contr…
…oller class
- Loading branch information
Showing
110 changed files
with
187 additions
and
6,474 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
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
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
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
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
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,54 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Localization; | ||
using Toucan.Contract; | ||
using Toucan.Server.Model; | ||
using Toucan.Service; | ||
|
||
namespace Toucan.Server.Controllers | ||
{ | ||
public abstract class ControllerBase : Controller | ||
{ | ||
protected ILocalizationService Localization { get; private set; } | ||
protected IDomainContextResolver Resolver; | ||
private ILocalizationDictionary dictionary; | ||
private IDomainContext domainContext; | ||
|
||
public ControllerBase(IDomainContextResolver resolver, ILocalizationService localization) | ||
{ | ||
this.Localization = localization; | ||
this.Resolver = resolver; | ||
} | ||
|
||
protected ILocalizationDictionary Dictionary | ||
{ | ||
get | ||
{ | ||
if (this.dictionary == null) | ||
this.dictionary = this.Localization.CreateDictionary(this.DomainContext); | ||
|
||
return this.dictionary; | ||
} | ||
} | ||
|
||
protected IDomainContext DomainContext | ||
{ | ||
get | ||
{ | ||
if (this.domainContext == null) | ||
this.domainContext = this.Resolver.Resolve(); | ||
|
||
return this.domainContext; | ||
} | ||
} | ||
|
||
protected void ThrowLocalizedServiceException(string key) | ||
{ | ||
throw new ServiceException(this.Dictionary[key].Value); | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.