Add project files.

This commit is contained in:
giteasujitb 2022-01-08 12:50:14 +05:30
commit 70340abf46
7149 changed files with 676109 additions and 0 deletions

65
.gitattributes vendored Normal file
View File

@ -0,0 +1,65 @@
coderush/wwwroot/* linguist-vendored
*.cshtml linguist-language=C#
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

261
.gitignore vendored Normal file
View File

@ -0,0 +1,261 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
project.fragment.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
#*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 go2ismail
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

47
README.md Normal file
View File

@ -0,0 +1,47 @@
# AdminLTE-Roles-And-Memberships-Example
ASP.NET Core 2.2 Roles And Memberships Customization Implemented Using Beautiful AdminLTE Template. C# as programming language and EF (Entity Framework) as ORM.
![sc1](coderush/wwwroot/images/lte0.png)
Features:
1. configuration over development (Identity configuration through appsettings.json)
2. custom error handling (ex: 404 and 500 custom error page)
3. user membership with dynamics roles management
4. dbinitializer for data seed (ex: super admin user initialization)
5. user registration and change password management
6. basic profile management
7. override identity user with custom column
8. active / de-active member
9. custom security service implemented through DI (dependency injection)
10. xsrf / anti forgery token
Technical:
1. C#
2. EF (Entity Framework)
3. jQuery
4. Bootstrap
5. Datatables.net
6. crud
7. toastr
8. mssql
# Development Tools & Environment
I'm using **Visual Studio Community 2017** for the development tools on Windows 10 machine.
# .Net Core Version
I'm using **.Net Core 2.2**
# Supported by CodeRush.Co
[CodeRush.CO] source code collections (https://coderush.co) lot of cool open source apps there. 50% Off All Products, Use Discount Code **GITHUB50**

25
SocietyCA.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31205.134
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SocietyCA", "coderush\SocietyCA.csproj", "{17E8F2F3-3578-4D5D-B810-87E298A48F62}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{17E8F2F3-3578-4D5D-B810-87E298A48F62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{17E8F2F3-3578-4D5D-B810-87E298A48F62}.Debug|Any CPU.Build.0 = Debug|Any CPU
{17E8F2F3-3578-4D5D-B810-87E298A48F62}.Release|Any CPU.ActiveCfg = Release|Any CPU
{17E8F2F3-3578-4D5D-B810-87E298A48F62}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FDE16EBB-4666-4CC8-9BC0-7CD48682F30A}
EndGlobalSection
EndGlobal

25
coderush.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31205.134
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SocietyCA", "coderush\SocietyCA.csproj", "{17E8F2F3-3578-4D5D-B810-87E298A48F62}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{17E8F2F3-3578-4D5D-B810-87E298A48F62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{17E8F2F3-3578-4D5D-B810-87E298A48F62}.Debug|Any CPU.Build.0 = Debug|Any CPU
{17E8F2F3-3578-4D5D-B810-87E298A48F62}.Release|Any CPU.ActiveCfg = Release|Any CPU
{17E8F2F3-3578-4D5D-B810-87E298A48F62}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FDE16EBB-4666-4CC8-9BC0-7CD48682F30A}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,21 @@
using System;
using coderush.Data;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.UI;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
[assembly: HostingStartup(typeof(coderush.Areas.Identity.IdentityHostingStartup))]
namespace coderush.Areas.Identity
{
public class IdentityHostingStartup : IHostingStartup
{
public void Configure(IWebHostBuilder builder)
{
builder.ConfigureServices((context, services) => {
});
}
}
}

View File

@ -0,0 +1,57 @@
@page
@model AccessDeniedModel
@{
ViewData["Title"] = "Access denied";
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>@ViewData["Title"]</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.7 -->
<link rel="stylesheet" href="~/adminlte/components/bootstrap/dist/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="~/adminlte/components/font-awesome/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="~/adminlte/components/Ionicons/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="~/adminlte/dist/css/AdminLTE.min.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Google Font -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition lockscreen">
<!-- Automatic element centering -->
<div class="lockscreen-wrapper">
<div class="lockscreen-logo">
<a href="/Identity/Account/Manage/Index">@ViewData["Title"]</a>
</div>
<div class="help-block text-center">
You do not have access to this resource.
</div>
<div class="text-center">
<a href="/Identity/Account/Login">Or sign in as a different user</a>
</div>
<div class="lockscreen-footer text-center">
Copyright &copy; 2019 <b><a href="https://authlinq.com" class="text-black">AuthlinQ</a></b><br>
All rights reserved
</div>
</div>
<!-- /.center -->
<!-- jQuery 3 -->
<script src="~/adminlte/components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="~/adminlte/components/bootstrap/dist/js/bootstrap.min.js"></script>
</body>
</html>

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace coderush.Areas.Identity.Pages.Account
{
public class AccessDeniedModel : PageModel
{
public void OnGet()
{
}
}
}

View File

@ -0,0 +1,57 @@
@page
@model ConfirmEmailModel
@{
ViewData["Title"] = "Confirm email";
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>@ViewData["Title"]</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.7 -->
<link rel="stylesheet" href="~/adminlte/components/bootstrap/dist/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="~/adminlte/components/font-awesome/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="~/adminlte/components/Ionicons/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="~/adminlte/dist/css/AdminLTE.min.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Google Font -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition lockscreen">
<!-- Automatic element centering -->
<div class="lockscreen-wrapper">
<div class="lockscreen-logo">
<a href="/Identity/Account/Manage/Index">@ViewData["Title"]</a>
</div>
<div class="help-block text-center">
Thank you for confirming your email.
</div>
<div class="text-center">
<a href="/Identity/Account/Login">Login</a>
</div>
<div class="lockscreen-footer text-center">
Copyright &copy; 2019 <b><a href="https://authlinq.com" class="text-black">AuthlinQ</a></b><br>
All rights reserved
</div>
</div>
<!-- /.center -->
<!-- jQuery 3 -->
<script src="~/adminlte/components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="~/adminlte/components/bootstrap/dist/js/bootstrap.min.js"></script>
</body>
</html>

View File

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace coderush.Areas.Identity.Pages.Account
{
[AllowAnonymous]
public class ConfirmEmailModel : PageModel
{
private readonly UserManager<IdentityUser> _userManager;
public ConfirmEmailModel(UserManager<IdentityUser> userManager)
{
_userManager = userManager;
}
public async Task<IActionResult> OnGetAsync(string userId, string code)
{
if (userId == null || code == null)
{
return RedirectToPage("/Index");
}
var user = await _userManager.FindByIdAsync(userId);
if (user == null)
{
return NotFound($"Unable to load user with ID '{userId}'.");
}
var result = await _userManager.ConfirmEmailAsync(user, code);
if (!result.Succeeded)
{
throw new InvalidOperationException($"Error confirming email for user with ID '{userId}':");
}
return Page();
}
}
}

View File

@ -0,0 +1,86 @@
@page
@model ForgotPasswordModel
@{
ViewData["Title"] = "Forgot your password? Enter your email";
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>@ViewData["Title"]</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.7 -->
<link rel="stylesheet" href="~/adminlte/components/bootstrap/dist/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="~/adminlte/components/font-awesome/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="~/adminlte/components/Ionicons/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="~/adminlte/dist/css/AdminLTE.min.css">
<!-- iCheck -->
<link rel="stylesheet" href="~/adminlte/plugins/iCheck/square/blue.css">
<!-- AdminLTE Skins. Choose a skin from the css/skins
folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet" href="~/adminlte/dist/css/skins/_all-skins.min.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Google Font -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition login-page">
<div class="login-box">
<div class="login-logo">
<a href="#">@ViewData["Title"]</a>
</div>
<!-- /.login-logo -->
<div class="login-box-body">
<form id="account" method="post">
<div asp-validation-summary="All" class="text-danger"></div>
<div class="form-group has-feedback">
<input asp-for="Input.Email" type="text" class="form-control" placeholder="Email">
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
</div>
</form>
<div class="social-auth-links text-center">
<p>- OR -</p>
<a href="#" class="btn btn-block btn-social btn-facebook btn-flat">
<i class="fa fa-facebook"></i> Sign in using
Facebook
</a>
<a href="#" class="btn btn-block btn-social btn-google btn-flat">
<i class="fa fa-google-plus"></i> Sign in using
Google+
</a>
</div>
<!-- /.social-auth-links -->
<a asp-page="./Login">Back to Login Page</a><br>
</div>
<!-- /.login-box-body -->
</div>
<!-- /.login-box -->
<!-- jQuery 3 -->
<script src="~/adminlte/components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="~/adminlte/components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- iCheck -->
<script src="~/adminlte/plugins/iCheck/icheck.min.js"></script>
<script>
$(function () {
$('input').iCheck({
checkboxClass: 'icheckbox_square-blue',
radioClass: 'iradio_square-blue',
increaseArea: '20%' /* optional */
});
});</script>
</body>
</html>

View File

@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.UI.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace coderush.Areas.Identity.Pages.Account
{
[AllowAnonymous]
public class ForgotPasswordModel : PageModel
{
private readonly UserManager<IdentityUser> _userManager;
private readonly IEmailSender _emailSender;
public ForgotPasswordModel(UserManager<IdentityUser> userManager, IEmailSender emailSender)
{
_userManager = userManager;
_emailSender = emailSender;
}
[BindProperty]
public InputModel Input { get; set; }
public class InputModel
{
[Required]
[EmailAddress]
public string Email { get; set; }
}
public async Task<IActionResult> OnPostAsync()
{
if (ModelState.IsValid)
{
var user = await _userManager.FindByEmailAsync(Input.Email);
if (user == null || !(await _userManager.IsEmailConfirmedAsync(user)))
{
// Don't reveal that the user does not exist or is not confirmed
return RedirectToPage("./ForgotPasswordConfirmation");
}
// For more information on how to enable account confirmation and password reset please
// visit https://go.microsoft.com/fwlink/?LinkID=532713
var code = await _userManager.GeneratePasswordResetTokenAsync(user);
var callbackUrl = Url.Page(
"/Account/ResetPassword",
pageHandler: null,
values: new { code },
protocol: Request.Scheme);
await _emailSender.SendEmailAsync(
Input.Email,
"Reset Password",
$"Please reset your password by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");
return RedirectToPage("./ForgotPasswordConfirmation");
}
return Page();
}
}
}

View File

