Skip to content

Commit

Permalink
feat: add document
Browse files Browse the repository at this point in the history
  • Loading branch information
BirajMainali committed Jan 28, 2024
1 parent 17c1b92 commit 6c08b60
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 6 deletions.
10 changes: 5 additions & 5 deletions App.Web/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -539,18 +539,18 @@
</footer>
</div>
</div>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/lib/nepali-date-picker/jquery.nepaliDatePicker.js" asp-append-version="true" defer="defer"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
<!-- Libs JS -->
<script src="~/theme/libs/apexcharts/dist/apexcharts.min.js?1684106062" defer></script>
<script src="/theme/libs/apexcharts/dist/apexcharts.min.js?1684106062" defer></script>
<script src="~/theme/libs/jsvectormap/dist/js/jsvectormap.min.js?1684106062" defer></script>
<script src="~/theme/libs/jsvectormap/dist/maps/world.js?1684106062" defer></script>
<script src="~/theme/libs/jsvectormap/dist/maps/world-merc.js?1684106062" defer></script>
<!-- Tabler Core -->
<script src="~/theme/js/tabler.min.js?1684106062" defer></script>
<script src="~/theme/js/demo.min.js?1684106062" defer></script>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/lib/nepali-date-picker/jquery.nepaliDatePicker.js" asp-append-version="true" defer="defer"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>
90 changes: 89 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,89 @@
# web-app-template-repo
# .NET Core Web App Template

## Pre-build's

* Generic Repository, Just inject IRepository to get started.
```csharp
IRepository<AppUser, long> userRepository
```
* Register your services into Dependencies with marks
```csharp
public interface IUserValidator : IScopedDependency // We have other too.
{
Task EnsureUniqueUserEmail(string email, long? id = null);
}
```
* Add your database Entity
```csharp
public class AppUser : FullAuditedEntity<long>
{
// props.
}
```
* Unit Of work
```csharp
public class UserService(IUserValidator userValidator, IUow uo) : IUserService
{
public async Task<AppUser> CreateUser(UserDto dto)
{
using var tsc = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);
var user = new AppUser();
await uow.CreateAsync(user);
await uow.CommitAsync();
tsc.Complete();
return user;
}
```
* Nepali Date, Importantly mentioned implementation show nepali but send English date request.
```html
<multi-date-span value="Datetime.Now()"/> // display nepali date.
<vc:date-input-vc name="To" value="@Model.Date"/> // nepali date input
```
* To current user information, We have `ICurrentUserProvider`
```csharp
public interface ICurrentUserProvider
{
bool IsLoggedIn();
Task<AppUser> GetCurrentUser();
long? GetCurrentUserId();
string GetCurrentConnectionKey();
}
```
* Multi-tenant Configuration `appsetting.json`. Physical separation is been used.
```json
"UseMultiTenancy": true, // you can control tenant from here.
```
* App-setting configurations
```csharp
IOptions<AppSettings> options
```
* Use Serilog
```csharp
ILogger<IMultiTenantHandler> logger
Log.Error(e, "Error while getting tenant");
```
* Resolve http response
```csharp
[Route("WhatIsMyTenant")]
public IActionResult WhatIsMyTenant()
{
try
{
var connectionKey = _currentUserProvider.GetCurrentConnectionKey();
return this.SendSuccess("Success", connectionKey); // here
}
catch (Exception e)
{
Log.Error(e, "Error while getting tenant");
return this.SendError(e.Message); // here
}
}
```

## Others
* Swagger `/Swagger`
* Logs `./Logs`
* Use of custom authentication including jwt and cookie.
* Physical content can saved outside application scope.
* Explore `FileHelper` to work with physical file.
* Check `IDatabaseConnectionProvider` to create new dapper connection.

0 comments on commit 6c08b60

Please sign in to comment.