@ -0,0 +1,58 @@
@page
@model ForgotPasswordConfirmation
@{
ViewData["Title"] = "Forgot password confirmation";
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>@ViewData["Title"]</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.7 -->
<link rel="stylesheet" href="~/adminlte/components/bootstrap/dist/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="~/adminlte/components/font-awesome/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="~/adminlte/components/Ionicons/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="~/adminlte/dist/css/AdminLTE.min.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Google Font -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition lockscreen">
<!-- Automatic element centering -->
<div class="lockscreen-wrapper">
<div class="lockscreen-logo">
<a href="/Identity/Account/Manage/Index">@ViewData["Title"]</a>
</div>
<div class="help-block text-center">
Please check your email to reset your password.
</div>
<div class="text-center">
<a href="/Identity/Account/Login">Login</a>
</div>
<div class="lockscreen-footer text-center">
Copyright &copy; 2019 <b><a href="https://authlinq.com" class="text-black">AuthlinQ</a></b><br>
All rights reserved
</div>
</div>
<!-- /.center -->
<!-- jQuery 3 -->
<script src="~/adminlte/components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="~/adminlte/components/bootstrap/dist/js/bootstrap.min.js"></script>
</body>
</html>

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace coderush.Areas.Identity.Pages.Account
{
[AllowAnonymous]
public class ForgotPasswordConfirmation : PageModel
{
public void OnGet()
{
}
}
}

View File

@ -0,0 +1,57 @@
@page
@model LockoutModel
@{
ViewData["Title"] = "Locked out";
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>@ViewData["Title"]</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.7 -->
<link rel="stylesheet" href="~/adminlte/components/bootstrap/dist/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="~/adminlte/components/font-awesome/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="~/adminlte/components/Ionicons/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="~/adminlte/dist/css/AdminLTE.min.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Google Font -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition lockscreen">
<!-- Automatic element centering -->
<div class="lockscreen-wrapper">
<div class="lockscreen-logo">
<a href="/Identity/Account/Manage/Index">@ViewData["Title"]</a>
</div>
<div class="help-block text-center">
This account has been locked out, please try again later.
</div>
<div class="text-center">
<a href="/Identity/Account/Login">Login</a>
</div>
<div class="lockscreen-footer text-center">
Copyright &copy; 2019 <b><a href="https://authlinq.com" class="text-black">AuthlinQ</a></b><br>
All rights reserved
</div>
</div>
<!-- /.center -->
<!-- jQuery 3 -->
<script src="~/adminlte/components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="~/adminlte/components/bootstrap/dist/js/bootstrap.min.js"></script>
</body>
</html>

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace coderush.Areas.Identity.Pages.Account
{
[AllowAnonymous]
public class LockoutModel : PageModel
{
public void OnGet()
{
}
}
}

View File

@ -0,0 +1,108 @@
@page
@model LoginModel
@{
ViewData["Title"] = "Log in";
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>@ViewData["Title"]</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.7 -->
<link rel="stylesheet" href="~/adminlte/components/bootstrap/dist/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="~/adminlte/components/font-awesome/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="~/adminlte/components/Ionicons/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="~/adminlte/dist/css/AdminLTE.min.css">
<!-- iCheck -->
<link rel="stylesheet" href="~/adminlte/plugins/iCheck/square/blue.css">
<!-- AdminLTE Skins. Choose a skin from the css/skins
folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet" href="~/adminlte/dist/css/skins/_all-skins.min.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Google Font -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition login-page">
<div class="login-box">
<div class="login-logo">
<a href="#">@ViewData["Title"]</a>
</div>
<!-- /.login-logo -->
<div class="login-box-body">
<p class="login-box-msg">Sign in to start your session</p>
<form id="account" method="post">
<div asp-validation-summary="All" class="text-danger"></div>
<div class="form-group has-feedback">
<input asp-for="Input.Email" type="text" class="form-control" placeholder="Email">
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input asp-for="Input.Password" type="password" class="form-control" placeholder="Password">
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="row">
<div class="col-xs-8">
<div class="checkbox icheck">
<label>
<input asp-for="Input.RememberMe" type="checkbox"> Remember Me
</label>
</div>
</div>
<!-- /.col -->
<div class="col-xs-4">
<button type="submit" class="btn btn-primary btn-block btn-flat">Sign In</button>
</div>
<!-- /.col -->
</div>
</form>
@*<div class="social-auth-links text-center">
<p>- OR -</p>
<a href="#" class="btn btn-block btn-social btn-facebook btn-flat">
<i class="fa fa-facebook"></i> Sign in using
Facebook
</a>
<a href="#" class="btn btn-block btn-social btn-google btn-flat">
<i class="fa fa-google-plus"></i> Sign in using
Google+
</a>
</div>*@
<!-- /.social-auth-links -->
@*<a asp-page="./ForgotPassword">I forgot my password</a><br>
<a asp-page="./Register" class="text-center">Register a new membership</a>*@
</div>
<!-- /.login-box-body -->
</div>
<!-- /.login-box -->
<!-- jQuery 3 -->
<script src="~/adminlte/components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="~/adminlte/components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- iCheck -->
<script src="~/adminlte/plugins/iCheck/icheck.min.js"></script>
<script>
$(function () {
$('input').iCheck({
checkboxClass: 'icheckbox_square-blue',
radioClass: 'iradio_square-blue',
increaseArea: '20%' /* optional */
});
});</script>
</body>
</html>

View File

@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
using coderush.Services.Security;
using Microsoft.Extensions.Options;
namespace coderush.Areas.Identity.Pages.Account
{
[AllowAnonymous]
public class LoginModel : PageModel
{
private readonly SignInManager<IdentityUser> _signInManager;
private readonly ILogger<LoginModel> _logger;
private readonly IdentityDefaultOptions _identityDefaultOptions;
public LoginModel(
SignInManager<IdentityUser> signInManager,
ILogger<LoginModel> logger,
IOptions<IdentityDefaultOptions> identityDefaultOptions
)
{
_signInManager = signInManager;
_logger = logger;
_identityDefaultOptions = identityDefaultOptions.Value;
}
[BindProperty]
public InputModel Input { get; set; }
public IList<AuthenticationScheme> ExternalLogins { get; set; }
public string ReturnUrl { get; set; }
[TempData]
public string ErrorMessage { get; set; }
public class InputModel
{
[Required]
[EmailAddress]
public string Email { get; set; }
[Required]
[DataType(DataType.Password)]
public string Password { get; set; }
[Display(Name = "Remember me?")]
public bool RememberMe { get; set; }
}
public async Task OnGetAsync(string returnUrl = null)
{
if (!string.IsNullOrEmpty(ErrorMessage))
{
ModelState.AddModelError(string.Empty, ErrorMessage);
}
//set default return url from appsettings.json
returnUrl = _identityDefaultOptions.DefaultReturnUrl;
// Clear the existing external cookie to ensure a clean login process
await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme);
ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
ReturnUrl = returnUrl;
}
public async Task<IActionResult> OnPostAsync(string returnUrl = null)
{
//set default return url from appsettings.json
returnUrl = _identityDefaultOptions.DefaultReturnUrl;
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(Input.Email, Input.Password, Input.RememberMe, lockoutOnFailure: true);
if (result.Succeeded)
{
_logger.LogInformation("User logged in.");
return LocalRedirect(returnUrl);
}
if (result.RequiresTwoFactor)
{
return RedirectToPage("./LoginWith2fa", new { ReturnUrl = returnUrl, RememberMe = Input.RememberMe });
}
if (result.IsLockedOut)
{
_logger.LogWarning("User account locked out.");
return RedirectToPage("./Lockout");
}
else
{
ModelState.AddModelError(string.Empty, "Invalid login attempt.");
return Page();
}
}
// If we got this far, something failed, redisplay form
return Page();
}
}
}

View File

@ -0,0 +1,56 @@
@page
@model LogoutModel
@{
ViewData["Title"] = "Log out";
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>@ViewData["Title"]</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.7 -->
<link rel="stylesheet" href="~/adminlte/components/bootstrap/dist/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="~/adminlte/components/font-awesome/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="~/adminlte/components/Ionicons/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="~/adminlte/dist/css/AdminLTE.min.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Google Font -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition lockscreen">
<!-- Automatic element centering -->
<div class="lockscreen-wrapper">
<div class="lockscreen-logo">
<a href="/Identity/Account/Manage/Index">@ViewData["Title"]</a>
</div>
<div class="help-block text-center">
You have successfully logged out of the application.
</div>
<div class="text-center">
<a href="/Identity/Account/Login">Login</a>
</div>
<div class="lockscreen-footer text-center">
Copyright &copy; 2019 <b><a href="https://authlinq.com" class="text-black">AuthlinQ</a></b><br>
All rights reserved
</div>
</div>
<!-- /.center -->
<!-- jQuery 3 -->
<script src="~/adminlte/components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="~/adminlte/components/bootstrap/dist/js/bootstrap.min.js"></script>
</body>
</html>

View File

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
namespace coderush.Areas.Identity.Pages.Account
{
[AllowAnonymous]
public class LogoutModel : PageModel
{
private readonly SignInManager<IdentityUser> _signInManager;
private readonly ILogger<LogoutModel> _logger;
public LogoutModel(SignInManager<IdentityUser> signInManager, ILogger<LogoutModel> logger)
{
_signInManager = signInManager;
_logger = logger;
}
public void OnGet()
{
}
public async Task<IActionResult> OnPost(string returnUrl = null)
{
await _signInManager.SignOutAsync();
_logger.LogInformation("User logged out.");
if (returnUrl != null)
{
return LocalRedirect(returnUrl);
}
else
{
return Page();
}
}
}
}

View File

@ -0,0 +1,125 @@
@page
@model ChangePasswordModel
@{
ViewData["Title"] = "Change Password";
}
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
@ViewData["Title"]
</h1>
<p>
<partial name="_StatusMessage" for="StatusMessage" />
</p>
</section>
<!-- Main content -->
<section class="content">
<!-- Default box -->
<form id="change-password-form" method="post">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">Enter Your Current and New Password</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip"
title="Collapse">
<i class="fa fa-minus"></i>
</button>
<button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
<i class="fa fa-times"></i>
</button>
</div>
</div>
<div class="box-body">
<div class="form-group">
<label asp-for="Input.OldPassword"></label>
<input asp-for="Input.OldPassword" class="form-control" />
<span asp-validation-for="Input.OldPassword" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Input.NewPassword"></label>
<input asp-for="Input.NewPassword" class="form-control" />
<span asp-validation-for="Input.NewPassword" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Input.ConfirmPassword"></label>
<input asp-for="Input.ConfirmPassword" class="form-control" />
<span asp-validation-for="Input.ConfirmPassword" class="text-danger"></span>
</div>
</div>
<!-- /.box-body -->
<div class="box-footer">
<button type="submit" class="btn btn-primary">Update password</button>
</div>
<!-- /.box-footer-->
</div>
</form>
<!-- /.box -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
@section Styles{
<!-- Bootstrap 3.3.7 -->
<link rel="stylesheet" href="~/adminlte/components/bootstrap/dist/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="~/adminlte/components/font-awesome/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="~/adminlte/components/Ionicons/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="~/adminlte/dist/css/AdminLTE.min.css">
<!-- AdminLTE Skins. Choose a skin from the css/skins
folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet" href="~/adminlte/dist/css/skins/_all-skins.min.css">
<!-- Pace style -->
<link rel="stylesheet" href="~/adminlte/plugins/pace/pace.min.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Google Font -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
}
@section Scripts{
<!-- jQuery 3 -->
<script src="~/adminlte/components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="~/adminlte/components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- PACE -->
<script src="~/adminlte/components/PACE/pace.min.js"></script>
<!-- Slimscroll -->
<script src="~/adminlte/components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="~/adminlte/components/fastclick/lib/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="~/adminlte/dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="~/adminlte/dist/js/demo.js"></script>
<!-- page script -->
<script type="text/javascript">
// To make Pace works on Ajax calls
$(document).ajaxStart(function () {
Pace.restart()
})
$('.ajax').click(function () {
$.ajax({
url: '#', success: function (result) {
$('.ajax-content').html('<hr>Ajax Request Completed !')
}
})
})
</script>
<partial name="_ValidationScriptsPartial" />
}

View File

@ -0,0 +1,117 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using coderush.Services.Security;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
namespace coderush.Areas.Identity.Pages.Account.Manage
{
public class ChangePasswordModel : PageModel
{
private readonly UserManager<IdentityUser> _userManager;
private readonly SignInManager<IdentityUser> _signInManager;
private readonly ILogger<ChangePasswordModel> _logger;
private readonly IdentityDefaultOptions _identityDefaultOptions;
private readonly SuperAdminDefaultOptions _superAdminDefaultOptions;
public ChangePasswordModel(
UserManager<IdentityUser> userManager,
SignInManager<IdentityUser> signInManager,
ILogger<ChangePasswordModel> logger,
IOptions<IdentityDefaultOptions> identityDefaultOptions,
IOptions<SuperAdminDefaultOptions> superAdminDefaultOptions
)
{
_userManager = userManager;
_signInManager = signInManager;
_logger = logger;
_identityDefaultOptions = identityDefaultOptions.Value;
_superAdminDefaultOptions = superAdminDefaultOptions.Value;
}
[BindProperty]
public InputModel Input { get; set; }
[TempData]
public string StatusMessage { get; set; }
public class InputModel
{
[Required]
[DataType(DataType.Password)]
[Display(Name = "Current password")]
public string OldPassword { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "New password")]
public string NewPassword { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm new password")]
[Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
}
public async Task<IActionResult> OnGetAsync()
{
var user = await _userManager.GetUserAsync(User);
if (user == null)
{
return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
}
var hasPassword = await _userManager.HasPasswordAsync(user);
if (!hasPassword)
{
return RedirectToPage("./SetPassword");
}
return Page();
}
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
var user = await _userManager.GetUserAsync(User);
if (user == null)
{
return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
}
//check to see demo or not, if demo so it can not change the super@admin.com data
if (_identityDefaultOptions.IsDemo && _superAdminDefaultOptions.Email == user.Email)
{
StatusMessage = "Error: Demo mode can not change super@admin.com data.";
return RedirectToPage();
}
var changePasswordResult = await _userManager.ChangePasswordAsync(user, Input.OldPassword, Input.NewPassword);
if (!changePasswordResult.Succeeded)
{
foreach (var error in changePasswordResult.Errors)
{
ModelState.AddModelError(string.Empty, error.Description);
}
return Page();
}
await _signInManager.RefreshSignInAsync(user);
_logger.LogInformation("User changed their password successfully.");
StatusMessage = "Your password has been changed.";
return RedirectToPage();
}
}
}

View File

@ -0,0 +1,138 @@
@page
@model IndexModel
@{
ViewData["Title"] = "Profile";
}
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
@ViewData["Title"]
</h1>
<p>
<partial name="_StatusMessage" for="StatusMessage" />
</p>
</section>
<!-- Main content -->
<section class="content">
<!-- Default box -->
<form id="profile-form" method="post">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">Basic Profile</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip"
title="Collapse">
<i class="fa fa-minus"></i>
</button>
<button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
<i class="fa fa-times"></i>
</button>
</div>
</div>
<div class="box-body">
<div class="form-group">
<label asp-for="Username"></label>
<input asp-for="Username" class="form-control" disabled />
</div>
<div class="form-group">
<label asp-for="Input.Email"></label>
@if (Model.IsEmailConfirmed)
{
<div class="input-group">
<input asp-for="Input.Email" class="form-control" />
<span class="input-group-addon" aria-hidden="true"><span class="glyphicon glyphicon-ok text-success"></span></span>
</div>
}
else
{
<input asp-for="Input.Email" class="form-control" />
<button id="email-verification" type="submit" asp-page-handler="SendVerificationEmail" class="btn btn-link">Send verification email</button>
}
<span asp-validation-for="Input.Email" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Input.PhoneNumber"></label>
<input asp-for="Input.PhoneNumber" class="form-control" />
<span asp-validation-for="Input.PhoneNumber" class="text-danger"></span>
</div>
</div>
<!-- /.box-body -->
<div class="box-footer">
<button id="update-profile-button" type="submit" class="btn btn-primary">Save</button>
</div>
<!-- /.box-footer-->
</div>
</form>
<!-- /.box -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
@section Styles{
<!-- Bootstrap 3.3.7 -->
<link rel="stylesheet" href="~/adminlte/components/bootstrap/dist/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="~/adminlte/components/font-awesome/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="~/adminlte/components/Ionicons/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="~/adminlte/dist/css/AdminLTE.min.css">
<!-- AdminLTE Skins. Choose a skin from the css/skins
folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet" href="~/adminlte/dist/css/skins/_all-skins.min.css">
<!-- Pace style -->
<link rel="stylesheet" href="~/adminlte/plugins/pace/pace.min.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Google Font -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
}
@section Scripts{
<!-- jQuery 3 -->
<script src="~/adminlte/components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="~/adminlte/components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- PACE -->
<script src="~/adminlte/components/PACE/pace.min.js"></script>
<!-- Slimscroll -->
<script src="~/adminlte/components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="~/adminlte/components/fastclick/lib/fastclick.js"></script>
<!-- AdminLTE App -->
<script src="~/adminlte/dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="~/adminlte/dist/js/demo.js"></script>
<!-- page script -->
<script type="text/javascript">
// To make Pace works on Ajax calls
$(document).ajaxStart(function () {
Pace.restart()
})
$('.ajax').click(function () {
$.ajax({
url: '#', success: function (result) {
$('.ajax-content').html('<hr>Ajax Request Completed !')
}
})
})
</script>
<partial name="_ValidationScriptsPartial" />
}

View File

@ -0,0 +1,167 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using coderush.Services.Security;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.UI.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Options;
namespace coderush.Areas.Identity.Pages.Account.Manage
{
public partial class IndexModel : PageModel
{
private readonly UserManager<IdentityUser> _userManager;
private readonly SignInManager<IdentityUser> _signInManager;
private readonly IEmailSender _emailSender;
private readonly IdentityDefaultOptions _identityDefaultOptions;
private readonly SuperAdminDefaultOptions _superAdminDefaultOptions;
public IndexModel(
UserManager<IdentityUser> userManager,
SignInManager<IdentityUser> signInManager,
IEmailSender emailSender,
IOptions<IdentityDefaultOptions> identityDefaultOptions,
IOptions<SuperAdminDefaultOptions> superAdminDefaultOptions
)
{
_userManager = userManager;
_signInManager = signInManager;
_emailSender = emailSender;
_identityDefaultOptions = identityDefaultOptions.Value;
_superAdminDefaultOptions = superAdminDefaultOptions.Value;
}
public string Username { get; set; }
public bool IsEmailConfirmed { get; set; }
[TempData]
public string StatusMessage { get; set; }
[BindProperty]
public InputModel Input { get; set; }
public class InputModel
{
[Required]
[EmailAddress]
public string Email { get; set; }
[Phone]
[Display(Name = "Phone number")]
public string PhoneNumber { get; set; }
}
public async Task<IActionResult> OnGetAsync()
{
var user = await _userManager.GetUserAsync(User);
if (user == null)
{
return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
}
var userName = await _userManager.GetUserNameAsync(user);
var email = await _userManager.GetEmailAsync(user);
var phoneNumber = await _userManager.GetPhoneNumberAsync(user);
Username = userName;
Input = new InputModel
{
Email = email,
PhoneNumber = phoneNumber
};
IsEmailConfirmed = await _userManager.IsEmailConfirmedAsync(user);
return Page();
}
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
var user = await _userManager.GetUserAsync(User);
if (user == null)
{
return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
}
//check to see demo or not, if demo so it can not change the super@admin.com data
if (_identityDefaultOptions.IsDemo && _superAdminDefaultOptions.Email == user.Email)
{
StatusMessage = "Error: Demo mode can not change super@admin.com data.";
return RedirectToPage();
}
var email = await _userManager.GetEmailAsync(user);
if (Input.Email != email)
{
var setEmailResult = await _userManager.SetEmailAsync(user, Input.Email);
if (!setEmailResult.Succeeded)
{
var userId = await _userManager.GetUserIdAsync(user);
throw new InvalidOperationException($"Unexpected error occurred setting email for user with ID '{userId}'.");
}
//profile change by its own, no need to verification
user.EmailConfirmed = true;
await _userManager.UpdateAsync(user);
}
var phoneNumber = await _userManager.GetPhoneNumberAsync(user);
if (Input.PhoneNumber != phoneNumber)
{
var setPhoneResult = await _userManager.SetPhoneNumberAsync(user, Input.PhoneNumber);
if (!setPhoneResult.Succeeded)
{
var userId = await _userManager.GetUserIdAsync(user);
throw new InvalidOperationException($"Unexpected error occurred setting phone number for user with ID '{userId}'.");
}
}
await _signInManager.RefreshSignInAsync(user);
StatusMessage = "Your profile has been updated";
return RedirectToPage();
}
public async Task<IActionResult> OnPostSendVerificationEmailAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
var user = await _userManager.GetUserAsync(User);
if (user == null)
{
return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
}
var userId = await _userManager.GetUserIdAsync(user);
var email = await _userManager.GetEmailAsync(user);
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
var callbackUrl = Url.Page(
"/Account/ConfirmEmail",
pageHandler: null,
values: new { userId = userId, code = code },
protocol: Request.Scheme);
await _emailSender.SendEmailAsync(
email,
"Confirm your email",
$"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");
StatusMessage = "Verification email sent. Please check your email.";
return RedirectToPage();
}
}
}

View File

@ -0,0 +1,12 @@
@model string
@if (!String.IsNullOrEmpty(Model))
{
var statusMessageClass = Model.StartsWith("Error") ? "danger" : "success";
<div class="alert alert-@statusMessageClass alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<span id="StatusMessage">@Model</span>
</div>
}

View File

@ -0,0 +1 @@
@using coderush.Areas.Identity.Pages.Account.Manage

View File

@ -0,0 +1,3 @@
@{
Layout = "/Views/Shared/_Adminlte.cshtml";
}

View File

@ -0,0 +1,108 @@
@page
@model RegisterModel
@{
ViewData["Title"] = "Register";
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>@ViewData["Title"]</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.7 -->
<link rel="stylesheet" href="~/adminlte/components/bootstrap/dist/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="~/adminlte/components/font-awesome/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="~/adminlte/components/Ionicons/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="~/adminlte/dist/css/AdminLTE.min.css">
<!-- iCheck -->
<link rel="stylesheet" href="~/adminlte/plugins/iCheck/square/blue.css">
<!-- AdminLTE Skins. Choose a skin from the css/skins
folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet" href="~/adminlte/dist/css/skins/_all-skins.min.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Google Font -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition register-page">
<div class="register-box">
<div class="register-logo">
<a href="#">@ViewData["Title"]</a>
</div>
<div class="register-box-body">
<p class="login-box-msg">Register a new membership</p>
<form asp-route-returnUrl="@Model.ReturnUrl" method="post">
<div asp-validation-summary="All" class="text-danger"></div>
<div class="form-group has-feedback">
<input asp-for="Input.Email" type="text" class="form-control" placeholder="Email">
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input asp-for="Input.Password" type="password" class="form-control" placeholder="Password">
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input asp-for="Input.ConfirmPassword" type="password" class="form-control" placeholder="Retype password">
<span class="glyphicon glyphicon-log-in form-control-feedback"></span>
</div>
<div class="row">
<div class="col-xs-8">
<div class="checkbox icheck">
<label>
<input type="checkbox"> I agree to the <a href="#">terms</a>
</label>
</div>
</div>
<!-- /.col -->
<div class="col-xs-4">
<button type="submit" class="btn btn-primary btn-block btn-flat">Register</button>
</div>
<!-- /.col -->
</div>
</form>
<div class="social-auth-links text-center">
<p>- OR -</p>
<a href="#" class="btn btn-block btn-social btn-facebook btn-flat">
<i class="fa fa-facebook"></i> Sign up using
Facebook
</a>
<a href="#" class="btn btn-block btn-social btn-google btn-flat">
<i class="fa fa-google-plus"></i> Sign up using
Google+
</a>
</div>
<a asp-page="./Login" class="text-center">I already have a membership? Login</a>
</div>
<!-- /.form-box -->
</div>
<!-- /.register-box -->
<!-- jQuery 3 -->
<script src="~/adminlte/components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="~/adminlte/components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- iCheck -->
<script src="~/adminlte/plugins/iCheck/icheck.min.js"></script>
<script>
$(function () {
$('input').iCheck({
checkboxClass: 'icheckbox_square-blue',
radioClass: 'iradio_square-blue',
increaseArea: '20%' /* optional */
});
});</script>
</body>
</html>

View File

@ -0,0 +1,114 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using coderush.Models;
using coderush.Services.Security;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.UI.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
namespace coderush.Areas.Identity.Pages.Account
{
[AllowAnonymous]
public class RegisterModel : PageModel
{
private readonly SignInManager<IdentityUser> _signInManager;
private readonly UserManager<IdentityUser> _userManager;
private readonly ILogger<RegisterModel> _logger;
private readonly IEmailSender _emailSender;
private readonly IdentityDefaultOptions _identityDefaultOptions;
public RegisterModel(
UserManager<IdentityUser> userManager,
SignInManager<IdentityUser> signInManager,
ILogger<RegisterModel> logger,
IEmailSender emailSender,
IOptions<IdentityDefaultOptions> identityDefaultOptions
)
{
_userManager = userManager;
_signInManager = signInManager;
_logger = logger;
_emailSender = emailSender;
_identityDefaultOptions = identityDefaultOptions.Value;
}
[BindProperty]
public InputModel Input { get; set; }
public string ReturnUrl { get; set; }
public class InputModel
{
[Required]
[EmailAddress]
[Display(Name = "Email")]
public string Email { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
}
public void OnGet(string returnUrl = null)
{
ReturnUrl = returnUrl;
}
public async Task<IActionResult> OnPostAsync(string returnUrl = null)
{
//set default return url from appsettings.json
returnUrl = _identityDefaultOptions.DefaultReturnUrl;
if (ModelState.IsValid)
{
var user = new ApplicationUser { UserName = Input.Email, Email = Input.Email };
var result = await _userManager.CreateAsync(user, Input.Password);
if (result.Succeeded)
{
_logger.LogInformation("User created a new account with password.");
//Cek appsettings.json for email auto confirmed
if (_identityDefaultOptions.EmailAutoConfirmed)
{
user.EmailConfirmed = true;
await _userManager.UpdateAsync(user);
}
var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);
var callbackUrl = Url.Page(
"/Account/ConfirmEmail",
pageHandler: null,
values: new { userId = user.Id, code = code },
protocol: Request.Scheme);
await _emailSender.SendEmailAsync(Input.Email, "Confirm your email",
$"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");
await _signInManager.SignInAsync(user, isPersistent: false);
return LocalRedirect(returnUrl);
}
foreach (var error in result.Errors)
{
ModelState.AddModelError(string.Empty, error.Description);
}
}
// If we got this far, something failed, redisplay form
return Page();
}
}
}

View File

@ -0,0 +1,52 @@
@page
@model ResetPasswordModel
@{
ViewData["Title"] = "Reset password";
Layout = null;
}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title> @ViewData["Title"] </title>
<link rel="shortcut icon" href="~/assets/images/favicon.png" type="image/x-icon" />
<!-- ================== APP CSS START ================== -->
<link rel="stylesheet" href="~/assets/css/style.css" />
<!-- ================== APP CSS END ================== -->
</head>
<body>
<div class="auth-container d-flex align-items-center">
<div class="col-lg-4 mx-auto">
<h2 class="text-center mb-4">Reset your password</h2>
<div class="auth-form">
<form method="post">
<div asp-validation-summary="All" class="text-danger"></div>
<input asp-for="Input.Code" type="hidden" />
<div class="form-group">
<label asp-for="Input.Email"></label>
<input asp-for="Input.Email" class="form-control" />
</div>
<div class="form-group">
<label asp-for="Input.Password"></label>
<input asp-for="Input.Password" class="form-control" />
</div>
<div class="form-group">
<label asp-for="Input.ConfirmPassword"></label>
<input asp-for="Input.ConfirmPassword" class="form-control" />
</div>
<button type="submit" class="btn btn-primary">Reset</button>
</form>
</div>
</div>
</div>
</body>
</html>
@section Scripts {
<partial name="_ValidationScriptsPartial" />
}

View File

@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace coderush.Areas.Identity.Pages.Account
{
[AllowAnonymous]
public class ResetPasswordModel : PageModel
{
private readonly UserManager<IdentityUser> _userManager;
public ResetPasswordModel(UserManager<IdentityUser> userManager)
{
_userManager = userManager;
}
[BindProperty]
public InputModel Input { get; set; }
public class InputModel
{
[Required]
[EmailAddress]
public string Email { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
public string Code { get; set; }
}
public IActionResult OnGet(string code = null)
{
if (code == null)
{
return BadRequest("A code must be supplied for password reset.");
}
else
{
Input = new InputModel
{
Code = code
};
return Page();
}
}
public async Task<IActionResult> OnPostAsync()
{
if (!ModelState.IsValid)
{
return Page();
}
var user = await _userManager.FindByEmailAsync(Input.Email);
if (user == null)
{
// Don't reveal that the user does not exist
return RedirectToPage("./ResetPasswordConfirmation");
}
var result = await _userManager.ResetPasswordAsync(user, Input.Code, Input.Password);
if (result.Succeeded)
{
return RedirectToPage("./ResetPasswordConfirmation");
}
foreach (var error in result.Errors)
{
ModelState.AddModelError(string.Empty, error.Description);
}
return Page();
}
}
}

View File

@ -0,0 +1,59 @@
@page
@model ResetPasswordConfirmationModel
@{
ViewData["Title"] = "Reset password confirmation";
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>@ViewData["Title"]</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.7 -->
<link rel="stylesheet" href="~/adminlte/components/bootstrap/dist/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="~/adminlte/components/font-awesome/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="~/adminlte/components/Ionicons/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="~/adminlte/dist/css/AdminLTE.min.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Google Font -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition lockscreen">
<!-- Automatic element centering -->
<div class="lockscreen-wrapper">
<div class="lockscreen-logo">
<a href="/Identity/Account/Manage/Index">@ViewData["Title"]</a>
</div>
<div class="help-block text-center">
Your password has been reset.
</div>
<div class="text-center">
<a href="/Identity/Account/Login">Login</a>
</div>
<div class="lockscreen-footer text-center">
Copyright &copy; 2019 <b><a href="https://authlinq.com" class="text-black">AuthlinQ</a></b><br>
All rights reserved
</div>
</div>
<!-- /.center -->
<!-- jQuery 3 -->
<script src="~/adminlte/components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="~/adminlte/components/bootstrap/dist/js/bootstrap.min.js"></script>
</body>
</html>

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace coderush.Areas.Identity.Pages.Account
{
[AllowAnonymous]
public class ResetPasswordConfirmationModel : PageModel
{
public void OnGet()
{
}
}
}

View File

@ -0,0 +1,2 @@
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>

View File

@ -0,0 +1 @@
@using coderush.Areas.Identity.Pages.Account

View File

@ -0,0 +1,50 @@
@page
@model ErrorModel
@{
ViewData["Title"] = "Error";
}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title> @ViewData["Title"] </title>
<link rel="shortcut icon" href="~/assets/images/favicon.png" type="image/x-icon" />
<!-- ================== APP CSS START ================== -->
<link rel="stylesheet" href="~/assets/css/style.css" />
<!-- ================== APP CSS END ================== -->
</head>
<body>
<div class="error-page d-flex align-items-center bg-info">
<div class="col-lg-7 mx-auto text-white">
<div class="row text-center">
<div class="col-12">
<h1 class="display-1 mb-0 text-white">500</h1>
</div>
<div class="col-12">
<h2>SORRY!</h2>
<h3 class="font-weight-300">Internal server error!</h3>
@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}
</div>
</div>
<div class="row mt-5">
<div class="col-12 text-center mt-xl-2">
<a class="text-white font-weight-500" href="/Identity/Account/Manage/Index">Back to home</a>
</div>
</div>
<div class="row mt-5">
<div class="col-12 mt-xl-2">
<p class="text-white font-weight-500 text-center">Copyright © 2019 All rights reserved.</p>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,21 @@
using System.Diagnostics;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace coderush.Areas.Identity.Pages
{
[AllowAnonymous]
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public class ErrorModel : PageModel
{
public string RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}
}

View File

@ -0,0 +1,4 @@
@using Microsoft.AspNetCore.Identity
@using coderush.Areas.Identity
@namespace coderush.Areas.Identity.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

View File

@ -0,0 +1,3 @@
@{
Layout = "/Views/Shared/_Adminlte.cshtml";
}

View File

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Mvc;
namespace coderush.Controllers
{
//custom error controller for handling 500 and 404
[AllowAnonymous]
[Route("Error")]
public class ErrorController : Controller
{
[Route("500")]
public IActionResult AppError()
{
// Get the details of the exception that occurred
var exceptionFeature = HttpContext.Features.Get<IExceptionHandlerPathFeature>();
if (exceptionFeature != null)
{
// Get which route the exception occurred at
string routeWhereExceptionOccurred = exceptionFeature.Path;
// Get the exception that occurred
Exception exceptionThatOccurred = exceptionFeature.Error;
// Write the exception path to debug output
System.Diagnostics.Debug.WriteLine(routeWhereExceptionOccurred);
}
return View();
}
[Route("404")]
public IActionResult PageNotFound()
{
// Perform any action before serving the View
return View();
}
}
}

View File

@ -0,0 +1,191 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using coderush.Data;
using SocietyCA.NewModels;
using Microsoft.AspNetCore.Mvc.Rendering;
using coderush;
namespace SocietyCA.Controllers
{
[Authorize(Roles = coderush.Services.App.Pages.Todo.RoleName)]
public class FlatListController : Controller
{
private readonly SocietyCollectorApprovalsTESTContext _context;
public FlatListController(SocietyCollectorApprovalsTESTContext context)
{
_context = context;
}
public IActionResult Index()
{
var todos = _context.CollectorApprovalData.OrderByDescending(x => x.FlatNo).ToList();
var buildings = _context.CollectorApprovalData.Select(p => p.Building).Distinct();
List<SelectListItem> buildingsSelectListItems = new List<SelectListItem>();
foreach (var item in buildings)
{
buildingsSelectListItems.Add(new SelectListItem(item, item));
}
buildingsSelectListItems.Add(new SelectListItem("Select All", "Select All"));
ViewBag.Buildings = buildingsSelectListItems;
return View(todos);
}
//display todo create edit form
[HttpGet]
public IActionResult Form(string id)
{
var buildings = _context.CollectorApprovalData.Select(p => p.Building).Distinct();
List<SelectListItem> buildingsSelectListItems = new List<SelectListItem>();
foreach (var item in buildings)
{
buildingsSelectListItems.Add(new SelectListItem(item, item));
}
ViewBag.Buildings = buildingsSelectListItems;
//create new
if (id == null)
{
CollectorApprovalData newTodo = new CollectorApprovalData();
return View(newTodo);
}
//edit todo
CollectorApprovalData todo = new CollectorApprovalData();
todo = _context.CollectorApprovalData.Where(x => x.Id.Equals(Convert.ToInt32(id))).FirstOrDefault();
if (todo == null)
{
return NotFound();
}
return View(todo);
}
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult SubmitForm(CollectorApprovalData todoItem)
{
try
{
if (!ModelState.IsValid)
{
TempData[StaticString.StatusMessage] = "Error: Model state not valid.";
return RedirectToAction(nameof(Form), new { id = todoItem.Id.ToString() ?? "" });
}
//create new
if (todoItem.Id == 0)
{
CollectorApprovalData collectorApprovalData = new CollectorApprovalData
{
AreaSqfeet = todoItem.AreaSqfeet,
Building = todoItem.Building,
CollectorApprovalDate = todoItem.CollectorApprovalDate,
CollectorListName = todoItem.CollectorListName,
CollectorStatus = todoItem.CollectorStatus,
CombinedFlat = todoItem.CombinedFlat,
FirstName = todoItem.FirstName,
FlatNo = todoItem.FlatNo,
LastName = todoItem.LastName,
Layout = todoItem.Layout,
MiddleName = todoItem.MiddleName,
OwnershipStatus = todoItem.OwnershipStatus,
ProjectSr = todoItem.ProjectSr,
SerialNumberofCl = todoItem.SerialNumberofCl,
ShareCertificateNo = todoItem.ShareCertificateNo,
SubSociety = todoItem.SubSociety,
Type = todoItem.Type
};
_context.CollectorApprovalData.Add(collectorApprovalData);
_context.SaveChanges();
TempData[StaticString.StatusMessage] = "New member information added successfully.";
return RedirectToAction(nameof(Form));
}
//edit existing
var editedItem = _context.CollectorApprovalData
.Where(x => x.Id.Equals(todoItem.Id)).FirstOrDefault();
editedItem.AreaSqfeet = todoItem.AreaSqfeet;
editedItem.Building = todoItem.Building;
editedItem.CollectorApprovalDate = todoItem.CollectorApprovalDate;
editedItem.CollectorListName = todoItem.CollectorListName;
editedItem.CollectorStatus = todoItem.CollectorStatus;
editedItem.CombinedFlat = todoItem.CombinedFlat;
editedItem.FirstName = todoItem.FirstName;
editedItem.FlatNo = todoItem.FlatNo;
editedItem.LastName = todoItem.LastName;
editedItem.Layout = todoItem.Layout;
editedItem.MiddleName = todoItem.MiddleName;
editedItem.OwnershipStatus = todoItem.OwnershipStatus;
editedItem.ProjectSr = todoItem.ProjectSr;
editedItem.SerialNumberofCl = todoItem.SerialNumberofCl;
editedItem.ShareCertificateNo = todoItem.ShareCertificateNo;
editedItem.SubSociety = todoItem.SubSociety;
editedItem.Type = todoItem.Type;
_context.Update(editedItem);
_context.SaveChanges();
TempData[StaticString.StatusMessage] = "Member information updated successfully.";
return RedirectToAction(nameof(Form), new { id = todoItem.Id.ToString() ?? "" });
}
catch (Exception ex)
{
TempData[StaticString.StatusMessage] = "Error: " + ex.Message;
return RedirectToAction(nameof(Form), new { id = todoItem.Id.ToString() ?? "" });
}
}
//display todo item for deletion
[HttpGet]
public IActionResult Delete(string id)
{
if (id == null)
{
return NotFound();
}
var todo = _context.CollectorApprovalData.Where(x => x.Id.Equals(Convert.ToInt32(id))).FirstOrDefault();
return View(todo);
}
//delete submitted todo item if found, otherwise 404
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult SubmitDelete(CollectorApprovalData todo)
{
try
{
var deleteTodo = _context.CollectorApprovalData.Where(x => x.Id.Equals(todo.Id)).FirstOrDefault();
if (deleteTodo == null)
{
return NotFound();
}
_context.CollectorApprovalData.Remove(deleteTodo);
_context.SaveChanges();
TempData[StaticString.StatusMessage] = "Member deleted successfully.";
return RedirectToAction(nameof(Index));
}
catch (Exception ex)
{
TempData[StaticString.StatusMessage] = "Error: " + ex.Message;
return RedirectToAction(nameof(Delete), new { id = todo.Id });
}
}
}
}

View File

@ -0,0 +1,330 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using coderush.Data;
using coderush.Models;
using coderush.Services.Security;
using coderush.ViewModels;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
namespace coderush.Controllers
{
[Authorize(Roles = Services.App.Pages.Membership.RoleName)]
public class MembershipController : Controller
{
private readonly Services.Security.ICommon _security;
private readonly IdentityDefaultOptions _identityDefaultOptions;
private readonly SuperAdminDefaultOptions _superAdminDefaultOptions;
private readonly ApplicationDbContext _context;
private readonly UserManager<IdentityUser> _userManager;
//dependency injection through constructor, to directly access services
public MembershipController(
Services.Security.ICommon security,
IOptions<IdentityDefaultOptions> identityDefaultOptions,
IOptions<SuperAdminDefaultOptions> superAdminDefaultOptions,
ApplicationDbContext context,
UserManager<IdentityUser> userManager
)
{
_security = security;
_identityDefaultOptions = identityDefaultOptions.Value;
_superAdminDefaultOptions = superAdminDefaultOptions.Value;
_context = context;
_userManager = userManager;
}
public IActionResult Index()
{
List<ApplicationUser> users = new List<ApplicationUser>();
users = _security.GetAllMembers();
return View(users);
}
//display change profile screen if member founded, otherwise 404
[HttpGet]
public IActionResult ChangeProfile(string id)
{
if (id == null)
{
return NotFound();
}
IdentityUser appUser = new IdentityUser();
appUser = _security.GetMemberByApplicationId(id);
if (appUser == null)
{
return NotFound();
}
return View(appUser);
}
//post submited change profile request
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> SubmitChangeProfile([Bind("Id,EmailConfirmed,Email,PhoneNumber")] ApplicationUser applicationUser)
{
try
{
if (!ModelState.IsValid)
{
TempData[StaticString.StatusMessage] = "Error: Model state not valid.";
return RedirectToAction(nameof(ChangeProfile), new { id = applicationUser.Id });
}
ApplicationUser updatedUser = new ApplicationUser();
updatedUser = _security.GetMemberByApplicationId(applicationUser.Id);
if (updatedUser == null)
{
TempData[StaticString.StatusMessage] = "Error: Can not found the member.";
return RedirectToAction(nameof(ChangeProfile), new { id = applicationUser.Id });
}
if (_identityDefaultOptions.IsDemo && _superAdminDefaultOptions.Email.Equals(applicationUser.Email))
{
TempData[StaticString.StatusMessage] = "Error: Demo mode can not change super@admin.com data.";
return RedirectToAction(nameof(ChangeProfile), new { id = applicationUser.Id });
}
updatedUser.Email = applicationUser.Email;
updatedUser.PhoneNumber = applicationUser.PhoneNumber;
updatedUser.EmailConfirmed = applicationUser.EmailConfirmed;
_context.Update(updatedUser);
await _context.SaveChangesAsync();
TempData[StaticString.StatusMessage] = "Update success";
return RedirectToAction(nameof(ChangeProfile), new { id = updatedUser.Id});
}
catch (Exception ex)
{
TempData[StaticString.StatusMessage] = "Error: " + ex.Message;
return RedirectToAction(nameof(ChangeProfile), new { id = applicationUser.Id });
}
}
//display change password screen if user founded, otherwise 404
[HttpGet]
public IActionResult ChangePassword(string id)
{
if (id == null)
{
return NotFound();
}
var member = _security.GetMemberByApplicationId(id);
if (member == null)
{
return NotFound();
}
ResetPassword cp = new ResetPassword();
cp.Id = id;
cp.UserName = member.UserName;
return View(cp);
}
//post submitted change password request
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> SubmitChangePassword([Bind("Id,OldPassword,NewPassword,ConfirmPassword")] ResetPassword changePassword)
{
try
{
if (!ModelState.IsValid)
{
TempData[StaticString.StatusMessage] = "Error: Model state not valid.";
return RedirectToAction(nameof(ChangePassword), new { id = changePassword.Id });
}
var member = _security.GetMemberByApplicationId(changePassword.Id);
if (member == null)
{
TempData[StaticString.StatusMessage] = "Error: Can not found the member.";
return RedirectToAction(nameof(ChangePassword), new { id = changePassword.Id });
}
if (_identityDefaultOptions.IsDemo && _superAdminDefaultOptions.Email.Equals(member.Email))
{
TempData[StaticString.StatusMessage] = "Error: Demo mode can not change super@admin.com data.";
return RedirectToAction(nameof(ChangePassword), new { id = changePassword.Id });
}
var tokenResetPassword = await _userManager.GeneratePasswordResetTokenAsync(member);
var changePasswordResult = await _userManager.ResetPasswordAsync(member, tokenResetPassword, changePassword.NewPassword);
if (!changePasswordResult.Succeeded)
{
TempData[StaticString.StatusMessage] = "Error: ";
foreach (var error in changePasswordResult.Errors)
{
ModelState.AddModelError(string.Empty, error.Description);
TempData[StaticString.StatusMessage] = TempData[StaticString.StatusMessage] + " " + error.Description;
}
return RedirectToAction(nameof(ChangePassword), new { id = changePassword.Id });
}
TempData[StaticString.StatusMessage] = "Reset password success";
return RedirectToAction(nameof(ChangePassword), new { id = changePassword.Id });
}
catch (Exception ex)
{
TempData[StaticString.StatusMessage] = "Error: " + ex.Message;
return RedirectToAction(nameof(ChangePassword), new { id = changePassword.Id });
}
}
//display change role screen if user founded, otherwise 404
[HttpGet]
public async Task<IActionResult> ChangeRole(string id)
{
if (id == null)
{
return NotFound();
}
var member = _security.GetMemberByApplicationId(id);
if (member == null)
{
return NotFound();
}
var registeredRoles = await _userManager.GetRolesAsync(member);
ChangeRoles changeRole = new ChangeRoles();
changeRole.Id = id;
changeRole.UserName = member.UserName;
changeRole.IsTodoRegistered = registeredRoles.Contains("Todo") ? true : false;
changeRole.IsMembershipRegistered = registeredRoles.Contains("Membership") ? true : false;
changeRole.IsRoleRegistered = registeredRoles.Contains("Role") ? true : false;
return View(changeRole);
}
//post submitted change role request
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> SubmitChangeRole([Bind("Id", "IsTodoRegistered", "IsMembershipRegistered", "IsRoleRegistered")]ChangeRoles changeRoles)
{
try
{
if (!ModelState.IsValid)
{
TempData[StaticString.StatusMessage] = "Error: Model state not valid.";
return RedirectToAction(nameof(ChangeRole), new { id = changeRoles.Id });
}
var member = _security.GetMemberByApplicationId(changeRoles.Id);
if (member == null)
{
TempData[StaticString.StatusMessage] = "Error: Can not found the member.";
return RedirectToAction(nameof(ChangeRole), new { id = changeRoles.Id });
}
if (_identityDefaultOptions.IsDemo && _superAdminDefaultOptions.Email.Equals(member.Email))
{
TempData[StaticString.StatusMessage] = "Error: Demo mode can not change super@admin.com data.";
return RedirectToAction(nameof(ChangeRole), new { id = changeRoles.Id });
}
//todo role
if (changeRoles.IsTodoRegistered)
{
await _userManager.AddToRoleAsync(member, "Todo");
}
else
{
await _userManager.RemoveFromRoleAsync(member, "Todo");
}
//membership role
if (changeRoles.IsMembershipRegistered)
{
await _userManager.AddToRoleAsync(member, "Membership");
}
else
{
await _userManager.RemoveFromRoleAsync(member, "Membership");
}
//role role
if (changeRoles.IsRoleRegistered)
{
await _userManager.AddToRoleAsync(member, "Role");
}
else
{
await _userManager.RemoveFromRoleAsync(member, "Role");
}
TempData[StaticString.StatusMessage] = "Update success";
return RedirectToAction(nameof(ChangeRole), new { id = changeRoles.Id });
}
catch (Exception ex)
{
TempData[StaticString.StatusMessage] = "Error: " + ex.Message;
return RedirectToAction(nameof(ChangeRole), new { id = changeRoles.Id });
}
}
//display member registration screen
[HttpGet]
public IActionResult Register()
{
return View();
}
//post submitted registration request
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> SubmitRegister([Bind("EmailConfirmed,Email,PhoneNumber,Password,ConfirmPassword")] Register register)
{
try
{
if (!ModelState.IsValid)
{
TempData[StaticString.StatusMessage] = "Error: Model state not valid.";
return RedirectToAction(nameof(Register));
}
ApplicationUser newMember = new ApplicationUser();
newMember.Email = register.Email;
newMember.UserName = register.Email;
newMember.PhoneNumber = register.PhoneNumber;
newMember.EmailConfirmed = register.EmailConfirmed;
newMember.isSuperAdmin = false;
var result = await _userManager.CreateAsync(newMember, register.Password);
if (result.Succeeded)
{
TempData[StaticString.StatusMessage] = "Register new member success";
return RedirectToAction(nameof(ChangeProfile), new { id = newMember.Id });
}
else
{
TempData[StaticString.StatusMessage] = "Error: Register new member not success";
return RedirectToAction(nameof(Register));
}
}
catch (Exception ex)
{
TempData[StaticString.StatusMessage] = "Error: " + ex.Message;
return RedirectToAction(nameof(Register));
}
}
}
}

View File

@ -0,0 +1,79 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SocietyCA.Models;
using SocietyCA.NewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace SocietyCA.Controllers
{
public class ReportsController : Controller
{
private readonly SocietyCollectorApprovalsTESTContext _context;
public ReportsController(SocietyCollectorApprovalsTESTContext context)
{
_context = context;
}
public IActionResult DCHSSummary()
{
DCHSSummaryModel dCHSSummaryModel = new DCHSSummaryModel();
var buildings = _context.CollectorApprovalData.Select(p => p.Building).Distinct();
List<DCHSCounts> dCHSCounts = new List<DCHSCounts>();
DCHSCounts finalrow = new DCHSCounts();
finalrow.BuildingName = "Grand Total";
foreach (var item in buildings)
{
DCHSCounts dCHSCounts1 = new DCHSCounts();
dCHSCounts1.BuildingName = item;
dCHSCounts1.CollectorApprovedCount = _context.CollectorApprovalData
.Where(p => p.CollectorStatus == "Collector Approved" && p.Building == item).Count();
dCHSCounts1.CollectorDeclinedCount = _context.CollectorApprovalData
.Where(p => p.CollectorStatus == "Declined" && p.Building == item).Count();
dCHSCounts1.ExcessUnitCount = _context.CollectorApprovalData
.Where(p => p.CollectorStatus == "Excess Unit" && p.Building == item).Count();
dCHSCounts1.FlatCount = _context.CollectorApprovalData
.Where(p => p.Building == item).Count();
finalrow.FlatCount += dCHSCounts1.FlatCount;
finalrow.CollectorApprovedCount += dCHSCounts1.CollectorApprovedCount;
finalrow.CollectorDeclinedCount += dCHSCounts1.CollectorDeclinedCount;
finalrow.ExcessUnitCount += dCHSCounts1.ExcessUnitCount;
dCHSCounts.Add(dCHSCounts1);
}
dCHSCounts.Add(finalrow);
dCHSSummaryModel.DCHSCounts = dCHSCounts;
dCHSSummaryModel.List1Count = _context.CollectorApprovalData
.Where(p => p.CollectorListName == "Approved List - I").Count();
dCHSSummaryModel.List2Count = _context.CollectorApprovalData
.Where(p => p.CollectorListName == "Approved List - II").Count();
dCHSSummaryModel.List3Count = _context.CollectorApprovalData
.Where(p => p.CollectorListName == "Approved List - III").Count();
dCHSSummaryModel.List4Count = _context.CollectorApprovalData
.Where(p => p.CollectorListName == "Approved List - IV").Count();
dCHSSummaryModel.TotalDeclinedUnit = _context.CollectorApprovalData
.Where(p => p.CollectorStatus == "Declined").Count();
dCHSSummaryModel.TotalExcessUnit = _context.CollectorApprovalData
.Where(p => p.CollectorStatus == "Excess Unit").Count();
return View(dCHSSummaryModel);
}
}
}

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace coderush.Controllers
{
[Authorize(Roles = Services.App.Pages.Role.RoleName)]
public class RoleController : Controller
{
private readonly Services.Security.ICommon _security;
//dependency injection through constructor, to directly access services
public RoleController(Services.Security.ICommon security)
{
_security = security;
}
//consume custom security service to get all roles
public IActionResult Index()
{
List<string> roles = new List<string>();
roles = _security.GetAllRoles();
return View(roles);
}
}
}

View File

@ -0,0 +1,140 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using coderush.Data;
using coderush.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace coderush.Controllers
{
[Authorize(Roles = Services.App.Pages.Todo.RoleName)]
public class TodoController : Controller
{
private readonly ApplicationDbContext _context;
//dependency injection through constructor, to directly access services
public TodoController(ApplicationDbContext context) {
_context = context;
}
//consume db context service, display all todo items
public IActionResult Index()
{
var todos = _context.Todo.OrderByDescending(x => x.CreatedDate).ToList();
return View(todos);
}
//display todo create edit form
[HttpGet]
public IActionResult Form(string id)
{
//create new
if (id == null)
{
Todo newTodo = new Todo();
return View(newTodo);
}
//edit todo
Todo todo = new Todo();
todo = _context.Todo.Where(x => x.TodoId.Equals(id)).FirstOrDefault();
if (todo == null)
{
return NotFound();
}
return View(todo);
}
//post submitted todo data. if todo.TodoId is null then create new, otherwise edit
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult SubmitForm([Bind("TodoId", "TodoItem", "IsDone")]Todo todo)
{
try
{
if (!ModelState.IsValid)
{
TempData[StaticString.StatusMessage] = "Error: Model state not valid.";
return RedirectToAction(nameof(Form), new { id = todo.TodoId ?? "" });
}
//create new
if (todo.TodoId == null)
{
Todo newTodo = new Todo();
newTodo.TodoId = Guid.NewGuid().ToString();
newTodo.CreatedDate = DateTime.Now;
newTodo.TodoItem = todo.TodoItem;
newTodo.IsDone = todo.IsDone;
_context.Todo.Add(todo);
_context.SaveChanges();
TempData[StaticString.StatusMessage] = "Create new todo item success.";
return RedirectToAction(nameof(Form), new { id = todo.TodoId ?? "" });
}
//edit existing
Todo editTodo = new Todo();
editTodo = _context.Todo.Where(x => x.TodoId.Equals(todo.TodoId)).FirstOrDefault();
editTodo.TodoItem = todo.TodoItem;
editTodo.IsDone = todo.IsDone;
_context.Update(editTodo);
_context.SaveChanges();
TempData[StaticString.StatusMessage] = "Edit existing todo item success.";
return RedirectToAction(nameof(Form), new { id = todo.TodoId ?? "" });
}
catch (Exception ex)
{
TempData[StaticString.StatusMessage] = "Error: " + ex.Message;
return RedirectToAction(nameof(Form), new { id = todo.TodoId ?? "" });
}
}
//display todo item for deletion
[HttpGet]
public IActionResult Delete(string id)
{
if (id == null)
{
return NotFound();
}
var todo = _context.Todo.Where(x => x.TodoId.Equals(id)).FirstOrDefault();
return View(todo);
}
//delete submitted todo item if found, otherwise 404
[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult SubmitDelete([Bind("TodoId")]Todo todo)
{
try
{
var deleteTodo = _context.Todo.Where(x => x.TodoId.Equals(todo.TodoId)).FirstOrDefault();
if (deleteTodo == null)
{
return NotFound();
}
_context.Todo.Remove(deleteTodo);
_context.SaveChanges();
TempData[StaticString.StatusMessage] = "Delete todo item success.";
return RedirectToAction(nameof(Index));
}
catch (Exception ex)
{
TempData[StaticString.StatusMessage] = "Error: " + ex.Message;
return RedirectToAction(nameof(Delete), new { id = todo.TodoId ?? "" });
}
}
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Text;
using coderush.Models;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
namespace coderush.Data
{
public class ApplicationDbContext : IdentityDbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
//custom entity, override identity user with new column
public DbSet<ApplicationUser> ApplicationUser { get; set; }
//custom entity, for simple todo app
public DbSet<Todo> Todo { get; set; }
}
}

View File

@ -0,0 +1,263 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using coderush.Data;
namespace coderush.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20190711020520_initial")]
partial class initial
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.4-servicing-10062")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Name")
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex")
.HasFilter("[NormalizedName] IS NOT NULL");
b.ToTable("AspNetRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("RoleId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AccessFailedCount");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Discriminator")
.IsRequired();
b.Property<string>("Email")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed");
b.Property<bool>("LockoutEnabled");
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasMaxLength(256);
b.Property<string>("PasswordHash");
b.Property<string>("PhoneNumber");
b.Property<bool>("PhoneNumberConfirmed");
b.Property<string>("SecurityStamp");
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex")
.HasFilter("[NormalizedUserName] IS NOT NULL");
b.ToTable("AspNetUsers");
b.HasDiscriminator<string>("Discriminator").HasValue("IdentityUser");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider");
b.Property<string>("ProviderKey");
b.Property<string>("ProviderDisplayName");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("RoleId");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("LoginProvider");
b.Property<string>("Name");
b.Property<string>("Value");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("coderush.Models.Todo", b =>
{
b.Property<string>("TodoId")
.ValueGeneratedOnAdd();
b.Property<DateTime>("CreatedDate");
b.Property<bool>("IsDone");
b.Property<string>("TodoItem")
.IsRequired();
b.HasKey("TodoId");
b.ToTable("Todo");
});
modelBuilder.Entity("coderush.Models.ApplicationUser", b =>
{
b.HasBaseType("Microsoft.AspNetCore.Identity.IdentityUser");
b.Property<bool>("isSuperAdmin");
b.HasDiscriminator().HasValue("ApplicationUser");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,239 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace coderush.Migrations
{
public partial class initial : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AspNetRoles",
columns: table => new
{
Id = table.Column<string>(nullable: false),
Name = table.Column<string>(maxLength: 256, nullable: true),
NormalizedName = table.Column<string>(maxLength: 256, nullable: true),
ConcurrencyStamp = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AspNetUsers",
columns: table => new
{
Id = table.Column<string>(nullable: false),
UserName = table.Column<string>(maxLength: 256, nullable: true),
NormalizedUserName = table.Column<string>(maxLength: 256, nullable: true),
Email = table.Column<string>(maxLength: 256, nullable: true),
NormalizedEmail = table.Column<string>(maxLength: 256, nullable: true),
EmailConfirmed = table.Column<bool>(nullable: false),
PasswordHash = table.Column<string>(nullable: true),
SecurityStamp = table.Column<string>(nullable: true),
ConcurrencyStamp = table.Column<string>(nullable: true),
PhoneNumber = table.Column<string>(nullable: true),
PhoneNumberConfirmed = table.Column<bool>(nullable: false),
TwoFactorEnabled = table.Column<bool>(nullable: false),
LockoutEnd = table.Column<DateTimeOffset>(nullable: true),
LockoutEnabled = table.Column<bool>(nullable: false),
AccessFailedCount = table.Column<int>(nullable: false),
Discriminator = table.Column<string>(nullable: false),
isSuperAdmin = table.Column<bool>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Todo",
columns: table => new
{
TodoId = table.Column<string>(nullable: false),
TodoItem = table.Column<string>(nullable: false),
IsDone = table.Column<bool>(nullable: false),
CreatedDate = table.Column<DateTime>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Todo", x => x.TodoId);
});
migrationBuilder.CreateTable(
name: "AspNetRoleClaims",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
RoleId = table.Column<string>(nullable: false),
ClaimType = table.Column<string>(nullable: true),
ClaimValue = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserClaims",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
UserId = table.Column<string>(nullable: false),
ClaimType = table.Column<string>(nullable: true),
ClaimValue = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetUserClaims_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserLogins",
columns: table => new
{
LoginProvider = table.Column<string>(nullable: false),
ProviderKey = table.Column<string>(nullable: false),
ProviderDisplayName = table.Column<string>(nullable: true),
UserId = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
table.ForeignKey(
name: "FK_AspNetUserLogins_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserRoles",
columns: table => new
{
UserId = table.Column<string>(nullable: false),
RoleId = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserTokens",
columns: table => new
{
UserId = table.Column<string>(nullable: false),
LoginProvider = table.Column<string>(nullable: false),
Name = table.Column<string>(nullable: false),
Value = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
table.ForeignKey(
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_AspNetRoleClaims_RoleId",
table: "AspNetRoleClaims",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "RoleNameIndex",
table: "AspNetRoles",
column: "NormalizedName",
unique: true,
filter: "[NormalizedName] IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_AspNetUserClaims_UserId",
table: "AspNetUserClaims",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_AspNetUserLogins_UserId",
table: "AspNetUserLogins",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_AspNetUserRoles_RoleId",
table: "AspNetUserRoles",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "EmailIndex",
table: "AspNetUsers",
column: "NormalizedEmail");
migrationBuilder.CreateIndex(
name: "UserNameIndex",
table: "AspNetUsers",
column: "NormalizedUserName",
unique: true,
filter: "[NormalizedUserName] IS NOT NULL");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AspNetRoleClaims");
migrationBuilder.DropTable(
name: "AspNetUserClaims");
migrationBuilder.DropTable(
name: "AspNetUserLogins");
migrationBuilder.DropTable(
name: "AspNetUserRoles");
migrationBuilder.DropTable(
name: "AspNetUserTokens");
migrationBuilder.DropTable(
name: "Todo");
migrationBuilder.DropTable(
name: "AspNetRoles");
migrationBuilder.DropTable(
name: "AspNetUsers");
}
}
}

View File

@ -0,0 +1,261 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using coderush.Data;
namespace coderush.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
partial class ApplicationDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.4-servicing-10062")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Name")
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex")
.HasFilter("[NormalizedName] IS NOT NULL");
b.ToTable("AspNetRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("RoleId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AccessFailedCount");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Discriminator")
.IsRequired();
b.Property<string>("Email")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed");
b.Property<bool>("LockoutEnabled");
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasMaxLength(256);
b.Property<string>("PasswordHash");
b.Property<string>("PhoneNumber");
b.Property<bool>("PhoneNumberConfirmed");
b.Property<string>("SecurityStamp");
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex")
.HasFilter("[NormalizedUserName] IS NOT NULL");
b.ToTable("AspNetUsers");
b.HasDiscriminator<string>("Discriminator").HasValue("IdentityUser");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider");
b.Property<string>("ProviderKey");
b.Property<string>("ProviderDisplayName");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("RoleId");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("LoginProvider");
b.Property<string>("Name");
b.Property<string>("Value");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("coderush.Models.Todo", b =>
{
b.Property<string>("TodoId")
.ValueGeneratedOnAdd();
b.Property<DateTime>("CreatedDate");
b.Property<bool>("IsDone");
b.Property<string>("TodoItem")
.IsRequired();
b.HasKey("TodoId");
b.ToTable("Todo");
});
modelBuilder.Entity("coderush.Models.ApplicationUser", b =>
{
b.HasBaseType("Microsoft.AspNetCore.Identity.IdentityUser");
b.Property<bool>("isSuperAdmin");
b.HasDiscriminator().HasValue("ApplicationUser");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,15 @@
using Microsoft.AspNetCore.Identity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace coderush.Models
{
public partial class ApplicationUser : IdentityUser
{
//override identity user, add new column
public bool isSuperAdmin { get; set; } = false;
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace SocietyCA.Models
{
public class DCHSCounts
{
public string BuildingName { get; set; }
public int FlatCount { get; set; }
public int CollectorApprovedCount { get; set; }
public int CollectorDeclinedCount { get; set; }
public int ExcessUnitCount { get; set; }
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace SocietyCA.Models
{
public class DCHSSummaryModel
{
public List<DCHSCounts> DCHSCounts { get; set; }
public int List1Count { get; set; }
public int List2Count { get; set; }
public int List3Count { get; set; }
public int List4Count { get; set; }
public int TotalDeclinedUnit { get; set; }
public int TotalExcessUnit { get; set; }
}
}

View File

@ -0,0 +1,11 @@
using System;
namespace coderush.Models
{
public class ErrorViewModel
{
public string RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
}

20
coderush/Models/Todo.cs Normal file
View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace coderush.Models
{
//todo class entity for simple todo app example
public class Todo
{
public string TodoId { get; set; }
[Required]
[Display(Name = "Todo Item")]
public string TodoItem { get; set; }
[Display(Name = "Is Done?")]
public bool IsDone { get; set; }
public DateTime CreatedDate { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace SocietyCA.NewModels
{
public partial class AspNetRoleClaims
{
public int Id { get; set; }
public string RoleId { get; set; }
public string ClaimType { get; set; }
public string ClaimValue { get; set; }
public virtual AspNetRoles Role { get; set; }
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
namespace SocietyCA.NewModels
{
public partial class AspNetRoles
{
public AspNetRoles()
{
AspNetRoleClaims = new HashSet<AspNetRoleClaims>();
AspNetUserRoles = new HashSet<AspNetUserRoles>();
}
public string Id { get; set; }
public string Name { get; set; }
public string NormalizedName { get; set; }
public string ConcurrencyStamp { get; set; }
public virtual ICollection<AspNetRoleClaims> AspNetRoleClaims { get; set; }
public virtual ICollection<AspNetUserRoles> AspNetUserRoles { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace SocietyCA.NewModels
{
public partial class AspNetUserClaims
{
public int Id { get; set; }
public string UserId { get; set; }
public string ClaimType { get; set; }
public string ClaimValue { get; set; }
public virtual AspNetUsers User { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace SocietyCA.NewModels
{
public partial class AspNetUserLogins
{
public string LoginProvider { get; set; }
public string ProviderKey { get; set; }
public string ProviderDisplayName { get; set; }
public string UserId { get; set; }
public virtual AspNetUsers User { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
namespace SocietyCA.NewModels
{
public partial class AspNetUserRoles
{
public string UserId { get; set; }
public string RoleId { get; set; }
public virtual AspNetRoles Role { get; set; }
public virtual AspNetUsers User { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace SocietyCA.NewModels
{
public partial class AspNetUserTokens
{
public string UserId { get; set; }
public string LoginProvider { get; set; }
public string Name { get; set; }
public string Value { get; set; }
public virtual AspNetUsers User { get; set; }
}
}

View File

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
namespace SocietyCA.NewModels
{
public partial class AspNetUsers
{
public AspNetUsers()
{
AspNetUserClaims = new HashSet<AspNetUserClaims>();
AspNetUserLogins = new HashSet<AspNetUserLogins>();
AspNetUserRoles = new HashSet<AspNetUserRoles>();
AspNetUserTokens = new HashSet<AspNetUserTokens>();
}
public string Id { get; set; }
public string UserName { get; set; }
public string NormalizedUserName { get; set; }
public string Email { get; set; }
public string NormalizedEmail { get; set; }
public bool EmailConfirmed { get; set; }
public string PasswordHash { get; set; }
public string SecurityStamp { get; set; }
public string ConcurrencyStamp { get; set; }
public string PhoneNumber { get; set; }
public bool PhoneNumberConfirmed { get; set; }
public bool TwoFactorEnabled { get; set; }
public DateTimeOffset? LockoutEnd { get; set; }
public bool LockoutEnabled { get; set; }
public int AccessFailedCount { get; set; }
public string Discriminator { get; set; }
public bool? IsSuperAdmin { get; set; }
public virtual ICollection<AspNetUserClaims> AspNetUserClaims { get; set; }
public virtual ICollection<AspNetUserLogins> AspNetUserLogins { get; set; }
public virtual ICollection<AspNetUserRoles> AspNetUserRoles { get; set; }
public virtual ICollection<AspNetUserTokens> AspNetUserTokens { get; set; }
}
}

View File

@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace SocietyCA.NewModels
{
public partial class CollectorApprovalData
{
public int Id { get; set; }
[Display(Name = "Layout")]
public string Layout { get; set; }
[Display(Name = "Building")]
public string Building { get; set; }
[Display(Name = "Part of Combined Flat")]
public string CombinedFlat { get; set; }
[Display(Name = "Type")]
public string Type { get; set; }
[Display(Name = "Area in Square feets")]
public string AreaSqfeet { get; set; }
[Display(Name = "Sub Society")]
public string SubSociety { get; set; }
[Display(Name = "Flat as per Registration")]
public string FlatNo { get; set; }
[Display(Name = "Sr. of Project")]
public string ProjectSr { get; set; }
[Display(Name = "First Name")]
public string FirstName { get; set; }
[Display(Name = "Middle Name")]
public string MiddleName { get; set; }
[Display(Name = "Last Name")]
public string LastName { get; set; }
public string MfirstName { get; set; }
public string MmiddleName { get; set; }
public string MlastName { get; set; }
[Display(Name = "Serial No. of share certificates")]
public string ShareCertificateNo { get; set; }
[Display(Name = "Collector List Names")]
public string CollectorListName { get; set; }
[Display(Name = "Serial No. of list")]
public string SerialNumberofCl { get; set; }
[Display(Name = "Collector Status")]
public string CollectorStatus { get; set; }
[Display(Name = "Date of Approval")]
public string CollectorApprovalDate { get; set; }
[Display(Name = "Ownership status")]
public string OwnershipStatus { get; set; }
}
}

View File

@ -0,0 +1,203 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
namespace SocietyCA.NewModels
{
public partial class SocietyCollectorApprovalsTESTContext : DbContext
{
public SocietyCollectorApprovalsTESTContext()
{
}
public SocietyCollectorApprovalsTESTContext(DbContextOptions<SocietyCollectorApprovalsTESTContext> options)
: base(options)
{
}
public virtual DbSet<AspNetRoleClaims> AspNetRoleClaims { get; set; }
public virtual DbSet<AspNetRoles> AspNetRoles { get; set; }
public virtual DbSet<AspNetUserClaims> AspNetUserClaims { get; set; }
public virtual DbSet<AspNetUserLogins> AspNetUserLogins { get; set; }
public virtual DbSet<AspNetUserRoles> AspNetUserRoles { get; set; }
public virtual DbSet<AspNetUserTokens> AspNetUserTokens { get; set; }
public virtual DbSet<AspNetUsers> AspNetUsers { get; set; }
public virtual DbSet<CollectorApprovalData> CollectorApprovalData { get; set; }
public virtual DbSet<Todo> Todo { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
//if (!optionsBuilder.IsConfigured)
//{
// optionsBuilder.UseSqlServer("Server=.;Database=SocietyCollectorApprovalsTEST;Trusted_Connection=True;MultipleActiveResultSets=true");
//}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.HasAnnotation("ProductVersion", "2.2.6-servicing-10079");
modelBuilder.Entity<AspNetRoleClaims>(entity =>
{
entity.HasIndex(e => e.RoleId);
entity.Property(e => e.RoleId).IsRequired();
entity.HasOne(d => d.Role)
.WithMany(p => p.AspNetRoleClaims)
.HasForeignKey(d => d.RoleId);
});
modelBuilder.Entity<AspNetRoles>(entity =>
{
entity.HasIndex(e => e.NormalizedName)
.HasName("RoleNameIndex")
.IsUnique()
.HasFilter("([NormalizedName] IS NOT NULL)");
entity.Property(e => e.Id).ValueGeneratedNever();
entity.Property(e => e.Name).HasMaxLength(256);
entity.Property(e => e.NormalizedName).HasMaxLength(256);
});
modelBuilder.Entity<AspNetUserClaims>(entity =>
{
entity.HasIndex(e => e.UserId);
entity.Property(e => e.UserId).IsRequired();
entity.HasOne(d => d.User)
.WithMany(p => p.AspNetUserClaims)
.HasForeignKey(d => d.UserId);
});
modelBuilder.Entity<AspNetUserLogins>(entity =>
{
entity.HasKey(e => new { e.LoginProvider, e.ProviderKey });
entity.HasIndex(e => e.UserId);
entity.Property(e => e.UserId).IsRequired();
entity.HasOne(d => d.User)
.WithMany(p => p.AspNetUserLogins)
.HasForeignKey(d => d.UserId);
});
modelBuilder.Entity<AspNetUserRoles>(entity =>
{
entity.HasKey(e => new { e.UserId, e.RoleId });
entity.HasIndex(e => e.RoleId);
entity.HasOne(d => d.Role)
.WithMany(p => p.AspNetUserRoles)
.HasForeignKey(d => d.RoleId);
entity.HasOne(d => d.User)
.WithMany(p => p.AspNetUserRoles)
.HasForeignKey(d => d.UserId);
});
modelBuilder.Entity<AspNetUserTokens>(entity =>
{
entity.HasKey(e => new { e.UserId, e.LoginProvider, e.Name });
entity.HasOne(d => d.User)
.WithMany(p => p.AspNetUserTokens)
.HasForeignKey(d => d.UserId);
});
modelBuilder.Entity<AspNetUsers>(entity =>
{
entity.HasIndex(e => e.NormalizedEmail)
.HasName("EmailIndex");
entity.HasIndex(e => e.NormalizedUserName)
.HasName("UserNameIndex")
.IsUnique()
.HasFilter("([NormalizedUserName] IS NOT NULL)");
entity.Property(e => e.Id).ValueGeneratedNever();
entity.Property(e => e.Discriminator).IsRequired();
entity.Property(e => e.Email).HasMaxLength(256);
entity.Property(e => e.IsSuperAdmin).HasColumnName("isSuperAdmin");
entity.Property(e => e.NormalizedEmail).HasMaxLength(256);
entity.Property(e => e.NormalizedUserName).HasMaxLength(256);
entity.Property(e => e.UserName).HasMaxLength(256);
});
modelBuilder.Entity<CollectorApprovalData>(entity =>
{
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.AreaSqfeet)
.HasColumnName("AreaSQFeet")
.HasMaxLength(500);
entity.Property(e => e.Building).HasMaxLength(500);
entity.Property(e => e.CollectorApprovalDate).HasMaxLength(500);
entity.Property(e => e.CollectorListName).HasMaxLength(500);
entity.Property(e => e.CollectorStatus).HasMaxLength(500);
entity.Property(e => e.CombinedFlat).HasMaxLength(500);
entity.Property(e => e.FirstName).HasMaxLength(500);
entity.Property(e => e.FlatNo).HasMaxLength(500);
entity.Property(e => e.LastName).HasMaxLength(500);
entity.Property(e => e.Layout).HasMaxLength(500);
entity.Property(e => e.MfirstName)
.HasColumnName("MFirstName")
.HasMaxLength(500);
entity.Property(e => e.MiddleName).HasMaxLength(500);
entity.Property(e => e.MlastName)
.HasColumnName("MLastName")
.HasMaxLength(500);
entity.Property(e => e.MmiddleName)
.HasColumnName("MMiddleName")
.HasMaxLength(500);
entity.Property(e => e.OwnershipStatus).HasMaxLength(500);
entity.Property(e => e.ProjectSr)
.HasColumnName("ProjectSR")
.HasMaxLength(500);
entity.Property(e => e.SerialNumberofCl)
.HasColumnName("SerialNumberofCL")
.HasMaxLength(500);
entity.Property(e => e.ShareCertificateNo).HasMaxLength(500);
entity.Property(e => e.SubSociety).HasMaxLength(500);
entity.Property(e => e.Type).HasMaxLength(500);
});
modelBuilder.Entity<Todo>(entity =>
{
entity.Property(e => e.TodoId).ValueGeneratedNever();
entity.Property(e => e.TodoItem).IsRequired();
});
}
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
namespace SocietyCA.NewModels
{
public partial class Todo
{
public string TodoId { get; set; }
public string TodoItem { get; set; }
public bool IsDone { get; set; }
public DateTime CreatedDate { get; set; }
}
}

24
coderush/Program.cs Normal file
View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace coderush
{
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
}
}

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DeleteExistingFiles>False</DeleteExistingFiles>
<ExcludeApp_Data>False</ExcludeApp_Data>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>bin\Release\netcoreapp2.2\publish\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:54403",
"sslPort": 44346
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"coderush": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,39 @@
using Microsoft.AspNetCore.Mvc.Rendering;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace coderush
{
//custom helper for highlight selected menu
public static class HtmlHelpers
{
public static string IsSelected(this IHtmlHelper html, string controller = null, string action = null, string cssClass = null)
{
if (String.IsNullOrEmpty(cssClass))
cssClass = "active";
string currentAction = (string)html.ViewContext.RouteData.Values["action"];
string currentController = (string)html.ViewContext.RouteData.Values["controller"];
if (String.IsNullOrEmpty(controller))
controller = currentController;
if (String.IsNullOrEmpty(action))
action = currentAction;
return controller == currentController && action == currentAction ?
cssClass : String.Empty;
}
public static string PageClass(this IHtmlHelper htmlHelper)
{
string currentAction = (string)htmlHelper.ViewContext.RouteData.Values["action"];
return currentAction;
}
}
}

View File

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace coderush.Services.App
{
//static class for app pages common information
public static partial class Pages
{
public static class Todo
{
public const string ControllerName = "Todo";
public const string RoleName = "Todo";
public const string UrlDefault = "/Todo/Index";
public const string NavigationName = "Todo";
}
public static class Membership
{
public const string ControllerName = "Membership";
public const string RoleName = "Membership";
public const string UrlDefault = "/Membership/Index";
public const string NavigationName = "Membership";
}
public static class Role
{
public const string ControllerName = "Role";
public const string RoleName = "Role";
public const string UrlDefault = "/Role/Index";
public const string NavigationName = "Role";
}
public static class FlatList
{
public const string ControllerName = "FlatList";
public const string RoleName = "Todo";
public const string UrlDefault = "/FlatList/Index";
public const string NavigationName = "Collector Approvals";
}
public static class Reports
{
public const string ControllerName = "Reports";
public const string RoleName = "Todo";
public const string URLDCHSSummary = "/Reports/DCHSSummary";
public const string NavigationName = "Collector Approvals";
}
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace coderush
{
//static class to avoid magic string when call partial view name
public static class PartialView
{
public static string StatusMessage => "_StatusMessage";
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace coderush
{
//static string to avoid magic string when call temp data, view data etc..
public static class StaticString
{
public static string StatusMessage => "StatusMessage";
}
}

View File

@ -0,0 +1,43 @@
using coderush.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace coderush.Services.Database
{
//special service provided for db initialization / data seed
public class Common : ICommon
{
private readonly ApplicationDbContext _context;
private readonly Security.ICommon _security;
public Common(ApplicationDbContext context, Security.ICommon security)
{
_context = context;
_security = security;
}
public async Task Initialize()
{
try
{
_context.Database.EnsureCreated();
//check for users
if (_context.ApplicationUser.Any())
{
return; //if user is not empty, DB has been seed
}
//init app with super admin user
await _security.CreateDefaultSuperAdmin();
}
catch (Exception)
{
throw;
}
}
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace coderush.Services.Database
{
public interface ICommon
{
Task Initialize();
}
}

View File

@ -0,0 +1,151 @@
using coderush.Data;
using coderush.Models;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace coderush.Services.Security
{
//custom service provided for common user and membership activities such as get user , create user etc..
public class Common : ICommon
{
private readonly UserManager<IdentityUser> _userManager;
private readonly RoleManager<IdentityRole> _roleManager;
private readonly SuperAdminDefaultOptions _superAdminDefaultOptions;
private readonly ApplicationDbContext _context;
public Common(
UserManager<IdentityUser> userManager,
RoleManager<IdentityRole> roleManager,
IOptions<SuperAdminDefaultOptions> superAdminDefaultOptions,
ApplicationDbContext context
)
{
_userManager = userManager;
_roleManager = roleManager;
_superAdminDefaultOptions = superAdminDefaultOptions.Value;
_context = context;
}
public async Task CreateDefaultSuperAdmin()
{
try
{
ApplicationUser superAdmin = new ApplicationUser();
superAdmin = await CreateApplicationUser(
new ApplicationUser
{
Email = _superAdminDefaultOptions.Email,
UserName = _superAdminDefaultOptions.Email,
EmailConfirmed = true,
isSuperAdmin = true
}
, _superAdminDefaultOptions.Password);
//loop all the roles and then fill to SuperAdmin so he become powerfull
IdentityUser selectedUser = await _userManager.FindByEmailAsync(superAdmin.Email);
List<string> roles = new List<string>();
if (selectedUser != null)
{
foreach (var item in typeof(App.Pages).GetNestedTypes())
{
var roleName = item.Name;
if (!await _roleManager.RoleExistsAsync(roleName))
{
await _roleManager.CreateAsync(new IdentityRole(roleName));
roles.Add(roleName);
}
}
await _userManager.AddToRolesAsync(selectedUser, roles);
}
}
catch (Exception)
{
throw;
}
}
public List<String> GetAllRoles()
{
try
{
List<String> roles = new List<string>();
foreach (var item in typeof(App.Pages).GetNestedTypes())
{
var roleName = item.Name;
roles.Add(roleName);
}
return roles;
}
catch (Exception)
{
throw;
}
}
public List<ApplicationUser> GetAllMembers()
{
try
{
List<ApplicationUser> users = new List<ApplicationUser>();
users = _context.ApplicationUser.ToList();
return users;
}
catch (Exception)
{
throw;
}
}
public ApplicationUser GetMemberByApplicationId(string applicationId)
{
try
{
ApplicationUser appUser = new ApplicationUser();
appUser = _context.ApplicationUser.Where(x => x.Id.Equals(applicationId)).FirstOrDefault();
return appUser;
}
catch (Exception)
{
throw;
}
}
public async Task<ApplicationUser> CreateApplicationUser(ApplicationUser applicationUser, string password)
{
try
{
ApplicationUser appUser = new ApplicationUser();
appUser.Email = applicationUser.Email;
appUser.UserName = applicationUser.Email;
appUser.EmailConfirmed = applicationUser.EmailConfirmed;
appUser.isSuperAdmin = applicationUser.isSuperAdmin;
await _userManager.CreateAsync(appUser, password);
return appUser;
}
catch (Exception)
{
throw;
}
}
}
}

View File

@ -0,0 +1,23 @@
using coderush.Models;
using Microsoft.AspNetCore.Identity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace coderush.Services.Security
{
public interface ICommon
{
Task CreateDefaultSuperAdmin();
List<String> GetAllRoles();
List<ApplicationUser> GetAllMembers();
ApplicationUser GetMemberByApplicationId(string applicationId);
Task<ApplicationUser> CreateApplicationUser(ApplicationUser applicationUser, string password);
}
}

View File

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace coderush.Services.Security
{
//special class to capture identity options from appsettings.json
public class IdentityDefaultOptions
{
//password settings
public bool PasswordRequireDigit { get; set; }
public int PasswordRequiredLength { get; set; }
public bool PasswordRequireNonAlphanumeric { get; set; }
public bool PasswordRequireUppercase { get; set; }
public bool PasswordRequireLowercase { get; set; }
public int PasswordRequiredUniqueChars { get; set; }
//lockout settings
public double LockoutDefaultLockoutTimeSpanInMinutes { get; set; }
public int LockoutMaxFailedAccessAttempts { get; set; }
public bool LockoutAllowedForNewUsers { get; set; }
//user settings
public bool UserRequireUniqueEmail { get; set; }
public bool SignInRequireConfirmedEmail { get; set; }
//cookie settings
public bool CookieHttpOnly { get; set; }
public double CookieExpiration { get; set; }
public bool SlidingExpiration { get; set; }
//email auto confirmed
public bool EmailAutoConfirmed { get; set; }
//default return url
public string DefaultReturnUrl { get; set; }
//is demo mode or not
public bool IsDemo { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace coderush.Services.Security
{
//special class to capture super admin options from appsettings.json
public class SuperAdminDefaultOptions
{
public string Email { get; set; }
public string Password { get; set; }
}
}

17
coderush/SocietyCA.csproj Normal file
View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<UserSecretsId>aspnet-coderush-32FBA6D7-1F1A-4E19-BE2A-1C1E45E3EA2F</UserSecretsId>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<TypeScriptToolsVersion>3.3</TypeScriptToolsVersion>
<AssemblyName>SocietyCA</AssemblyName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
</ItemGroup>
</Project>

152
coderush/Startup.cs Normal file
View File

@ -0,0 +1,152 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.UI;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using coderush.Data;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using coderush.Services.Security;
using coderush.Models;
using SocietyCA.NewModels;
namespace coderush
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
options.HttpOnly = Microsoft.AspNetCore.CookiePolicy.HttpOnlyPolicy.Always;
});
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection")));
services.AddDbContext<SocietyCollectorApprovalsTESTContext>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection")));
/// Get Custom Identity Default Options
IConfigurationSection identityDefaultOptionsConfigurationSection = Configuration.GetSection("IdentityDefaultOptions");
services.Configure<IdentityDefaultOptions>(identityDefaultOptionsConfigurationSection);
var identityDefaultOptions = identityDefaultOptionsConfigurationSection.Get<IdentityDefaultOptions>();
services.AddIdentity<IdentityUser, IdentityRole>(options =>
{
// Password settings
options.Password.RequireDigit = identityDefaultOptions.PasswordRequireDigit;
options.Password.RequiredLength = identityDefaultOptions.PasswordRequiredLength;
options.Password.RequireNonAlphanumeric = identityDefaultOptions.PasswordRequireNonAlphanumeric;
options.Password.RequireUppercase = identityDefaultOptions.PasswordRequireUppercase;
options.Password.RequireLowercase = identityDefaultOptions.PasswordRequireLowercase;
options.Password.RequiredUniqueChars = identityDefaultOptions.PasswordRequiredUniqueChars;
// Lockout settings
options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(identityDefaultOptions.LockoutDefaultLockoutTimeSpanInMinutes);
options.Lockout.MaxFailedAccessAttempts = identityDefaultOptions.LockoutMaxFailedAccessAttempts;
options.Lockout.AllowedForNewUsers = identityDefaultOptions.LockoutAllowedForNewUsers;
// User settings
options.User.RequireUniqueEmail = identityDefaultOptions.UserRequireUniqueEmail;
// email confirmation require
options.SignIn.RequireConfirmedEmail = identityDefaultOptions.SignInRequireConfirmedEmail;
})
.AddDefaultUI(UIFramework.Bootstrap4)
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
// cookie settings
services.ConfigureApplicationCookie(options =>
{
// Cookie settings
options.Cookie.HttpOnly = identityDefaultOptions.CookieHttpOnly;
options.Cookie.Expiration = TimeSpan.FromDays(identityDefaultOptions.CookieExpiration);
options.SlidingExpiration = identityDefaultOptions.SlidingExpiration;
});
/// Get Custom Super Admin Default options
services.Configure<SuperAdminDefaultOptions>(Configuration.GetSection("SuperAdminDefaultOptions"));
/// Add Custom Common Security Service
services.AddTransient<Services.Security.ICommon, Services.Security.Common>();
/// Add Custom Common Database servcie
services.AddScoped<Services.Database.ICommon, Services.Database.Common>();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, Services.Database.ICommon dbInit)
{
//custom exception handling, to catch 404
app.Use(async (context, next) =>
{
await next();
if (context.Response.StatusCode == 404 && !context.Response.HasStarted)
{
string originalPath = context.Request.Path.Value;
context.Items["originalPath"] = originalPath;
context.Request.Path = "/Error/404";
await next();
}
});
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
//custom exception handling to catch error 500
app.UseExceptionHandler("/Error/500");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
//init database with custom seed data
dbInit.Initialize().Wait();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseAuthentication();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Todo}/{action=Index}/{id?}");
});
}
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace coderush.ViewModels
{
//view model for changeroles screen
public class ChangeRoles
{
public string Id { get; set; }
public string UserName { get; set; }
public bool IsTodoRegistered { get; set; }
public bool IsMembershipRegistered { get; set; }
public bool IsRoleRegistered { get; set; }
}
}

View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace coderush.ViewModels
{
//view model for register screen
public class Register
{
[Required]
[EmailAddress]
[Display(Name = "Email")]
public string Email { get; set; }
[Phone]
[Display(Name = "Phone number")]
public string PhoneNumber { get; set; }
public bool EmailConfirmed { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
}
}

View File

@ -0,0 +1,23 @@
using System.ComponentModel.DataAnnotations;
namespace coderush.ViewModels
{
//view model for reset password
public class ResetPassword
{
public string Id { get; set; }
public string UserName { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "New password")]
public string NewPassword { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm new password")]
[Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
}
}

View File

@ -0,0 +1,56 @@

@{
ViewData["Title"] = "500: Ups...";
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>@ViewData["Title"]</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.7 -->
<link rel="stylesheet" href="~/adminlte/components/bootstrap/dist/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="~/adminlte/components/font-awesome/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="~/adminlte/components/Ionicons/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="~/adminlte/dist/css/AdminLTE.min.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Google Font -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition lockscreen">
<!-- Automatic element centering -->
<div class="lockscreen-wrapper">
<div class="lockscreen-logo">
<a href="/Identity/Account/Manage/Index">@ViewData["Title"]</a>
</div>
<div class="help-block text-center">
Sorry something not right...
</div>
<div class="text-center">
<a href="/Identity/Account/Login">Or sign in as a different user</a>
</div>
<div class="lockscreen-footer text-center">
Copyright &copy; 2019 <b><a href="https://authlinq.com" class="text-black">AuthlinQ</a></b><br>
All rights reserved
</div>
</div>
<!-- /.center -->
<!-- jQuery 3 -->
<script src="~/adminlte/components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="~/adminlte/components/bootstrap/dist/js/bootstrap.min.js"></script>
</body>
</html>

View File

@ -0,0 +1,56 @@

@{
ViewData["Title"] = "404: PageNotFound";
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>@ViewData["Title"]</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.7 -->
<link rel="stylesheet" href="~/adminlte/components/bootstrap/dist/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="~/adminlte/components/font-awesome/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="~/adminlte/components/Ionicons/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="~/adminlte/dist/css/AdminLTE.min.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Google Font -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition lockscreen">
<!-- Automatic element centering -->
<div class="lockscreen-wrapper">
<div class="lockscreen-logo">
<a href="/Identity/Account/Manage/Index">@ViewData["Title"]</a>
</div>
<div class="help-block text-center">
Sorry we did not found what you looking for
</div>
<div class="text-center">
<a href="/Identity/Account/Login">Or sign in as a different user</a>
</div>
<div class="lockscreen-footer text-center">
Copyright &copy; 2019 <b><a href="https://authlinq.com" class="text-black">AuthlinQ</a></b><br>
All rights reserved
</div>
</div>
<!-- /.center -->
<!-- jQuery 3 -->
<script src="~/adminlte/components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="~/adminlte/components/bootstrap/dist/js/bootstrap.min.js"></script>
</body>
</html>

View File

@ -0,0 +1,275 @@
@model SocietyCA.NewModels.CollectorApprovalData
@{ ViewData["Title"] = "Delete Member"; }
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
@ViewData["Title"]
</h1>
<p>
@await Html.PartialAsync(PartialView.StatusMessage, TempData[StaticString.StatusMessage])
</p>
</section>
<!-- Main content -->
<section class="content">
<!-- Default box -->
<form asp-controller="FlatList" asp-action="SubmitDelete" method="post">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">Delete Member? this process is irreversible</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip"
title="Collapse">
<i class="fa fa-minus"></i>
</button>
<button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
<i class="fa fa-times"></i>
</button>
</div>
</div>
<div class="box-body">
<input type="hidden" asp-for="Id" />
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label asp-for="Layout"></label>
<select asp-for="Layout" class="form-control">
<option value="">NA</option>
<option value="DCHS-A(A-I)">DCHS-A(A-I)</option>
<option value="DCHS(L-O and O1)">DCHS(L-O and O1)</option>
<option value="DCHS-B(J-K)">DCHS-B(J-K)</option>
</select>
<span asp-validation-for="Layout" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label asp-for="Building"></label>
<select asp-for="Building"
asp-items="ViewBag.Buildings" class="form-control">
</select>
<span asp-validation-for="Building" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label asp-for="CombinedFlat"></label>
<input asp-for="CombinedFlat" class="form-control" />
<span asp-validation-for="CombinedFlat" class="text-danger"></span>
</div>
</div>
</div>
@*<div class="row">
<div class="col-md-4">
</div>
<div class="col-md-4">
</div>
<div class="col-md-4">
</div>
</div>*@
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label asp-for="Type"></label>
<input asp-for="Type" class="form-control" />
<span asp-validation-for="Type" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label asp-for="AreaSqfeet"></label>
<input asp-for="AreaSqfeet" class="form-control" />
<span asp-validation-for="AreaSqfeet" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label asp-for="SubSociety"></label>
<select asp-for="SubSociety" class="form-control">
<option value="">NA</option>
<option value="1. Panchavati Residential">1. Panchavati Residential</option>
<option value="2. Dnyaneswar Residential">2. Dnyaneswar Residential</option>
<option value="3. Panchavati Shops">3. Panchavati Shops</option>
<option value="4. Dnyaneshwar Shops (Pinnac)">4. Dnyaneshwar Shops (Pinnac)</option>
</select>
<span asp-validation-for="SubSociety" class="text-danger"></span>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label asp-for="FlatNo"></label>
<input asp-for="FlatNo" class="form-control" />
<span asp-validation-for="FlatNo" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label asp-for="ProjectSr"></label>
<input asp-for="ProjectSr" class="form-control" />
<span asp-validation-for="ProjectSr" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label asp-for="FirstName"></label>
<input asp-for="FirstName" class="form-control" />
<span asp-validation-for="FirstName" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label asp-for="MiddleName"></label>
<input asp-for="MiddleName" class="form-control" />
<span asp-validation-for="MiddleName" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label asp-for="LastName"></label>
<input asp-for="LastName" class="form-control" />
<span asp-validation-for="LastName" class="text-danger"></span>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label asp-for="ShareCertificateNo"></label>
<input asp-for="ShareCertificateNo" class="form-control" />
<span asp-validation-for="ShareCertificateNo" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label asp-for="CollectorListName"></label>
<select asp-for="CollectorListName" class="form-control">
<option value="">NA</option>
<option value="Approved List - I">Approved List - I</option>
<option value="Approved List - II">Approved List - II</option>
<option value="Approved List -III">Approved List - III</option>
<option value="Approved List -IV">Approved List - IV</option>
<option value="Duplicate Name">Duplicate Name</option>
<option value="Under PMC">Under PMC</option>
</select>
<span asp-validation-for="CollectorListName" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label asp-for="SerialNumberofCl"></label>
<input asp-for="SerialNumberofCl" class="form-control" />
<span asp-validation-for="SerialNumberofCl" class="text-danger"></span>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label asp-for="CollectorStatus"></label>
<select asp-for="CollectorStatus" class="form-control">
<option value="">NA</option>
<option value="Collector Approved">Collector Approved</option>
<option value="Declined">Declined</option>
<option value="Excess Unit">Excess Unit</option>
<option value="Not Sure">Not Sure</option>
</select>
<span asp-validation-for="CollectorStatus" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label asp-for="CollectorApprovalDate"></label>
<select asp-for="CollectorApprovalDate" class="form-control">
<option value="">NA</option>
<option value="30/01/1960">30 JAN 1960</option>
<option value="04/04/2008">04 APR 2008</option>
<option value="07/06/2008">07 JUN 2008</option>
<option value="12/06/2008">12 JUN 2008</option>
</select>
<span asp-validation-for="CollectorApprovalDate" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label asp-for="OwnershipStatus"></label>
<select asp-for="OwnershipStatus" class="form-control">
<option value="">NA</option>
<option value="Currently Residing">Currently Residing</option>
<option value="Flat sold">Flat sold</option>
</select>
<span asp-validation-for="OwnershipStatus" class="text-danger"></span>
</div>
</div>
</div>
</div>
<!-- /.box-body -->
<div class="box-footer">
<a href="/Todo/FlatList" class="btn btn-default">Back</a>
<button type="submit" class="btn btn-danger">Delete</button>
</div>
<!-- /.box-footer-->
</div>
</form>
<!-- /.box -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
@section Styles{
}
@section Scripts{
<partial name="_ValidationScriptsPartial" />
}

View File

@ -0,0 +1,298 @@
@model SocietyCA.NewModels.CollectorApprovalData
@{ ViewData["Title"] = "Member Information Form"; }
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
@ViewData["Title"]
</h1>
<p>
@await Html.PartialAsync(PartialView.StatusMessage, TempData[StaticString.StatusMessage])
</p>
</section>
<!-- Main content -->
<section class="content">
<!-- Default box -->
<form asp-controller="FlatList" asp-action="SubmitForm" method="post">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">Create or edit existing Member item</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip"
title="Collapse">
<i class="fa fa-minus"></i>
</button>
<button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
<i class="fa fa-times"></i>
</button>
</div>
</div>
<div class="box-body">
<input type="hidden" asp-for="Id" />
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label asp-for="Layout"></label>
<select asp-for="Layout" class="form-control">
<option value="">NA</option>
<option value="DCHS-A(A-I)">DCHS-A(A-I)</option>
<option value="DCHS(L-O and O1)">DCHS(L-O and O1)</option>
<option value="DCHS-B(J-K)">DCHS-B(J-K)</option>
</select>
<span asp-validation-for="Layout" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label asp-for="Building"></label>
<select asp-for="Building"
asp-items="ViewBag.Buildings" class="form-control">
</select>
<span asp-validation-for="Building" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label asp-for="CombinedFlat"></label>
<input asp-for="CombinedFlat" class="form-control" />
<span asp-validation-for="CombinedFlat" class="text-danger"></span>
</div>
</div>
</div>
@*<div class="row">
<div class="col-md-4">
</div>
<div class="col-md-4">
</div>
<div class="col-md-4">
</div>
</div>*@
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label asp-for="Type"></label>
<input asp-for="Type" class="form-control" />
<span asp-validation-for="Type" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label asp-for="AreaSqfeet"></label>
<input asp-for="AreaSqfeet" class="form-control" />
<span asp-validation-for="AreaSqfeet" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label asp-for="SubSociety"></label>
<select asp-for="SubSociety" class="form-control">
<option value="">NA</option>
<option value="1. Panchavati Residential">1. Panchavati Residential</option>
<option value="2. Dnyaneswar Residential">2. Dnyaneswar Residential</option>
<option value="3. Panchavati Shops">3. Panchavati Shops</option>
<option value="4. Dnyaneshwar Shops (Pinnac)">4. Dnyaneshwar Shops (Pinnac)</option>
</select>
<span asp-validation-for="SubSociety" class="text-danger"></span>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label asp-for="FlatNo"></label>
<input asp-for="FlatNo" class="form-control" />
<span asp-validation-for="FlatNo" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label asp-for="ProjectSr"></label>
<input asp-for="ProjectSr" class="form-control" />
<span asp-validation-for="ProjectSr" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label asp-for="FirstName"></label>
<input asp-for="FirstName" class="form-control" />
<span asp-validation-for="FirstName" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label asp-for="MiddleName"></label>
<input asp-for="MiddleName" class="form-control" />
<span asp-validation-for="MiddleName" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label asp-for="LastName"></label>
<input asp-for="LastName" class="form-control" />
<span asp-validation-for="LastName" class="text-danger"></span>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label asp-for="ShareCertificateNo"></label>
<input asp-for="ShareCertificateNo" class="form-control" />
<span asp-validation-for="ShareCertificateNo" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label asp-for="CollectorListName"></label>
<select asp-for="CollectorListName" id="collectorListId" class="form-control">
<option value="">NA</option>
<option value="Approved List - I">Approved List - I</option>
<option value="Approved List - II">Approved List - II</option>
<option value="Approved List - III">Approved List - III</option>
<option value="Approved List - IV">Approved List - IV</option>
<option value="Duplicate Name">Duplicate Name</option>
<option value="Under PMC">Under PMC</option>
</select>
<span asp-validation-for="CollectorListName" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label asp-for="SerialNumberofCl"></label>
<input asp-for="SerialNumberofCl" class="form-control" />
<span asp-validation-for="SerialNumberofCl" class="text-danger"></span>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label asp-for="CollectorStatus"></label>
<select asp-for="CollectorStatus" class="form-control">
<option value="">NA</option>
<option value="Collector Approved">Collector Approved</option>
<option value="Declined">Declined</option>
<option value="Excess Unit">Excess Unit</option>
<option value="Not Sure">Not Sure</option>
</select>
<span asp-validation-for="CollectorStatus" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label asp-for="CollectorApprovalDate"></label>
<select asp-for="CollectorApprovalDate" id="CollectorApprovalDateID"
class="form-control">
<option value="">NA</option>
<option value="30/01/1960">30 JAN 1960</option>
<option value="04/04/2008">04 APR 2008</option>
<option value="07/06/2008">07 JUN 2008</option>
<option value="12/06/2007">12 JUN 2007</option>
</select>
<span asp-validation-for="CollectorApprovalDate" class="text-danger"></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label asp-for="OwnershipStatus"></label>
<select asp-for="OwnershipStatus" class="form-control">
<option value="">NA</option>
<option value="Currently Residing">Currently Residing</option>
<option value="Flat sold">Flat sold</option>
</select>
<span asp-validation-for="OwnershipStatus" class="text-danger"></span>
</div>
</div>
</div>
</div>
<!-- /.box-body -->
<div class="box-footer">
<a href="/FlatList/Index" class="btn btn-default">Back</a>
<button type="submit" class="btn btn-primary">Save</button>
</div>
<!-- /.box-footer-->
</div>
</form>
<!-- /.box -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
@section Styles{
}
@section Scripts{
<partial name="_ValidationScriptsPartial" />
<script type="text/javascript">
$("#collectorListId").change(function () {
var value = $('#collectorListId :selected').text();
if (value == 'Approved List - I') {
$('#CollectorApprovalDateID').val('04/04/2008');
} else if (value == 'Approved List - II') {
$('#CollectorApprovalDateID').val('07/06/2008');
} else if (value == 'Approved List - III') {
$('#CollectorApprovalDateID').val('12/06/2007');
} else if (value == 'Approved List - IV') {
$('#CollectorApprovalDateID').val('30/01/1960');
} else {
$('#CollectorApprovalDateID').val('');
}
});
</script>
}

View File

@ -0,0 +1,161 @@
@model List<SocietyCA.NewModels.CollectorApprovalData>
@{ ViewData["Title"] = "Dyaneshwar Soc"; }
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
@ViewData["Title"]
</h1>
<p>
@await Html.PartialAsync(PartialView.StatusMessage, TempData[StaticString.StatusMessage])
</p>
</section>
<!-- Main content -->
<section class="content">
<!-- Default box -->
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">List of all Society Members</h3>
<div class="box-tools pull-right">
<a href="/FlatList/Form" class="btn btn-primary"><i class="fa fa-plus"></i></a>
</div>
</div>
<div class="box-body">
<div class="row">
<div class="form-group col-md-4">
<label>Enter Building</label>
@*<input type="text" id="building" class="form-control" />*@
<select id="building"
asp-items="ViewBag.Buildings" class="form-control">
</select>
</div>
</div>
<div class="row col-md-12">
<div class="table-responsive">
<table id="gridFlat" class="table table-striped" cellspacing="0" width="100%">
<thead>
<tr>
<th width="5%">Edit</th>
@*<th width="5%">Delete</th>*@
<th width="5%">Building</th>
<th width="10%">Sub Soc.</th>
<th width="10%">Flat No.</th>
<th width="10%">First Name</th>
<th width="10%">Last Name</th>
<th width="15%">Collector List</th>
<th width="10%">List Sr.No</th>
<th width="15%">Share Cert. No</th>
<th width="15%">Collector Status</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
<a href="/FlatList/Form/@item.Id"><i class="fa fa-edit"></i></a>
</td>
@*<td>
<a href="/FlatList/Delete/@item.Id"><i class="fa fa-trash"></i></a>
</td>*@
<td>@item.Building</td>
<td>@item.SubSociety</td>
<td>@item.FlatNo</td>
<td>@item.FirstName</td>
<td>@item.LastName</td>
<td>@item.CollectorListName</td>
<td>@item.SerialNumberofCl</td>
<td>@item.ShareCertificateNo</td>
<td>@item.CollectorStatus</td>
</tr>
}
</tbody>
</table>
</div>
</div>
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
@section Styles{
<!-- DataTables -->
<link rel="stylesheet" href="~/adminlte/components/datatables.net-bs/css/dataTables.bootstrap.min.css">
}
@section Scripts{
<!-- DataTables -->
<script src="~/adminlte/components/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="~/adminlte/components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.1.0/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.1.0/js/buttons.html5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
<!-- page script -->
<script type="text/javascript">
$(document).ready(function () {
$.fn.dataTable.ext.search.push(
function (settings, data, dataIndex) {
var min = $('#building').val();
var buildingname = data[1];
if (min == 'Select All') {
return true;
}
if (buildingname.toLowerCase() == min.toLowerCase()) {
return true;
} else {
return false;
}
if (isNullOrEmpty(min)) {
return true;
}
return false;
}
);
var table = $('#gridFlat').DataTable({
lengthChange: true,
dom: 'Bfrtip',
info: true,
scrollX: false,
pageLength: 10,
"filter": true,
deferRender: true,
"searching": true,
buttons: [
'excelHtml5'
]
});
$('#building').change(function () {
table.draw();
});
});</script>
}

View File

@ -0,0 +1,76 @@
@model ResetPassword
@{
ViewData["Title"] = "Change Password";
}
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
@ViewData["Title"]
</h1>
<p>
@await Html.PartialAsync(PartialView.StatusMessage, TempData[StaticString.StatusMessage])
</p>
</section>
<!-- Main content -->
<section class="content">
<!-- Default box -->
<form asp-controller="Membership" asp-action="SubmitChangePassword" method="post">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">Reset member password</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip"
title="Collapse">
<i class="fa fa-minus"></i>
</button>
<button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
<i class="fa fa-times"></i>
</button>
</div>
</div>
<div class="box-body">
<input type="hidden" asp-for="Id" />
<div class="form-group">
<label asp-for="UserName"></label>
<input asp-for="UserName" class="form-control" disabled />
</div>
<div class="form-group">
<label asp-for="NewPassword"></label>
<input asp-for="NewPassword" class="form-control" />
<span asp-validation-for="NewPassword" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="ConfirmPassword"></label>
<input asp-for="ConfirmPassword" class="form-control" />
<span asp-validation-for="ConfirmPassword" class="text-danger"></span>
</div>
</div>
<!-- /.box-body -->
<div class="box-footer">
<a href="/Membership/Index" class="btn btn-default">Back</a>
<button type="submit" class="btn btn-primary">Update password</button>
</div>
<!-- /.box-footer-->
</div>
</form>
<!-- /.box -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
@section Styles{
}
@section Scripts{
<partial name="_ValidationScriptsPartial" />
}

View File

@ -0,0 +1,84 @@
@using Microsoft.AspNetCore.Identity
@model IdentityUser
@{
ViewData["Title"] = "Change Profile";
}
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
@ViewData["Title"]
</h1>
<p>
@await Html.PartialAsync(PartialView.StatusMessage, TempData[StaticString.StatusMessage])
</p>
</section>
<!-- Main content -->
<section class="content">
<!-- Default box -->
<form asp-controller="Membership" asp-action="SubmitChangeProfile" method="post">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">Change member profile</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip"
title="Collapse">
<i class="fa fa-minus"></i>
</button>
<button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
<i class="fa fa-times"></i>
</button>
</div>
</div>
<div class="box-body">
<input type="hidden" asp-for="Id" />
<div class="form-group">
<label asp-for="UserName"></label>
<input asp-for="UserName" class="form-control" disabled />
</div>
<div class="form-group">
<label asp-for="Email"></label>
<input asp-for="Email" class="form-control" />
<span asp-validation-for="Email" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="PhoneNumber"></label>
<input asp-for="PhoneNumber" class="form-control" />
<span asp-validation-for="PhoneNumber" class="text-danger"></span>
</div>
<div class="form-group">
<input asp-for="EmailConfirmed" type="checkbox" class="flat-red" />
<label> Active</label>
</div>
</div>
<!-- /.box-body -->
<div class="box-footer">
<a href="/Membership/Index" class="btn btn-default">Back</a>
<button type="submit" class="btn btn-primary">Save</button>
</div>
<!-- /.box-footer-->
</div>
</form>
<!-- /.box -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
@section Styles{
}
@section Scripts{
<partial name="_ValidationScriptsPartial" />
}

View File

@ -0,0 +1,105 @@
@model ChangeRoles
@{
ViewData["Title"] = "Change Role";
}
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
@ViewData["Title"]
</h1>
<p>
@await Html.PartialAsync(PartialView.StatusMessage, TempData[StaticString.StatusMessage])
</p>
</section>
<!-- Main content -->
<section class="content">
<!-- Default box -->
<form asp-controller="Membership" asp-action="SubmitChangeRole" method="post">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">Change member roles</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip"
title="Collapse">
<i class="fa fa-minus"></i>
</button>
<button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
<i class="fa fa-times"></i>
</button>
</div>
</div>
<div class="box-body">
<input type="hidden" asp-for="Id" />
<div class="form-group">
<label asp-for="UserName"></label>
<input asp-for="UserName" class="form-control" disabled />
</div>
<div class="table-responsive">
<table class="table" cellspacing="0" width="100%">
<thead>
<tr>
<th width="60%">Role Name</th>
<th width="40%">Is Role Registered</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<label class="label label-success">Todo</label>
</td>
<td>
<input class="flat-red" asp-for="IsTodoRegistered">
</td>
</tr>
<tr>
<td>
<label class="label label-success">Membership</label>
</td>
<td>
<input class="flat-red" asp-for="IsMembershipRegistered">
</td>
</tr>
<tr>
<td>
<label class="label label-success">Role</label>
</td>
<td>
<input class="flat-red" asp-for="IsRoleRegistered">
</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- /.box-body -->
<div class="box-footer">
<a href="/Membership/Index" class="btn btn-default">Back</a>
<button type="submit" class="btn btn-primary">Save</button>
</div>
<!-- /.box-footer-->
</div>
</form>
<!-- /.box -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
@section Styles{
}
@section Scripts{
<partial name="_ValidationScriptsPartial" />
}

View File

@ -0,0 +1,124 @@

@model List<ApplicationUser>
@{
ViewData["Title"] = "Membership";
}
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
@ViewData["Title"]
</h1>
<p>
@await Html.PartialAsync(PartialView.StatusMessage, TempData[StaticString.StatusMessage])
</p>
</section>
<!-- Main content -->
<section class="content">
<!-- Default box -->
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">List of member</h3>
<div class="box-tools pull-right">
<a href="/Membership/Register" class="btn btn-primary"><i class="fa fa-plus"></i></a>
</div>
</div>
<div class="box-body">
<div class="table-responsive">
<table id="grid" class="table table-striped" cellspacing="0" width="100%">
<thead>
<tr>
<th width="10%"></th>
<th width="25%">Member Email</th>
<th width="25%">Phone Number</th>
<th width="10%">Status</th>
<th width="20%">Super Admin?</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
<div class="btn-group">
<div class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="/Membership/ChangeProfile/@item.Id">Change Profile</a></li>
<li><a href="/Membership/ChangePassword/@item.Id">Reset Password</a></li>
<li><a href="/Membership/ChangeRole/@item.Id">Change Role</a></li>
</ul>
</div>
</div>
</td>
<td>@item.Email</td>
<td>@item.PhoneNumber</td>
<td>
<span class="label label-@(item.EmailConfirmed ? "success" : "danger")">@(item.EmailConfirmed ? "Active" : "Pending")</span>
</td>
<td>
<input type="checkbox" class="flat-red" @(item.isSuperAdmin ? "checked" : "") onclick="return false;">
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
@section Styles{
<!-- DataTables -->
<link rel="stylesheet" href="~/adminlte/components/datatables.net-bs/css/dataTables.bootstrap.min.css">
}
@section Scripts{
<!-- DataTables -->
<script src="~/adminlte/components/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="~/adminlte/components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
<!-- page script -->
<script type="text/javascript">
$(document).ready(function () {
$('#grid').DataTable({
lengthChange: false,
info: false,
searching: true,
dom: 'lrtip',
scrollX: false,
pageLength: 5,
});
});
</script>
}

View File

@ -0,0 +1,90 @@
@using coderush.ViewModels
@model Register
@{
ViewData["Title"] = "Register";
}
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
@ViewData["Title"]
</h1>
<p>
@await Html.PartialAsync(PartialView.StatusMessage, TempData[StaticString.StatusMessage])
</p>
</section>
<!-- Main content -->
<section class="content">
<!-- Default box -->
<form asp-controller="Membership" asp-action="SubmitRegister" method="post">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">Register new member</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip"
title="Collapse">
<i class="fa fa-minus"></i>
</button>
<button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
<i class="fa fa-times"></i>
</button>
</div>
</div>
<div class="box-body">
<div class="form-group">
<label asp-for="Email"></label>
<input asp-for="Email" class="form-control" />
<span asp-validation-for="Email" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="PhoneNumber"></label>
<input asp-for="PhoneNumber" class="form-control" />
<span asp-validation-for="PhoneNumber" class="text-danger"></span>
</div>
<div class="form-group">
<input asp-for="EmailConfirmed" type="checkbox" class="flat-red" />
<label> Active</label>
</div>
<div class="form-group">
<label asp-for="Password"></label>
<input asp-for="Password" class="form-control" />
<span asp-validation-for="Password" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="ConfirmPassword"></label>
<input asp-for="ConfirmPassword" class="form-control" />
<span asp-validation-for="ConfirmPassword" class="text-danger"></span>
</div>
</div>
<!-- /.box-body -->
<div class="box-footer">
<a href="/Membership/Index" class="btn btn-default">Back</a>
<button type="submit" class="btn btn-primary">Save</button>
</div>
<!-- /.box-footer-->
</div>
</form>
<!-- /.box -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
@section Styles{
}
@section Scripts{
<partial name="_ValidationScriptsPartial" />
}

View File

@ -0,0 +1,178 @@
@model SocietyCA.Models.DCHSSummaryModel
@{ ViewData["Title"] = "Dyaneshwar Soc"; }
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
@ViewData["Title"]
</h1>
<p>
@await Html.PartialAsync(PartialView.StatusMessage, TempData[StaticString.StatusMessage])
</p>
</section>
<!-- Main content -->
<section class="content">
<!-- Default box -->
<div class="box">
<div class="box-header with-border">
@*<h3 class="box-title">DCHS Membership Summary </h3>*@
@*<div class="box-tools pull-right">
<a href="/FlatList/Form" class="btn btn-primary"><i class="fa fa-plus"></i></a>
</div>*@
</div>
<div class="box-body">
<div class="row col-md-12" style="text-align:center;">
<h3 class="box-title">DCHS Membership Summary </h3>
</div>
<div class="row">
<div class="col-md-1">
</div>
<div class="col-md-10" style="text-align:center;">
<div class="table-responsive">
<table id="gridFlat" class="table table-striped" cellspacing="0" width="60%">
<thead>
<tr>
<th width="20%">Building Name</th>
<th width="15%">Flat Count</th>
<th width="15%">Collector Approved</th>
<th width="15%">Collector Declined</th>
<th width="15%">Excess Units</th>
<th width="20%">Total</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.DCHSCounts)
{
<tr>
<td>@item.BuildingName</td>
<td>@item.FlatCount</td>
<td>@item.CollectorApprovedCount</td>
<td>@item.CollectorDeclinedCount</td>
<td>@item.ExcessUnitCount</td>
<td>@(item.CollectorApprovedCount + item.CollectorDeclinedCount + item.ExcessUnitCount)</td>
</tr>}
</tbody>
</table>
</div>
</div>
</div>
<div class="row col-md-12" style="text-align:center;">
<h3 class="box-title">Collector Approved List Count </h3>
</div>
<div class="row">
<div class="col-md-2">
</div>
<div class="col-md-8">
<div class="table-responsive" style="text-align:center;">
<table id="gridFlat" class="table table-striped" cellspacing="0" width="100%">
<thead>
<tr>
<th width="15%">Collector Approved Lists</th>
<th width="15%">List Count</th>
<th width="15%">As per Database</th>
</tr>
</thead>
<tbody>
<tr>
<td>List 1 - Additional Members</td>
<td>258</td>
<td>@Model.List1Count</td>
</tr>
<tr>
<td>List 2 - Additional Members</td>
<td>135</td>
<td>@Model.List2Count</td>
</tr>
<tr>
<td>List 3 - Additional Members</td>
<td>82</td>
<td>@Model.List3Count</td>
</tr>
<tr>
<td>List 4 - Original Members</td>
<td>40</td>
<td>@Model.List4Count</td>
</tr>
<tr>
<td>TOTAL of Memberships</td>
<td>515</td>
<td>@(Model.List4Count + Model.List1Count + Model.List2Count + Model.List3Count)</td>
</tr>
<tr>
<td>TOTAL Declined Units</td>
<td></td>
<td>@Model.TotalDeclinedUnit</td>
</tr>
<tr>
<td>TOTAL Excess Units</td>
<td></td>
<td>@Model.TotalExcessUnit</td>
</tr>
<tr style="font-weight:bold;">
<td>Grand Total</td>
<td></td>
<td>@(Model.List4Count + Model.List1Count + Model.List2Count + Model.List3Count + Model.TotalExcessUnit + Model.TotalDeclinedUnit)</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
@section Styles{
<style>
tr:last-child {
font-weight: bold;
}
th {
text-align: center;
}
td:first-child {
text-align: left;
}
th:first-child {
text-align: left;
}
</style>
}
@section Scripts{
}

View File

@ -0,0 +1,102 @@
@model List<string>
@{
ViewData["Title"] = "Role";
}
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
@ViewData["Title"]
</h1>
<p>
@await Html.PartialAsync(PartialView.StatusMessage, TempData[StaticString.StatusMessage])
</p>
</section>
<!-- Main content -->
<section class="content">
<!-- Default box -->
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">List of role</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip"
title="Collapse">
<i class="fa fa-minus"></i>
</button>
<button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
<i class="fa fa-times"></i>
</button>
</div>
</div>
<div class="box-body">
<div class="table-responsive">
<table id="grid" class="table table-striped" cellspacing="0" width="100%">
<thead>
<tr>
<th width="100%">Role Name</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
<label class="label label-success">@item</label>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
@section Styles{
<!-- DataTables -->
<link rel="stylesheet" href="~/adminlte/components/datatables.net-bs/css/dataTables.bootstrap.min.css">
}
@section Scripts{
<!-- DataTables -->
<script src="~/adminlte/components/datatables.net/js/jquery.dataTables.min.js"></script>
<script src="~/adminlte/components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
<!-- page script -->
<script type="text/javascript">
$(document).ready(function () {
$('#grid').DataTable({
lengthChange: false,
info: false,
searching: true,
dom: 'lrtip',
scrollX: false,
pageLength: 5,
});
});
</script>
}

View File

@ -0,0 +1,103 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>@ViewData["Title"] - Dnyaneshwar Hos. Soc.</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!-- Bootstrap 3.3.7 -->
<link rel="stylesheet" href="~/adminlte/components/bootstrap/dist/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="~/adminlte/components/font-awesome/css/font-awesome.min.css">
<!-- iCheck for checkboxes and radio inputs -->
<link rel="stylesheet" href="~/adminlte/plugins/iCheck/all.css">
<!-- Toastr -->
<link rel="stylesheet" href="~/adminlte/plugins/toastr/toastr.min.css" />
<!-- Ionicons -->
<link rel="stylesheet" href="~/adminlte/components/Ionicons/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="~/adminlte/dist/css/AdminLTE.min.css">
<!-- AdminLTE Skins. Choose a skin from the css/skins
folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet" href="~/adminlte/dist/css/skins/_all-skins.min.css">
<!-- Pace style -->
<link rel="stylesheet" href="~/adminlte/plugins/pace/pace.min.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- Google Font -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
@RenderSection("Styles", required: false)
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
@await Html.PartialAsync("_AdminlteMainHeader")
<!-- Left side column. contains the logo and sidebar -->
@await Html.PartialAsync("_AdminlteMainSidebar")
<!-- Content Wrapper. Contains page content -->
@RenderBody()
<!-- /.content-wrapper -->
@await Html.PartialAsync("_AdminlteFooter")
</div>
<!-- ./wrapper -->
<!-- jQuery 3 -->
<script src="~/adminlte/components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="~/adminlte/components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- PACE -->
<script src="~/adminlte/components/PACE/pace.min.js"></script>
<!-- Slimscroll -->
<script src="~/adminlte/components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="~/adminlte/components/fastclick/lib/fastclick.js"></script>
<!-- iCheck 1.0.1 -->
<script src="~/adminlte/plugins/iCheck/icheck.min.js"></script>
<!-- Toastr -->
<script src="~/adminlte/plugins/toastr/toastr.min.js"></script>
<!-- AdminLTE App -->
<script src="~/adminlte/dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="~/adminlte/dist/js/demo.js"></script>
<script src="~/js/site.js"></script>
<script type="text/javascript">
$(document).ready(function () {
//for green iCheck
$('input[type="checkbox"].flat-red, input[type="radio"].flat-red').iCheck({
checkboxClass: 'icheckbox_flat-green',
radioClass: 'iradio_flat-green'
})
//toastr message
var message = $("#StatusMessage").text();
if (message) {
if (message.includes("Error")) {
//error
toastr.error(message);
} else {
//success
toastr.success(message)
}
}
});
</script>
@RenderSection("Scripts", required: false)
</body>
</html>

View File

@ -0,0 +1,168 @@
<aside class="control-sidebar control-sidebar-dark">
<!-- Create the tabs -->
<ul class="nav nav-tabs nav-justified control-sidebar-tabs">
<li><a href="#control-sidebar-home-tab" data-toggle="tab"><i class="fa fa-home"></i></a></li>
<li><a href="#control-sidebar-settings-tab" data-toggle="tab"><i class="fa fa-gears"></i></a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<!-- Home tab content -->
<div class="tab-pane" id="control-sidebar-home-tab">
<h3 class="control-sidebar-heading">Recent Activity</h3>
<ul class="control-sidebar-menu">
<li>
<a href="javascript:void(0)">
<i class="menu-icon fa fa-birthday-cake bg-red"></i>
<div class="menu-info">
<h4 class="control-sidebar-subheading">Langdon's Birthday</h4>
<p>Will be 23 on April 24th</p>
</div>
</a>
</li>
<li>
<a href="javascript:void(0)">
<i class="menu-icon fa fa-user bg-yellow"></i>
<div class="menu-info">
<h4 class="control-sidebar-subheading">Frodo Updated His Profile</h4>
<p>New phone +1(800)555-1234</p>
</div>
</a>
</li>
<li>
<a href="javascript:void(0)">
<i class="menu-icon fa fa-envelope-o bg-light-blue"></i>
<div class="menu-info">
<h4 class="control-sidebar-subheading">Nora Joined Mailing List</h4>
<p>nora@example.com</p>
</div>
</a>
</li>
<li>
<a href="javascript:void(0)">
<i class="menu-icon fa fa-file-code-o bg-green"></i>
<div class="menu-info">
<h4 class="control-sidebar-subheading">Cron Job 254 Executed</h4>
<p>Execution time 5 seconds</p>
</div>
</a>
</li>
</ul>
<!-- /.control-sidebar-menu -->
<h3 class="control-sidebar-heading">Tasks Progress</h3>
<ul class="control-sidebar-menu">
<li>
<a href="javascript:void(0)">
<h4 class="control-sidebar-subheading">
Custom Template Design
<span class="label label-danger pull-right">70%</span>
</h4>
<div class="progress progress-xxs">
<div class="progress-bar progress-bar-danger" style="width: 70%"></div>
</div>
</a>
</li>
<li>
<a href="javascript:void(0)">
<h4 class="control-sidebar-subheading">
Update Resume
<span class="label label-success pull-right">95%</span>
</h4>
<div class="progress progress-xxs">
<div class="progress-bar progress-bar-success" style="width: 95%"></div>
</div>
</a>
</li>
<li>
<a href="javascript:void(0)">
<h4 class="control-sidebar-subheading">
Laravel Integration
<span class="label label-warning pull-right">50%</span>
</h4>
<div class="progress progress-xxs">
<div class="progress-bar progress-bar-warning" style="width: 50%"></div>
</div>
</a>
</li>
<li>
<a href="javascript:void(0)">
<h4 class="control-sidebar-subheading">
Back End Framework
<span class="label label-primary pull-right">68%</span>
</h4>
<div class="progress progress-xxs">
<div class="progress-bar progress-bar-primary" style="width: 68%"></div>
</div>
</a>
</li>
</ul>
<!-- /.control-sidebar-menu -->
</div>
<!-- /.tab-pane -->
<!-- Stats tab content -->
<div class="tab-pane" id="control-sidebar-stats-tab">Stats Tab Content</div>
<!-- /.tab-pane -->
<!-- Settings tab content -->
<div class="tab-pane" id="control-sidebar-settings-tab">
<form method="post">
<h3 class="control-sidebar-heading">General Settings</h3>
<div class="form-group">
<label class="control-sidebar-subheading">
Report panel usage
<input type="checkbox" class="pull-right" checked>
</label>
<p>
Some information about this general settings option
</p>
</div>
<!-- /.form-group -->
<div class="form-group">
<label class="control-sidebar-subheading">
Allow mail redirect
<input type="checkbox" class="pull-right" checked>
</label>
<p>
Other sets of options are available
</p>
</div>
<!-- /.form-group -->
<div class="form-group">
<label class="control-sidebar-subheading">
Expose author name in posts
<input type="checkbox" class="pull-right" checked>
</label>
<p>
Allow the user to show his name in blog posts
</p>
</div>
<!-- /.form-group -->
<h3 class="control-sidebar-heading">Chat Settings</h3>
<div class="form-group">
<label class="control-sidebar-subheading">
Show me as online
<input type="checkbox" class="pull-right" checked>
</label>
</div>
<!-- /.form-group -->
<div class="form-group">
<label class="control-sidebar-subheading">
Turn off notifications
<input type="checkbox" class="pull-right">
</label>
</div>
<!-- /.form-group -->
<div class="form-group">
<label class="control-sidebar-subheading">
Delete chat history
<a href="javascript:void(0)" class="text-red pull-right"><i class="fa fa-trash-o"></i></a>
</label>
</div>
<!-- /.form-group -->
</form>
</div>
<!-- /.tab-pane -->
</div>
</aside>
<!-- /.control-sidebar -->
<!-- Add the sidebar's background. This div must be placed
immediately after the control sidebar -->
<div class="control-sidebar-bg"></div>

View File

@ -0,0 +1,6 @@
<footer class="main-footer">
<div class="pull-right hidden-xs">
<b>Version</b> 1.0.0
</div>
<strong>AuthlinQ &copy; 2019 <a href="https://authlinq.com">AuthlinQ</a>.</strong>
</footer>

View File

@ -0,0 +1,74 @@
@using Microsoft.AspNetCore.Identity
@inject UserManager<IdentityUser> _userManager
@{
var email = "";
var user = await _userManager.GetUserAsync(User);
if (user != null)
{
email = user.Email;
}
}
<header class="main-header">
<!-- Logo -->
<a href="/Identity/Account/Manage/Index" class="logo">
<!-- mini logo for sidebar mini 50x50 pixels -->
<span class="logo-mini"><b>D</b>H</span>
<!-- logo for regular state and mobile devices -->
<span class="logo-lg"><b>Dnyane</b>shwar</span>
</a>
<!-- Header Navbar: style can be found in header.less -->
<nav class="navbar navbar-static-top">
<!-- Sidebar toggle button-->
<a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
<span class="sr-only">Toggle navigation</span>
</a>
<div class="navbar-custom-menu">
<ul class="nav navbar-nav">
<!-- User Account: style can be found in dropdown.less -->
<li class="dropdown user user-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img src="~/adminlte/dist/img/user2-160x160.jpg" class="user-image" alt="User Image">
<span class="hidden-xs">@email</span>
</a>
<ul class="dropdown-menu">
<!-- User image -->
<li class="user-header">
<img src="~/adminlte/dist/img/user2-160x160.jpg" class="img-circle" alt="User Image">
<p>
@email
</p>
</li>
<!-- Menu Body -->
<li class="user-body">
<div class="row">
<div class="col-xs-6 text-center">
<a href="/Identity/Account/Manage/Index">Change Profile</a>
</div>
<div class="col-xs-6 text-center">
<a href="/Identity/Account/Manage/ChangePassword">Change Password</a>
</div>
</div>
<!-- /.row -->
</li>
<!-- Menu Footer-->
<li class="user-footer">
<div class="pull-left">
</div>
<div class="pull-right">
<form id="formSignout" asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="@Url.Action("Index", "Todo")">
<a class="btn btn-default btn-flat" href="javascript:void(0)" onclick="document.getElementById('formSignout').submit();">
Sign Out
</a>
</form>
</div>
</li>
</ul>
</li>
</ul>
</div>
</nav>
</header>

View File

@ -0,0 +1,91 @@
@using Microsoft.AspNetCore.Identity
@inject UserManager<IdentityUser> _userManager
@{ var email = "";
var user = await _userManager.GetUserAsync(User);
if (user != null)
{
email = user.Email;
} }
<aside class="main-sidebar">
<!-- sidebar: style can be found in sidebar.less -->
<section class="sidebar">
<!-- Sidebar user panel -->
<div class="user-panel">
<div class="pull-left image">
<img src="~/adminlte/dist/img/user2-160x160.jpg" height="30" width="30" class="img-circle" alt="User Image">
</div>
<div class="pull-left info">
<p>@email</p>
<a href="#"><i class="fa fa-circle text-success"></i> Online</a>
</div>
</div>
<!-- search form -->
<form action="#" method="get" class="sidebar-form">
<div class="input-group">
<input type="text" name="q" class="form-control" placeholder="Search...">
<span class="input-group-btn">
<button type="submit" name="search" id="search-btn" class="btn btn-flat">
<i class="fa fa-search"></i>
</button>
</span>
</div>
</form>
<!-- /.search form -->
<!-- sidebar menu: : style can be found in sidebar.less -->
<ul class="sidebar-menu" data-widget="tree">
<li class="header">Data Inputs</li>
@*<li class="@Html.IsSelected(controller: Pages.Todo.ControllerName)">
<a href="@Pages.Todo.UrlDefault">
<i class="fa fa-th"></i> <span>@Pages.Todo.NavigationName</span>
<span class="pull-right-container">
<small class="label pull-right bg-green">List</small>
</span>
</a>
</li>*@
<li class="@Html.IsSelected(controller: Pages.FlatList.ControllerName)">
<a href="@Pages.FlatList.UrlDefault">
<i class="fa fa-th"></i> <span>@Pages.FlatList.NavigationName</span>
<span class="pull-right-container">
<small class="label pull-right bg-green">List</small>
</span>
</a>
</li>
<li class="@Html.IsSelected(controller: Pages.Membership.ControllerName)">
<a href="@Pages.Membership.UrlDefault">
<i class="fa fa-th"></i> <span>@Pages.Membership.NavigationName</span>
<span class="pull-right-container">
<small class="label pull-right bg-green">List</small>
</span>
</a>
</li>
<li class="@Html.IsSelected(controller: Pages.Role.ControllerName)">
<a href="@Pages.Role.UrlDefault">
<i class="fa fa-th"></i> <span>@Pages.Role.NavigationName</span>
<span class="pull-right-container">
<small class="label pull-right bg-green">List</small>
</span>
</a>
</li>
<li class="header">Reports</li>
<li>
<a href="@Pages.Reports.URLDCHSSummary">
<i class="fa fa-th"></i> <span>DCHS Membership Summary</span>
</a>
</li>
@*<li class="@Html.IsSelected(controller: Pages.Reports.ControllerName)">
<a href="@Pages.Reports.URLDCHSSummary">
<i class="fa fa-th"></i> <span>DCHS Membership Summary</span>
</a>
</li>
<li class="@Html.IsSelected(controller: Pages.Reports.ControllerName)">
<a href="@Pages.Reports.URLDCHSSummary">
<i class="fa fa-th"></i> <span>DCHS Membership Summary</span>
</a>
</li>*@
</ul>
</section>
<!-- /.sidebar -->
</aside>

Some files were not shown because too many files have changed in this diff Show More