Initial commit

This commit is contained in:
amoussa1229 2024-09-28 14:58:36 -04:00
commit 69b9e69f00
612 changed files with 235620 additions and 0 deletions

63
.gitattributes vendored Normal file
View file

@ -0,0 +1,63 @@
###############################################################################
# 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

364
.gitignore vendored Normal file
View file

@ -0,0 +1,364 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.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
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# 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
# Note: 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
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable 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
*.appx
*.appxbundle
*.appxupload
# 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
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# 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
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# 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/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
/SeaHavenIndustries/wwwroot/ChromeEx/Win_x64_1000083_chrome-win/chrome-win

View file

@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "8.0.8",
"commands": [
"dotnet-ef"
],
"rollForward": false
}
}
}

View file

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.8" />
<PackageReference Include="SendGrid" Version="9.29.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Data.SeaHavenIndustries\Data.SeaHavenIndustries.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,6 @@
@Api.SeaHavenIndustries_HostAddress = http://localhost:5141
GET {{Api.SeaHavenIndustries_HostAddress}}/weatherforecast/
Accept: application/json
###

View file

@ -0,0 +1,253 @@
using Data.SeaHavenIndustries;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.IdentityModel.Tokens;
using System.IdentityModel.Tokens.Jwt;
using System.Net.Mail;
using System.Net;
using System.Security.Claims;
using System.Text;
using Api.SeaHavenIndustries.DTOs;
using Microsoft.EntityFrameworkCore;
using System.Diagnostics;
namespace Api.SeaHavenIndustries.Controllers
{
[ApiController]
[Route("[controller]")]
public class AuthenticationController : Controller
{
private readonly UserManager<ApplicationUser> _userManager;
private readonly IConfiguration _configuration;
private readonly ApplicationDbContext _db;
public AuthenticationController(UserManager<ApplicationUser> userManager, IConfiguration configuration, ApplicationDbContext db, IWebHostEnvironment webHostEnvironment, IHttpContextAccessor httpContext)
{
_userManager = userManager;
_configuration = configuration;
_db = db;
}
[AllowAnonymous]
[HttpPost]
[Route("login")]
public async Task<IActionResult> Login([FromBody] LoginModel model)
{
var user = await _userManager.FindByNameAsync(model.Username ?? "");
if (user.IsDeleted != true && user != null && await _userManager.CheckPasswordAsync(user, model.Password ?? ""))
{
// Standard login without 2FA
var userRoles = await _userManager.GetRolesAsync(user);
var authClaims = new List<Claim>
{
new Claim(ClaimTypes.Name, user.UserName ?? ""),
new Claim(ClaimTypes.NameIdentifier, user.Id),
new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString())
};
foreach (var userRole in userRoles)
{
authClaims.Add(new Claim(ClaimTypes.Role, userRole));
}
var token = GetToken(authClaims);
return Ok(new
{
token = new JwtSecurityTokenHandler().WriteToken(token),
expiration = token.ValidTo,
email = user.Email,
userRoles = userRoles.FirstOrDefault(),
phoneNumber = user.PhoneNumber,
fullname = user.FirstName + " " + user.LastName,
id = user.Id
});
}
// Invalid credentials
return Unauthorized();
}
[Route("ChangePassword")]
[HttpPost]
public async Task<IActionResult> ChangePassword(ChangePasswords usermodel)
{
var userid = User.FindFirstValue(ClaimTypes.NameIdentifier) ?? "";
var user = await _userManager.FindByIdAsync(userid);
var result = await _userManager.ChangePasswordAsync(user, usermodel.Currentpassword ?? "", usermodel.Confirmpassword ?? "");
if (result.Succeeded)
{
return Ok(new Response { Status = "Success ", Message = "Password successfully changed" });
}
else
return BadRequest(new Response { Status = "Old Password is incorrect" });
}
private JwtSecurityToken GetToken(List<Claim> authClaims)
{
var authSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_configuration["JWT:Secret"] ?? ""));
var token = new JwtSecurityToken(
issuer: _configuration["JWT:ValidIssuer"],
audience: _configuration["JWT:ValidAudience"],
expires: DateTime.Now.AddDays(10),
claims: authClaims,
signingCredentials: new SigningCredentials(authSigningKey, SecurityAlgorithms.HmacSha256)
);
return token;
}
[HttpPost]
[Route("UpdateProfile")]
public async Task<IActionResult> UserProfileUpdate([FromForm] User_DTO model)
{
try
{
var userid = User.FindFirstValue(ClaimTypes.NameIdentifier) ?? "";
ApplicationUser appuser = _db.Users.AsNoTracking().Where(u => u.Id == userid).FirstOrDefault() ?? new ApplicationUser();
appuser.FirstName = model.Name;
appuser.Email = model.Email;
appuser.Contact = model.Contact;
_db.Users.Update(appuser);
await _db.SaveChangesAsync();
return Ok(new DataResponse
{
Message = "Introduction Updated Successfully",
Status = "200",
Data = _db.Users.Where(u => u.Id == userid).Select(s => new
{
s.FirstName,
//s.Location,
s.Email,
s.Contact
}).FirstOrDefault()
});
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
#region Forget Password Area
[AllowAnonymous]
[HttpPost()]
[Route("ForgetPassword")]
public async Task<IActionResult> ForgetPassword(string Email)
{
var user = await _db.Users.Where(u => u.Email.ToLower().Trim() == Email.ToLower().ToLower()).FirstOrDefaultAsync();
if (user != null)
{
if (_db.ForgetPasswordCodes.Where(u => u.Email.ToLower().Trim() == Email.ToLower().Trim()).Any())
{
_db.ForgetPasswordCodes.Remove(_db.ForgetPasswordCodes.Where(u => u.Email.ToLower().Trim() == Email.ToLower().Trim()).FirstOrDefault());
_db.SaveChanges();
}
ForgetPasswordCode forgetPasswordCode = new ForgetPasswordCode();
forgetPasswordCode.Email = user.Email ?? "";
forgetPasswordCode.UserId = user.Id;
forgetPasswordCode.Code = GenerateRandomNo();
_db.ForgetPasswordCodes.Add(forgetPasswordCode);
_db.SaveChanges();
string body = $"Your Password Reset Code is: " + forgetPasswordCode.Code;
SendEMail(user.Email, "Forget Password Request.", body);
return Ok(new Response { Status = "Success ", Message = "Please check your email for code" });
}
else
{
return BadRequest(new Response { Status = "Error", Message = "No such email is registered" });
}
}
//need email and code
[AllowAnonymous]
[HttpPost()]
[Route("VerificationCode")]
public async Task<IActionResult> VerificationCode(string code)
{
try
{
if (await _db.ForgetPasswordCodes.Where(u => u.Code == code).AnyAsync())
{
return Ok(new Response { Status = "Success ", Message = "Code Matched" });
}
else
{
return BadRequest(new Response { Status = "Error", Message = "Code Not Matched" });
}
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = "Error: " + ex.Message });
}
}
// need email, password and code
[AllowAnonymous]
[HttpPost()]
[Route("ResetPassword")]
public async Task<IActionResult> ResetPassword(ForgetPassword_Dto fpdto)
{
try
{
if (_db.ForgetPasswordCodes.Where(u => u.Email.ToLower().Trim() == fpdto.Email.ToLower().Trim() && u.Code == fpdto.Code.Trim()).Any())
{
var GetUser = _db.ForgetPasswordCodes.Where(u => u.Email.ToLower().Trim() == fpdto.Email.ToLower().Trim()).FirstOrDefault();
var user = await _userManager.FindByIdAsync(GetUser.UserId);
var token = await _userManager.GeneratePasswordResetTokenAsync(user);
var result = await _userManager.ResetPasswordAsync(user, token, fpdto.Password);
return Ok(new Response { Status = "Success ", Message = "password changed" });
}
else
{
return BadRequest(new Response { Status = "Error", Message = "Your email or code not found please check" });
}
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = "Error: " + ex.Message });
}
}
[HttpGet()]
public bool SendEMail(string emailid, string subject, string body)
{
try
{
MailMessage mail = new MailMessage();
mail.From = new MailAddress("infoesquall@codevoir.com"); //IMPORTANT: This must be same as your smtp authentication address.
mail.To.Add(emailid);
//set the content
mail.Subject = subject;
mail.Body = body;
mail.IsBodyHtml = true;
//send the message
SmtpClient smtp = new SmtpClient("mail.codevoir.com");
//IMPORANT: Your smtp login email MUST be same as your FROM address.
NetworkCredential Credentials = new NetworkCredential("infoesquall@codevoir.com", "Abc123!@#");
smtp.UseDefaultCredentials = false;
smtp.Credentials = Credentials;
smtp.Port = 8889; //25 alternative port number is 8889
smtp.EnableSsl = false;
smtp.Send(mail);
return true;
}
catch (Exception ex)
{
return false;
}
}
private Random _random = new Random();
private string GenerateRandomNo()
{
return _random.Next(0, 9999).ToString("D4");
}
#endregion
}
}

View file

@ -0,0 +1,136 @@
using Api.SeaHavenIndustries.DTOs;
using Api.SeaHavenIndustries.Helper.ViewModel;
using Data.SeaHavenIndustries;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
namespace Api.SeaHavenIndustries.Controllers
{
[Authorize]
[ApiController]
[Route("[controller]")]
public class CommonController : Controller
{
private readonly UserManager<ApplicationUser> _userManager;
private readonly ApplicationDbContext _db;
public CommonController(UserManager<ApplicationUser> userManager, ApplicationDbContext db)
{
_userManager = userManager;
_db = db;
}
[HttpGet]
[Route("GetUsers")]
public async Task<IActionResult> GetUsers(string? search = "", int page = 1, int pageSize = 10)
{
try
{
var allUsersQuery = _db.Users
.Where(w => w.FirstName.ToLower().Contains(search.ToLower()))
.OrderByDescending(d => d.Id);
var totalCount = allUsersQuery.Count();
var paginatedUsers = allUsersQuery
.Skip((page - 1) * pageSize)
.Take(pageSize)
.ToList();
// Calculate the number of pages
var totalPages = (int)Math.Ceiling(totalCount / (double)pageSize);
var filteredUsers = new List<UserRoleViewModel>();
foreach (var user in paginatedUsers)
{
var roles = await _userManager.GetRolesAsync(user);
if (!roles.Contains("Admin"))
{
filteredUsers.Add(new UserRoleViewModel
{
RoleName = roles.Count()>0?roles.First():"",
Email = user.Email,
UserName = user.FirstName,
Date = user.CreatedDate?.Date.ToString(),
Status = user.UniqueName,
Id = user.Id
});
}
}
// Create a view model containing the paged items and pagination metadata
var viewModel = new Pagination_DTO
{
Data = filteredUsers,
PageNumber = page,
PageSize = pageSize,
TotalCount = totalCount,
TotalPages = totalPages
};
return Ok(viewModel);
}
catch (Exception ex)
{
return BadRequest(new { Status = "Error", Message = ex.Message });
}
}
[HttpGet]
[Route("GetRoles")]
public async Task<IActionResult> GetRoles()
{
try
{
var data = await _db.Roles.Select(s => new {Id=s.Name,s.Name}).ToListAsync();
return Ok(data);
}
catch (Exception ex)
{
return BadRequest(new { Status = "Error", Message = ex.Message });
}
}
[HttpGet]
[Route("GetSitesName")]
public async Task<IActionResult> GetSiteName()
{
var data =await _db.Locations.Select(n=> new
{
n.Id,
n.Name,
n.Title
}).ToListAsync();
return Ok(data);
}
[HttpGet]
[Route("GetContacts")]
public async Task<IActionResult> GetContacts()
{
var data =await _db.Contacts.Select(n=> new
{
n.Id,
n.Name,
email=n.Email,
phone=n.PhoneNumber
}).ToListAsync();
return Ok(data);
}
[HttpGet]
[Route("GetCategories")]
public async Task<IActionResult> GetCategories()
{
var data = await _db.Categories.Select(s=> new
{
s.Id,
s.Name
}).ToListAsync();
return Ok(data);
}
}
}

View file

@ -0,0 +1,211 @@
using Api.SeaHavenIndustries.DTOs;
using Data.SeaHavenIndustries;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace Api.SeaHavenIndustries.Controllers
{
[Authorize]
[ApiController]
[Route("[controller]")]
public class ContactController : Controller
{
private readonly UserManager<ApplicationUser> _userManager;
private readonly ApplicationDbContext _db;
public ContactController(UserManager<ApplicationUser> userManager, ApplicationDbContext db)
{
_userManager = userManager;
_db = db;
}
[HttpPost]
[Route("AddContacts")]
public async Task<IActionResult> AddContacts(Contact_DTO contacts)
{
try
{
Contacts model = new Contacts();
model.Name = contacts.Name;
model.PhoneNumber = contacts.PhoneNumber;
model.Email = contacts.Email;
_db.Contacts.Add(model);
await _db.SaveChangesAsync();
return Ok(new DataResponse { Message = "Updated Successfully", Status = "200" });
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
[HttpPost]
[Route("EditContacts")]
public async Task<IActionResult> EditContacts(EditContact_DTO contacts)
{
try
{
var exist = _db.Contacts.Where(w => w.Id == contacts.Id).FirstOrDefault();
exist.Name = contacts.Name;
exist.PhoneNumber = contacts.PhoneNumber;
exist.Email = contacts.Email;
_db.Contacts.Update(exist);
await _db.SaveChangesAsync();
return Ok(new DataResponse { Message = "Updated Successfully", Status = "200" });
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
[HttpGet]
[Route("DeleteContacts")]
public async Task<IActionResult> DeleteContacts(int id)
{
try
{
var exist = _db.Contacts.Where(w => w.Id == id).FirstOrDefault();
if (exist != null)
{
_db.Remove(exist);
}
else
{
return BadRequest(new Response { Status = "Error", Message = "ID not matched!" });
}
await _db.SaveChangesAsync();
return Ok(new DataResponse { Message = "Removed Successfully", Status = "200" });
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
[HttpGet]
[Route("GetContactList")]
public IActionResult GetContactList(string? search ="", int page = 1, int pageSize = 10)
{
var totalCount = _db.Contacts.Count();
var data = _db.Contacts.Where(s=> s.Name.ToLower().Contains(search.ToLower()) || s.Email.ToLower().Contains(search.ToLower()) || s.PhoneNumber.Contains(search.ToLower())).Select(n => new
{
n.Id,
n.Name,
email = n.Email,
phone = n.PhoneNumber
}).OrderByDescending(d => d.Id).ToList().Skip((page - 1) * pageSize)
.Take(pageSize);
// Calculate the number of pages
var totalPages = (int)Math.Ceiling(totalCount / (double)pageSize);
// Create a view model containing the paged items and pagination metadata
var viewModel = new Pagination_DTO
{
Data = data,
PageNumber = page,
PageSize = pageSize,
TotalCount = totalCount,
TotalPages = totalPages
};
return Ok(viewModel);
}
[HttpPost]
[Route("AddLocation")]
public async Task<IActionResult> AddLocation(Location_DTO model)
{
try
{
Locations locations = new Locations();
locations.Title = model.Title;
locations.Name = model.Name;
_db.Locations.Add(locations);
await _db.SaveChangesAsync();
return Ok(new DataResponse { Message = "Updated Successfully", Status = "200" });
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
[HttpPost]
[Route("EditLocation")]
public async Task<IActionResult> EditLocation(EditLocation_DTO model)
{
try
{
var exist = _db.Locations.Where(w => w.Id == model.Id).FirstOrDefault();
if (exist != null)
{
exist.Title = model.Title;
exist.Name = model.Name;
}
else
{
return BadRequest(new Response { Status = "Error", Message = "ID not matched!" });
}
_db.Locations.Update(exist);
await _db.SaveChangesAsync();
return Ok(new DataResponse { Message = "Updated Successfully", Status = "200" });
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
[HttpPost]
[Route("DeleteLocation")]
public async Task<IActionResult> DeleteLocation(int Id)
{
try
{
var data1 = await _db.Templates.ToListAsync();
_db.Templates.RemoveRange(data1);
var data = await _db.Locations.Where(w => w.Id == Id).FirstOrDefaultAsync();
if (data != null)
{
_db.Locations.Remove(data ?? new Locations());
}
else
{
return BadRequest(new Response { Status = "Error", Message = "ID not matched!" });
}
await _db.SaveChangesAsync();
return Ok(new DataResponse { Message = "Updated Successfully", Status = "200" });
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
[HttpGet]
[Route("GetAddressbook")]
public IActionResult GetAddressbook(string? search = "", int page = 1, int pageSize = 10)
{
var totalCount = _db.Locations.Count();
var data = _db.Locations.Where(w=> w.Name.ToLower().Contains(search.ToLower()) || w.Title.ToLower().Contains(search.ToLower())).Select(n => new
{
n.Id,
n.Name,
n.Title
}).OrderByDescending(d => d.Id).ToList().Skip((page - 1) * pageSize)
.Take(pageSize);
// Calculate the number of pages
var totalPages = (int)Math.Ceiling(totalCount / (double)pageSize);
// Create a view model containing the paged items and pagination metadata
var viewModel = new Pagination_DTO
{
Data = data,
PageNumber = page,
PageSize = pageSize,
TotalCount = totalCount,
TotalPages = totalPages
};
return Ok(viewModel);
}
}
}

View file

@ -0,0 +1,249 @@
using Api.SeaHavenIndustries.DTOs;
using Data.SeaHavenIndustries;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using System.Linq;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace Api.SeaHavenIndustries.Controllers
{
[Authorize]
[ApiController]
[Route("[controller]")]
public class QuotesController : Controller
{
private readonly UserManager<ApplicationUser> _userManager;
private readonly ApplicationDbContext _db;
private readonly IWebHostEnvironment _webHostEnvironment;
IHttpContextAccessor _httpContext;
public QuotesController(UserManager<ApplicationUser> userManager, ApplicationDbContext db, IWebHostEnvironment webHostEnvironment, IHttpContextAccessor httpContext)
{
_userManager = userManager;
_db = db;
_webHostEnvironment = webHostEnvironment;
_httpContext = httpContext;
}
[HttpPost]
[Route("AddQuote")]
public async Task<IActionResult> AddQuote([FromBody] Quote_DTO model)
{
try
{
Quotes quotes = new Quotes();
quotes.QuotId = model.QuotId;
quotes.ContactId = model.ContactId;
quotes.PO = model.PO;
quotes.TT = model.TT;
quotes.ProjectName = model.ProjectName;
quotes.Date = DateTime.Parse(model.Date);
quotes.WorkorderId = model.WorkorderId;
quotes.SiteName = model.SiteName;
quotes.SiteId = model.SiteId;
quotes.BillingAddress = model.BillingAddress;
quotes.LineItems = quotes.LineItems == null ? new List<QuotesLineItems>() : quotes.LineItems;
if (model.LineItems != null && model.LineItems.Any())
{
foreach (var lineItemDto in model.LineItems)
{
QuotesLineItems lineItem = new QuotesLineItems()
{
LineitemNumber = lineItemDto.LineitemNumber,
Lineitem = lineItemDto.Lineitem,
Descriptions = lineItemDto.Descriptions
};
quotes.LineItems.Add(lineItem);
}
}
_db.Quotes.Add(quotes);
await _db.SaveChangesAsync();
return Ok(new DataResponse { Message = "Updated Successfully", Status = "200" });
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
[HttpPost]
[Route("EditQuote")]
public async Task<IActionResult> EditQuote([FromBody] EditQuote_DTO model)
{
try
{
var quotes = _db.Quotes.Where(w => w.Id == model.id).FirstOrDefault();
if (quotes != null)
{
quotes.QuotId = model.QuotId;
quotes.ContactId = model.ContactId;
quotes.PO = model.PO;
quotes.TT = model.TT;
quotes.ProjectName = model.ProjectName;
quotes.Date = DateTime.Parse(model.Date);
quotes.WorkorderId = model.WorkorderId;
quotes.SiteName = model.SiteName;
quotes.SiteId = model.SiteId;
quotes.BillingAddress = model.BillingAddress;
var existQuoteLine = _db.QuotesLines.Where(w => w.QuoteId == model.id).ToList();
if (existQuoteLine.Count() > 0)
{
_db.QuotesLines.RemoveRange(existQuoteLine);
}
quotes.LineItems = quotes.LineItems == null ? new List<QuotesLineItems>() : quotes.LineItems;
if (model.LineItems != null && model.LineItems.Any())
{
foreach (var lineItemDto in model.LineItems)
{
QuotesLineItems lineItem = new QuotesLineItems()
{
LineitemNumber = lineItemDto.LineitemNumber,
Lineitem = lineItemDto.Lineitem,
Descriptions = lineItemDto.Descriptions
};
quotes.LineItems.Add(lineItem);
}
}
_db.Update(quotes);
}
else
{
return BadRequest("ID not matched!");
}
await _db.SaveChangesAsync();
return Ok(new DataResponse { Message = "Updated Successfully", Status = "200" });
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
[HttpGet]
[Route("DeleteQuote")]
public IActionResult DeleteQuote(int id)
{
try
{
var data = _db.Quotes.Where(w => w.Id == id).FirstOrDefault();
if (data != null)
{
var existlineitem = _db.QuotesLines.Where(w => w.QuoteId == id).ToList();
if (existlineitem.Any())
{
_db.QuotesLines.RemoveRange(existlineitem);
}
_db.Quotes.Remove(data);
}
else
{
return BadRequest("ID not matched!");
}
_db.SaveChanges();
return Ok(new DataResponse { Message = "Removed Successfully", Status = "200" });
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
[HttpGet]
[Route("GetQuoutes")]
public IActionResult GetQuotes(string search = "", int page = 1, int pageSize = 10)
{
var totalCount = _db.Quotes.Count();
var data = _db.Quotes.Include(s => s.WorkOrder).AsNoTracking().Where(w => w.QuotId.ToLower().Contains(search.ToLower()) || w.SiteName.ToLower().Contains(search.ToLower()) || w.WorkOrder.WorkerOrderTitle.ToLower().Contains(search.ToLower())).Select(s => new
{
s.Id,
QuoteId = "QO-" + s.QuotId,
WOID = s.WorkOrder != null ? s.WorkOrder.WorkerOrderNumber : "",
s.ProjectName,
TotalAmount = "$" + s.LineItems.Sum(s => s.Lineitem.Value).ToString(),
siteName = s.SiteName,
status = s.Status
}).OrderByDescending(d => d.Id).ToList().Skip((page - 1) * pageSize)
.Take(pageSize);
// Calculate the number of pages
var totalPages = (int)Math.Ceiling(totalCount / (double)pageSize);
// Create a view model containing the paged items and pagination metadata
var viewModel = new Pagination_DTO
{
Data = data,
PageNumber = page,
PageSize = pageSize,
TotalCount = totalCount,
TotalPages = totalPages
};
return Ok(viewModel);
}
[HttpGet]
[Route("GetQuoutesdetailsAgainstWorkOrder")]
public async Task<IActionResult> GetQuoutesdetailsAgainstWorkOrder(int woId)
{
var data = await _db.workOrders.Include(s => s.Locations).Where(w => w.Id == woId).Select(s => new
{
s.Id,
s.PO,
s.TT,
s.Locations.Title,
s.Locations.Name
}).ToListAsync();
return Ok(data);
}
[HttpGet]
[Route("GetQuoutesById")]
public async Task<IActionResult> GetQuoutesById(int id)
{
var data = await _db.Quotes.Where(s => s.Id == id).Include(s => s.WorkOrder).Select(s => new
{
s.Id,
s.QuotId,
s.Date,
s.Contacts.Name,
s.PO,
s.TT,
s.SiteName,
s.ProjectName,
s.SiteId,
s.BillingAddress,
s.ShippingAddress,
lineitems = s.LineItems.Select(q => new { q.Descriptions, q.Lineitem }),
TotalAmount = "$" + s.LineItems.Sum(s => s.Lineitem.Value).ToString()
}).FirstOrDefaultAsync();
return Ok(data);
}
[HttpGet]
[Route("GetReporting")]
public async Task<IActionResult> GetReporting()
{
var totalCreatedWorkOrder = await _db.workOrders.CountAsync();
var totalCompleted = _db.workOrders.Count(w => w.Status == "Done");
var totalSev1 = _db.workOrders.Count(w => w.Priority == "Sev 1");
var totalSev2 = _db.workOrders.Count(w => w.Priority == "Sev 2");
var totalSev3 = _db.workOrders.Count(w => w.Priority == "Sev 3");
var totalSev4 = _db.workOrders.Count(w => w.Priority == "Sev 4");
var totalSev5 = _db.workOrders.Count(w => w.Priority == "Sev 5");
var data = new Reporting_DTO
{
TotalCreatedWorkOrder = totalCreatedWorkOrder,
TotalCompleted = totalCompleted,
TotalSev1 = totalSev1,
TotalSev2 = totalSev2,
TotalSev3 = totalSev3,
TotalSev4 = totalSev4,
TotalSev5 = totalSev5
};
return Ok(data);
}
}
}

View file

@ -0,0 +1,239 @@
using Api.SeaHavenIndustries.DTOs;
using Api.SeaHavenIndustries.Helper.ViewModel;
using Data.SeaHavenIndustries;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace Api.SeaHavenIndustries.Controllers
{
[Authorize]
[ApiController]
[Route("[controller]")]
public class SettingsController : Controller
{
private readonly UserManager<ApplicationUser> _userManager;
private readonly ApplicationDbContext _db;
public SettingsController(UserManager<ApplicationUser> userManager, ApplicationDbContext db)
{
_userManager = userManager;
_db = db;
}
[HttpPost]
[Route("AddCategory")]
public async Task<IActionResult> AddCategory(Category_DTO model)
{
try
{
Category category = new Category();
category.Name = model.Name;
_db.Categories.Add(category);
await _db.SaveChangesAsync();
return Ok(new DataResponse { Message = "Successfully Saved Data", Status = "200" });
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
[HttpPost]
[Route("EditCategory")]
public async Task<IActionResult> EditCategory(EditCategory_DTO model)
{
try
{
var exist = _db.Categories.Where(w => w.Id == model.Id).FirstOrDefault();
exist.Name = model.Name;
_db.Categories.Update(exist);
await _db.SaveChangesAsync();
return Ok(new DataResponse { Message = "Updated Successfully", Status = "200" });
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
[HttpGet]
[Route("DeleteCategory")]
public async Task<IActionResult> DeleteCategory(int id)
{
try
{
var exist = _db.Categories.Where(w => w.Id == id).FirstOrDefault();
if (exist != null)
{
var chkexist = _db.Templates.Where(w => w.CategoryId == id).ToList();
if (chkexist != null)
{
_db.RemoveRange(chkexist);
}
var chkworkordercategory = _db.workOrderCategories.Where(w => w.CategoryId == id).ToList();
if (chkworkordercategory != null)
{
_db.RemoveRange(chkworkordercategory);
}
_db.Remove(exist);
}
else
{
return BadRequest(new Response { Status = "Error", Message = "ID not matched!" });
}
await _db.SaveChangesAsync();
return Ok(new DataResponse { Message = "Deleted Successfully", Status = "200" });
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
[HttpGet]
[Route("GetCategoryList")]
public IActionResult GetCategoryList(int page = 1, int pageSize = 10)
{
var totalCount = _db.Categories.Count();
var data = _db.Categories.Select(s => new
{
s.Id,
s.Name
}).OrderByDescending(d => d.Id).ToList().Skip((page - 1) * pageSize)
.Take(pageSize);
// Calculate the number of pages
var totalPages = (int)Math.Ceiling(totalCount / (double)pageSize);
// Create a view model containing the paged items and pagination metadata
var viewModel = new Pagination_DTO
{
Data = data,
PageNumber = page,
PageSize = pageSize,
TotalCount = totalCount,
TotalPages = totalPages
};
return Ok(viewModel);
}
[HttpGet]
[Route("GetTemplates")]
public IActionResult GetTemplates(int page = 1, int pageSize = 10)
{
try
{
var totalCount = _db.workOrders.Where(w=> w.istemplate == true).Count();
var data = _db.workOrders.Where(w => w.istemplate == true).OrderByDescending(d => d.Id).ToList().Skip((page - 1) * pageSize)
.Take(pageSize);
// Calculate the number of pages
var totalPages = (int)Math.Ceiling(totalCount / (double)pageSize);
// Create a view model containing the paged items and pagination metadata
var viewModel = new Pagination_DTO
{
Data = data,
PageNumber = page,
PageSize = pageSize,
TotalCount = totalCount,
TotalPages = totalPages
};
return Ok(viewModel);
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
[HttpGet]
[Route("GetUsers")]
public async Task<IActionResult> GetUsers(string? search = "", int page = 1, int pageSize = 10)
{
try
{
var totalCount = _db.Users.Count();
var allUsers = _db.Users.Where(w => w.FirstName.ToLower().Contains(search.ToLower())).OrderByDescending(d => d.Id).ToList().Skip((page - 1) * pageSize)
.Take(pageSize);
// Calculate the number of pages
var totalPages = (int)Math.Ceiling(totalCount / (double)pageSize);
var filteredUsers = new List<UserRoleViewModel>();
foreach (var user in allUsers)
{
var roles = await _userManager.GetRolesAsync(user);
if (!roles.Contains("Admin"))
{
filteredUsers.Add(new UserRoleViewModel
{
RoleName = roles.Count() > 0 ? roles.First() : "",
Email = user.Email,
UserName = user.FirstName,
Date = user.CreatedDate?.Date.ToString(),
Status = user.UniqueName,
Id = user.Id
});
}
}
// Create a view model containing the paged items and pagination metadata
var viewModel = new Pagination_DTO
{
Data = filteredUsers,
PageNumber = page,
PageSize = pageSize,
TotalCount = totalCount,
TotalPages = totalPages
};
return Ok(viewModel);
}
catch (Exception ex)
{
return BadRequest(new { Status = "Error", Message = ex.Message });
}
}
[HttpGet]
[Route("GetRoles")]
public async Task<IActionResult> GetRoles()
{
try
{
var data = _db.Roles.ToList();
List<Roles_DTO> roles = new List<Roles_DTO>();
foreach (var role in data)
{
if (role.Name == "Admin")
{
roles.Add(new Roles_DTO { Name = role.Name, Description = "Full Access" });
}
else if(role.Name == "Supervisor")
{
roles.Add(new Roles_DTO { Name = role.Name, Description = "Access to Team's Work Orders Only" });
}
else if(role.Name == "Manager")
{
roles.Add(new Roles_DTO { Name = role.Name, Description = "Full access accept quotes" });
}
else if(role.Name =="User")
{
roles.Add(new Roles_DTO { Name = role.Name, Description = "Access to Assigned Work Orders Only" });
}
}
return Ok(roles);
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
}
}

View file

@ -0,0 +1,230 @@
using Api.SeaHavenIndustries.DTOs;
using Api.SeaHavenIndustries.Helper;
using Data.SeaHavenIndustries;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Security.Claims;
using System.Security.Cryptography;
namespace Api.SeaHavenIndustries.Controllers
{
[Authorize]
[ApiController]
[Route("[controller]")]
public class UserController : Controller
{
private readonly UserManager<ApplicationUser> _userManager;
private readonly ApplicationDbContext _db;
private readonly SendMessage _sendemail;
public UserController(UserManager<ApplicationUser> userManager, ApplicationDbContext db, SendMessage sendemail)
{
_userManager = userManager;
_db = db;
_sendemail = sendemail;
}
[HttpPost]
[Route("AddUser")]
public async Task<IActionResult> AddUser(User_DTO model)
{
try
{
ApplicationUser user = new ApplicationUser();
user.EmailConfirmed = true;
user.UserName = model.Email;
user.Email = model.Email;
user.FirstName = model.Name;
user.CreatedDate = DateTime.Now;
user.UniqueName = "Active";
var password = GenerateRandomPassword(8);
var result = await _userManager.CreateAsync(user, password);
if (result.Succeeded)
{
await _userManager.AddToRoleAsync(user, model.Role ?? "");
}
else
{
return BadRequest(result.Errors.FirstOrDefault()?.Description ?? "error");
}
//var request = _httpContextAccessor.HttpContext?.Request;
//var domain = $"{request?.Scheme}://{request?.Host}";
string subject = "Login Information";
//string greeting = $"Dear {model.FirstName},\n\n";
//string loginLink = $"Click here to login:<a href='{domain}/Login'>{domain}/Login</a>\n";
string passwordInfo = $"Your password is: {password}\n\n";
string body = $"{passwordInfo}";
await _sendemail.SendEMail(model?.Email ?? "", subject, body);
return Ok(new DataResponse { Message = "Updated Successfully", Status = "200" });
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
[HttpPost]
[Route("EditUser")]
public async Task<IActionResult> EditUser(EditUser_DTO user)
{
try
{
var exist = _db.Users.Where(w => w.Id == user.Id).FirstOrDefault();
exist.FirstName = user.Name;
exist.EmailConfirmed = true;
exist.UserName = user.Email;
exist.Email = user.Email;
exist.NormalizedEmail = user.Email.ToUpper();
exist.NormalizedUserName = user.Email.ToUpper();
exist.CreatedDate = DateTime.Now;
exist.UniqueName = "Active";
var existingRole = await _userManager.GetRolesAsync(exist);
if (existingRole != null && existingRole.Any())
{
await _userManager.RemoveFromRolesAsync(exist, existingRole);
}
await _userManager.AddToRoleAsync(exist, user.Role ?? "");
await _db.SaveChangesAsync();
return Ok(new DataResponse { Message = "Updated Successfully", Status = "200" });
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
[HttpGet]
[Route("DeleteUser")]
public async Task<IActionResult> DeleteUser(string id)
{
try
{
var data = await _db.Users.Where(w => w.Id == id).FirstOrDefaultAsync();
if (data != null)
{
var existworkorder = _db.workOrders.Where(w => w.AssignTo.Contains(data.Id)).ToList();
foreach (var workorder in existworkorder)
{
var existdata = _db.workOrders.Where(w => w.Id == workorder.Id).FirstOrDefault();
existdata.AssignTo = null;
}
var existworkordercomments = _db.Comments.Where(w => w.UserId.Contains(data.Id)).ToList();
foreach (var workorderc in existworkordercomments)
{
var existdatacomm = _db.Comments.Where(w => w.Id == workorderc.Id).FirstOrDefault();
existdatacomm.UserId = null;
}
var existtemplate = _db.Templates.Where(w => w.AssignTo.Contains(data.Id)).ToList();
foreach (var workordert in existtemplate)
{
var existdattem = _db.Templates.Where(w => w.Id == workordert.Id).FirstOrDefault();
existdattem.AssignTo = null;
}
var existtempexistuserrolelate = _db.UserRoles.Where(w => w.UserId.Contains(data.Id)).ToList();
if (existtempexistuserrolelate.Count() > 0)
{
_db.UserRoles.RemoveRange(existtempexistuserrolelate);
}
_db.Users.Remove(data);
}
else
{
return BadRequest(new Response { Status = "Error", Message = "ID not matched!" });
}
await _db.SaveChangesAsync();
return Ok(new DataResponse { Message = "Updated Successfully", Status = "200" });
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
[HttpPost]
[Route("DeleteCurrentUser")]
public async Task<IActionResult> DeleteCurrentUser()
{
try
{
var userid = User.FindFirstValue(ClaimTypes.NameIdentifier) ?? "";
var exist = _db.Users.Where(w => w.Id == userid).FirstOrDefault();
if(exist != null)
{
exist.IsDeleted = true;
}
await _db.SaveChangesAsync();
return Ok(new DataResponse { Message = "Updated Successfully", Status = "200" });
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
[HttpGet]
[Route("UserProfile")]
public async Task<IActionResult> UserProfile()
{
var userid = User.FindFirstValue(ClaimTypes.NameIdentifier) ?? "";
var data = await _db.Users.Where(w => w.Id == userid).Select(s => new
{
s.Id,
Name = s.FirstName,
addeddate = s.CreatedDate,
s.Email,
s.Contact
}).ToListAsync();
return Ok(data);
}
public static string GenerateRandomPassword(int length = 8)
{
const string validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()_-+=<>?";
const string capitalLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string digits = "1234567890";
const string symbols = "!@#$%^&*()_-+=<>?";
using (var rng = RandomNumberGenerator.Create())
{
var passwordChars = new char[length];
// Ensure at least one capital letter
passwordChars[0] = capitalLetters[GetNextNonNegativeIndex(rng, capitalLetters.Length)];
// Ensure at least one digit
passwordChars[1] = digits[GetNextNonNegativeIndex(rng, digits.Length)];
// Ensure at least one symbol
passwordChars[2] = symbols[GetNextNonNegativeIndex(rng, symbols.Length)];
// Fill the rest of the password with random characters
for (int i = 3; i < length; i++)
{
passwordChars[i] = validChars[GetNextNonNegativeIndex(rng, validChars.Length)];
}
// Shuffle the password characters, excluding the initial characters
Random random = new Random();
for (int i = length - 1; i > 2; i--)
{
int j = random.Next(2, i + 1);
(passwordChars[i], passwordChars[j]) = (passwordChars[j], passwordChars[i]);
}
return new string(passwordChars);
}
}
private static int GetNextNonNegativeIndex(RandomNumberGenerator rng, int maxValue)
{
byte[] randomBytes = new byte[4];
rng.GetBytes(randomBytes);
int nextIndex = BitConverter.ToInt32(randomBytes, 0) % maxValue;
return (nextIndex + maxValue) % maxValue; // Ensure the index is non-negative
}
}
}

View file

@ -0,0 +1,23 @@
using Microsoft.AspNetCore.Mvc;
namespace Api.SeaHavenIndustries.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
}
}

View file

@ -0,0 +1,755 @@
using Api.SeaHavenIndustries.DTOs;
using Data.SeaHavenIndustries;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using System.IO;
using System.Net.Http.Headers;
using System.Security.Claims;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace Api.SeaHavenIndustries.Controllers
{
[Authorize]
[ApiController]
[Route("[controller]")]
public class WorkOrderController : Controller
{
private readonly UserManager<ApplicationUser> _userManager;
private readonly ApplicationDbContext _db;
private readonly IWebHostEnvironment _webHostEnvironment;
IHttpContextAccessor _httpContext;
public WorkOrderController(UserManager<ApplicationUser> userManager, ApplicationDbContext db, IWebHostEnvironment webHostEnvironment, IHttpContextAccessor httpContext)
{
_userManager = userManager;
_db = db;
_webHostEnvironment = webHostEnvironment;
_httpContext = httpContext;
}
[HttpPost]
[Route("AddWorkorder")]
public async Task<IActionResult> Addworkorder([FromForm] Workorder_DTO model)
{
try
{
string userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
WorkOrder workOrder = new WorkOrder();
workOrder.WorkerOrderNumber = model.WorkerOrderNumber;
workOrder.WorkerOrderTitle = model.WorkerOrderTitle;
workOrder.Description = model.Description;
workOrder.TT = model.TT;
workOrder.PO = model.PO;
workOrder.AssignTo = model.AssignTo;
workOrder.DueDate = model.DueDate;
workOrder.Priority = model.Priority;
workOrder.istemplate = model.istemplate;
//workOrder.CategoryId = model.CategoryId;
workOrder.LocationId = model.LocationId;
workOrder.Status = "Open";
workOrder.istemplate = model.istemplate;
workOrder.BeforPhotoIssue = model.BeforPhotoIssue;
workOrder.AfterPhotoIssue = model.AfterPhotoIssue;
workOrder.SignOffName = model.SignOffName;
workOrder.SignOffSignature = model.SignOffSignature;
workOrder.WorkOrderContacts = workOrder.WorkOrderContacts==null? new List<WorkOrderContacts>(): workOrder.WorkOrderContacts;
List<int> contactIds = model.GetContactIds();
workOrder.WorkOrderCategories = workOrder.WorkOrderCategories == null ? new List<WorkOrderCategories>() : workOrder.WorkOrderCategories;
List<int> categoryIds = model.GetCategoryIds();
// Create new records for the associations (pseudo-code)
foreach (int contactId in contactIds)
{
// Create association with contact
workOrder.WorkOrderContacts.Add(new WorkOrderContacts { ContactId = contactId });
}
foreach (int categoryId in categoryIds)
{
// Create association with category
workOrder.WorkOrderCategories.Add(new WorkOrderCategories { CategoryId = categoryId });
}
#region Images of workorder
workOrder.workOrderAttachments = workOrder.workOrderAttachments == null ? new List<WorkOrderAttachments>() : workOrder.workOrderAttachments;
foreach (var attachment in model.Attachments)
{
string fileName = ContentDispositionHeaderValue.Parse(attachment.ContentDisposition).FileName.Trim('"');
string uniqueFileName = $"{Guid.NewGuid()}_{fileName}";
string uploadProfilePath = Path.Combine("Assets", "Documents");
string fullPath = Path.Combine(_webHostEnvironment.WebRootPath, uploadProfilePath, uniqueFileName);
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
// Copy the file to the server
using (var ms = System.IO.File.Create(fullPath))
{
await attachment.CopyToAsync(ms);
}
// Update the user's image URL
var request = _httpContext.HttpContext.Request;
var domain = $"{request.Scheme}://{request.Host}";
var imagesPath = domain + "/" + Path.Combine(uploadProfilePath, uniqueFileName);
workOrder.workOrderAttachments.Add(new WorkOrderAttachments { Attachments = imagesPath });
}
if (model.BeforPhotoAttachment != null)
{
string fileName = ContentDispositionHeaderValue.Parse(model.BeforPhotoAttachment.ContentDisposition).FileName.Trim('"');
string uniqueFileName = $"{Guid.NewGuid()}_{fileName}";
string uploadProfilePath = Path.Combine("Assets", "Documents");
string fullPath = Path.Combine(_webHostEnvironment.WebRootPath, uploadProfilePath, uniqueFileName);
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
// Copy the file to the server
using (var ms = System.IO.File.Create(fullPath))
{
await model.BeforPhotoAttachment.CopyToAsync(ms);
}
// Update the user's image URL
var request = _httpContext.HttpContext.Request;
var domain = $"{request.Scheme}://{request.Host}";
workOrder.BeforPhotoAttachment = domain + "/" + Path.Combine(uploadProfilePath, uniqueFileName);
}
if (model.AfterPhotoAttachment != null)
{
string fileName = ContentDispositionHeaderValue.Parse(model.AfterPhotoAttachment.ContentDisposition).FileName.Trim('"');
string uniqueFileName = $"{Guid.NewGuid()}_{fileName}";
string uploadProfilePath = Path.Combine("Assets", "Documents");
string fullPath = Path.Combine(_webHostEnvironment.WebRootPath, uploadProfilePath, uniqueFileName);
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
// Copy the file to the server
using (var ms = System.IO.File.Create(fullPath))
{
await model.AfterPhotoAttachment.CopyToAsync(ms);
}
// Update the user's image URL
var request = _httpContext.HttpContext.Request;
var domain = $"{request.Scheme}://{request.Host}";
workOrder.AfterPhotoAttachment = domain + "/" + Path.Combine(uploadProfilePath, uniqueFileName);
}
if (model.SignOffAttachment != null)
{
string fileName = ContentDispositionHeaderValue.Parse(model.SignOffAttachment.ContentDisposition).FileName.Trim('"');
string uniqueFileName = $"{Guid.NewGuid()}_{fileName}";
string uploadProfilePath = Path.Combine("Assets", "Documents");
string fullPath = Path.Combine(_webHostEnvironment.WebRootPath, uploadProfilePath, uniqueFileName);
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
// Copy the file to the server
using (var ms = System.IO.File.Create(fullPath))
{
await model.SignOffAttachment.CopyToAsync(ms);
}
// Update the user's image URL
var request = _httpContext.HttpContext.Request;
var domain = $"{request.Scheme}://{request.Host}";
workOrder.SignOffAttachment = domain + "/" + Path.Combine(uploadProfilePath, uniqueFileName);
}
#endregion
_db.Add(workOrder);
_db.SaveChanges();
return Ok(new DataResponse { Message = "Updated Successfully", Status = "200" });
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
[HttpPost]
[Route("EditWorkorder")]
public async Task<IActionResult> Editworkorder([FromForm] EditWorkorder_DTO model)
{
try
{
var workOrder = _db.workOrders.Where(w => w.Id == model.Id).FirstOrDefault();
workOrder.WorkerOrderNumber = model.WorkerOrderNumber;
workOrder.WorkerOrderTitle = model.WorkerOrderTitle;
workOrder.Description = model.Description;
workOrder.TT = model.TT;
workOrder.PO = model.PO;
workOrder.AssignTo = model.AssignTo;
workOrder.DueDate = model.DueDate;
workOrder.Priority = model.Priority;
//workOrder.CategoryId = model.CategoryId;
workOrder.LocationId = model.LocationId;
workOrder.Status = "Open";
//workOrder.istemplate = false;
workOrder.BeforPhotoIssue = model.BeforPhotoIssue;
workOrder.AfterPhotoIssue = model.AfterPhotoIssue;
workOrder.SignOffName = model.SignOffName;
workOrder.SignOffSignature = model.SignOffSignature;
var existcontact=_db.WorkOrderContacts.Where(w=>w.WorkorderId==model.Id).ToList();
if (existcontact.Count()>0)
{
_db.WorkOrderContacts.RemoveRange(existcontact);
}
var existcategory=_db.workOrderCategories.Where(w=>w.WorkorderId==model.Id).ToList();
if (existcategory.Count()>0)
{
_db.workOrderCategories.RemoveRange(existcategory);
}
workOrder.WorkOrderContacts = workOrder.WorkOrderContacts == null ? new List<WorkOrderContacts>() : workOrder.WorkOrderContacts;
List<int> contactIds = model.GetContactIds();
workOrder.WorkOrderCategories = workOrder.WorkOrderCategories == null ? new List<WorkOrderCategories>() : workOrder.WorkOrderCategories;
List<int> categoryIds = model.GetCategoryIds();
// Create new records for the associations (pseudo-code)
foreach (int contactId in contactIds)
{
// Create association with contact
workOrder.WorkOrderContacts.Add(new WorkOrderContacts { ContactId = contactId });
}
foreach (int categoryId in categoryIds)
{
// Create association with category
workOrder.WorkOrderCategories.Add(new WorkOrderCategories { CategoryId = categoryId });
}
#region Images of workorder
workOrder.workOrderAttachments = workOrder.workOrderAttachments == null ? new List<WorkOrderAttachments>() : workOrder.workOrderAttachments;
foreach (var attachment in model.Attachments)
{
string fileName = ContentDispositionHeaderValue.Parse(attachment.ContentDisposition).FileName.Trim('"');
string uniqueFileName = $"{Guid.NewGuid()}_{fileName}";
string uploadProfilePath = Path.Combine("Assets", "Documents");
string fullPath = Path.Combine(_webHostEnvironment.WebRootPath, uploadProfilePath, uniqueFileName);
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
// Copy the file to the server
using (var ms = System.IO.File.Create(fullPath))
{
await attachment.CopyToAsync(ms);
}
// Update the user's image URL
var request = _httpContext.HttpContext.Request;
var domain = $"{request.Scheme}://{request.Host}";
var imagesPath = domain + "/" + Path.Combine(uploadProfilePath, uniqueFileName);
workOrder.workOrderAttachments.Add(new WorkOrderAttachments { Attachments = imagesPath });
}
if (model.BeforPhotoAttachment != null)
{
string fileName = ContentDispositionHeaderValue.Parse(model.BeforPhotoAttachment.ContentDisposition).FileName.Trim('"');
string uniqueFileName = $"{Guid.NewGuid()}_{fileName}";
string uploadProfilePath = Path.Combine("Assets", "Documents");
string fullPath = Path.Combine(_webHostEnvironment.WebRootPath, uploadProfilePath, uniqueFileName);
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
// Copy the file to the server
using (var ms = System.IO.File.Create(fullPath))
{
await model.BeforPhotoAttachment.CopyToAsync(ms);
}
// Update the user's image URL
var request = _httpContext.HttpContext.Request;
var domain = $"{request.Scheme}://{request.Host}";
workOrder.BeforPhotoAttachment = domain + "/" + Path.Combine(uploadProfilePath, uniqueFileName);
}
if (model.AfterPhotoAttachment != null)
{
string fileName = ContentDispositionHeaderValue.Parse(model.AfterPhotoAttachment.ContentDisposition).FileName.Trim('"');
string uniqueFileName = $"{Guid.NewGuid()}_{fileName}";
string uploadProfilePath = Path.Combine("Assets", "Documents");
string fullPath = Path.Combine(_webHostEnvironment.WebRootPath, uploadProfilePath, uniqueFileName);
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
// Copy the file to the server
using (var ms = System.IO.File.Create(fullPath))
{
await model.AfterPhotoAttachment.CopyToAsync(ms);
}
// Update the user's image URL
var request = _httpContext.HttpContext.Request;
var domain = $"{request.Scheme}://{request.Host}";
workOrder.AfterPhotoAttachment = domain + "/" + Path.Combine(uploadProfilePath, uniqueFileName);
}
if (model.SignOffAttachment != null)
{
string fileName = ContentDispositionHeaderValue.Parse(model.SignOffAttachment.ContentDisposition).FileName.Trim('"');
string uniqueFileName = $"{Guid.NewGuid()}_{fileName}";
string uploadProfilePath = Path.Combine("Assets", "Documents");
string fullPath = Path.Combine(_webHostEnvironment.WebRootPath, uploadProfilePath, uniqueFileName);
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
// Copy the file to the server
using (var ms = System.IO.File.Create(fullPath))
{
await model.SignOffAttachment.CopyToAsync(ms);
}
// Update the user's image URL
var request = _httpContext.HttpContext.Request;
var domain = $"{request.Scheme}://{request.Host}";
workOrder.SignOffAttachment = domain + "/" + Path.Combine(uploadProfilePath, uniqueFileName);
}
#endregion
_db.SaveChanges();
return Ok(new DataResponse { Message = "Updated Successfully", Status = "200" });
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
//[HttpGet]
//[Route("GetWorkorder")]
//public IActionResult GetWorkorder(int page = 1, int pageSize = 10, string search="")
//{
// var totalCount = _db.workOrders.Count();
// var data = _db.workOrders.Include(w => w.Locations).AsNoTracking().Where(w => w.istemplate != true && (w.WorkerOrderTitle.ToLower().Contains(search.ToLower()) || w.WorkerOrderNumber.ToLower().Contains(search.ToLower()) || w.Locations.Title.ToLower().Contains(search.ToLower()))).Select(s => new
// {
// s.Id,
// s.WorkerOrderTitle,
// s.DueDate,
// s.Priority,
// s.Status,
// site = s.Locations.Name
// }).OrderByDescending(d=> d.Id).ToList().Skip((page - 1) * pageSize)
// .Take(pageSize);
// // Calculate the number of pages
// var totalPages = (int)Math.Ceiling(totalCount / (double)pageSize);
// // Create a view model containing the paged items and pagination metadata
// var viewModel = new Pagination_DTO
// {
// Data = data,
// PageNumber = page,
// PageSize = pageSize,
// TotalCount = totalCount,
// TotalPages = totalPages
// };
// return Ok(viewModel);
//}
[HttpGet]
[Route("DeleteWorkorder")]
public IActionResult Deleteworkorder(int id)
{
try
{
var exist = _db.workOrders.Where(w => w.Id == id).FirstOrDefault();
if (exist != null)
{
var quotes = _db.Quotes.Where(w => w.WorkorderId == id).ToList();
if (quotes.Count() > 0)
{
foreach (var itm in quotes)
{
var existquotes = _db.Quotes.Where(w => w.Id == itm.Id).FirstOrDefault();
existquotes.WorkorderId = null;
}
}
var attachments = _db.workOrderAttachments.Where(w => w.WorkorderId == id).ToList();
if (attachments.Count() > 0)
{
_db.RemoveRange(attachments);
}
var contacts = _db.WorkOrderContacts.Where(w => w.WorkorderId == id).ToList();
if (contacts.Count() > 0)
{
_db.RemoveRange(contacts);
}
var category = _db.workOrderCategories.Where(w => w.WorkorderId == id).ToList();
if (category.Count() > 0)
{
_db.RemoveRange(category);
}
var comments = _db.Comments.Where(w => w.WorkerOrderId == id).ToList();
if (comments.Count() > 0)
{
_db.RemoveRange(comments);
}
_db.Remove(exist);
}
else
{
return BadRequest("ID not matched!");
}
_db.SaveChanges();
return Ok(new DataResponse { Message = "Removed Successfully", Status = "200" });
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
[HttpGet]
[Route("GetFilteredWorkorder")]
public IActionResult GetFilteredWorkorder(
[FromQuery] string[] assignto,
[FromQuery] int[]? location,
[FromQuery] string[]? priority,
[FromQuery] string[]? status,
[FromQuery] string[]? duedate,
[FromQuery] string search = "",
[FromQuery] string sort = "Sort Order",
[FromQuery] string sortby = "Sort By",
int page = 1,
int pageSize = 10)
{
try
{
IQueryable<WorkOrder> query = _db.workOrders.Where(w => w.istemplate != true).Include(w => w.Locations);
if (!string.IsNullOrEmpty(search))
{
query = query.Where(w =>
w.WorkerOrderTitle.ToLower().Contains(search.ToLower()) ||
w.WorkerOrderNumber.ToLower().Contains(search.ToLower()) ||
w.Locations.Title.ToLower().Contains(search.ToLower()));
}
if (assignto != null && assignto.Length > 0)
{
if (assignto[0] != "" && assignto[0]!=null)
query = query.Where(w => assignto.Contains(w.AssignTo));
}
if (location != null && location.Length > 0)
{
if (location[0]!=0)
query = query.Where(w => location.Contains(w.LocationId ?? 0));
}
if (priority != null && priority.Length > 0)
{
if (priority[0] != "" && priority[0] != null)
query = query.Where(w => priority.Contains(w.Priority));
}
if (status != null && status.Length > 0)
{
if (status[0] != "" && status[0] != null)
query = query.Where(w => status.Contains(w.Status));
}
var data = query.ToList();
// Perform client-side filtering for due dates
data = data.Where(w =>
duedate == null || duedate.Length == 0 || duedate[0] == null ||
duedate.Any(dd => w.DueDate.HasValue && CheckDueDate(dd, w.DueDate.Value.Date, DateTime.UtcNow.Date))).ToList();
// Apply sorting
if (!string.IsNullOrEmpty(sort) && !string.IsNullOrEmpty(sortby) && sortby != "")
{
switch (sortby)
{
case "Name":
data = (sort.ToLower() == "ascending") ? data.OrderBy(w => w.WorkerOrderTitle).ToList() : data.OrderByDescending(w => w.WorkerOrderTitle).ToList();
break;
case "Due Date":
data = (sort.ToLower() == "ascending") ? data.OrderBy(w => w.DueDate).ToList() : data.OrderByDescending(w => w.DueDate).ToList();
break;
case "Severity":
data = (sort.ToLower() == "ascending") ? data.OrderBy(w => w.Priority).ToList() : data.OrderByDescending(w => w.Priority).ToList();
break;
default:
// Handle default case or throw an exception
break;
}
}
var totalCount = data.Count();
var pagedData = data
.Skip((page - 1) * pageSize)
.Take(pageSize)
.Select(s => new { s.Id, s.WorkerOrderTitle, s.DueDate, s.Status, s.Priority, s.Locations.Name })
.OrderByDescending(d => d.Name)
.ToList();
var totalPages1 = (int)Math.Ceiling(totalCount / (double)pageSize);
// Create a view model containing the paged items and pagination metadata
var viewModel = new Pagination_DTO
{
Data = pagedData,
PageNumber = page,
PageSize = pageSize,
TotalCount = totalCount,
TotalPages = totalPages1
};
return Ok(viewModel);
}
catch (Exception ex)
{
// Handle exception and return a default result or an error response
return StatusCode(500, "Internal Server Error");
}
}
[HttpGet]
[Route("GetWorkorderById")]
public async Task<IActionResult> GetWorkorderById(int id)
{
var exist = await _db.workOrders.Include(w => w.Locations).Include(w => w.Comments).Include(w => w.Quotes).Where(w => w.Id == id).Select(s => new
{
s.Id,
s.WorkerOrderNumber,
title= s.WorkerOrderTitle,
s.DueDate,
s.Status,
assignee = s.AssignToUser.FirstName,
location = s.Locations.Name,
priority = s.Priority,
s.PO,
s.TT,
poc = s.WorkOrderContacts.Select(s => new {s.Id,name=s.POC.Name,email=s.POC.Email,phone=s.POC.PhoneNumber}),
category = s.WorkOrderCategories.Select(s => new {s.Id,name=s.Category.Name}),
Attachments = s.workOrderAttachments.Select(s => new {s.Id,attachment=s.Attachments}),
//category = s.Category.Name,
//s.Attachments,
s.BeforPhotoIssue,
s.BeforPhotoAttachment,
s.AfterPhotoIssue,
s.AfterPhotoAttachment,
s.SignOffName,
s.SignOffAttachment,
s.SignOffSignature,
Comments = s.Comments.Select(s => new { s.Id, s.CreatedDate, s.Commenttext, s.Documents,userName=s.ApplicationUser.FirstName }),
quotes = s.Quotes.Select(q => new { code = q.QuotId, q.Id })
}).FirstOrDefaultAsync();
if (exist == null)
{
return BadRequest(new Response { Status = "Error", Message = "ID not found!" });
}
else
{
return Ok(exist);
}
}
[HttpGet]
[Route("GetFilteredWorkorder2")]
public IActionResult GetFilteredWorkorder2([FromQuery] string[] assignto, [FromQuery] int[]? location, [FromQuery] string[]? priority, [FromQuery] string[]? status, [FromQuery] string[]? duedate, [FromQuery] string search = "", [FromQuery] string sort = "Sort Order", [FromQuery] string sortby= "Sort By", int page = 1, int pageSize = 10)
{
try
{
var totalCount = _db.workOrders.Where(w => w.istemplate != true).Count();
if (sort == "Sort Order" && sortby == "Sort By" && assignto.Count() == 0 && (duedate == null || duedate.Count() == 0) && location.Count() == 0 && (priority == null || priority.Count() == 0) && (status == null || status.Count() == 0) && search == "")
{
var data1 = _db.workOrders.Where(w => w.istemplate != true).Include(w => w.Locations).ToListAsync();
return Ok(data1);
}
//if (sort == "Sort Order" && sortby == "Sort By" && assignto.Count() == 0 && (duedate == null || duedate.Count() == 0) && location.Count() == 0 && (priority == null || priority.Count() == 0) && (status == null || status.Count() == 0) && search == "")
//{
// var data1 = _db.workOrders.Where(w => w.istemplate != true).Include(w => w.Locations).Select(s => new {s.Id, s.WorkerOrderTitle, s.DueDate, s.Status, s.Priority, s.Locations.Name }).OrderByDescending(d => d.Name).ToList().Skip((page - 1) * pageSize)
// .Take(pageSize);
// // Calculate the number of pages
// var totalPages = (int)Math.Ceiling(totalCount / (double)pageSize);
// // Create a view model containing the paged items and pagination metadata
// var viewModel1 = new Pagination_DTO
// {
// Data = data1,
// PageNumber = page,
// PageSize = pageSize,
// TotalCount = totalCount,
// TotalPages = totalPages
// };
// return Ok(viewModel1);
//}
var currentDate = DateTime.UtcNow.Date;
var data = _db.workOrders.Include(w => w.Locations)
.Where(w => w.istemplate != true && ((w.WorkerOrderTitle.ToLower().Contains(search.ToLower()) || w.WorkerOrderNumber.ToLower().Contains(search.ToLower()) || w.Locations.Title.ToLower().Contains(search.ToLower())) &&
(assignto.Count() == 0 || assignto.Contains(w.AssignTo)) &&
(location.Count() == 0 || (w.LocationId.HasValue && location.Contains(w.LocationId.Value))) &&
(priority.Count() == 0 || priority.Contains(w.Priority)) &&
((status.Count() == 0 || status.Contains(w.Status))
)))
.ToList();
// Perform client-side filtering for due dates
data = data.Where(w =>
duedate.Count() == 0 ||
duedate.Any(dd => w.DueDate.HasValue && CheckDueDate(dd, w.DueDate.Value.Date, currentDate))).ToList();
// Apply sorting
if (!string.IsNullOrEmpty(sort) && !string.IsNullOrEmpty(sortby) && sortby != "")
{
switch (sortby)
{
case "Name":
data = (sort.ToLower() == "ascending") ? data.OrderBy(w => w.WorkerOrderTitle).ToList() : data.OrderByDescending(w => w.WorkerOrderTitle).ToList();
break;
case "Due Date":
data = (sort.ToLower() == "ascending") ? data.OrderBy(w => w.DueDate).ToList() : data.OrderByDescending(w => w.DueDate).ToList();
break;
case "Severity":
data = (sort.ToLower() == "ascending") ? data.OrderBy(w => w.Priority).ToList() : data.OrderByDescending(w => w.Priority).ToList();
break;
default:
// Handle default case or throw an exception
break;
}
}
var newdata=data.Select(s => new { s.Id, s.WorkerOrderTitle, s.DueDate, s.Status, s.Priority, s.Locations.Name }).OrderByDescending(d => d.Name).ToList().Skip((page - 1) * pageSize)
.Take(pageSize);
var totalPages1 = (int)Math.Ceiling(totalCount / (double)pageSize);
// Create a view model containing the paged items and pagination metadata
var viewModel = new Pagination_DTO
{
Data = newdata,
PageNumber = page,
PageSize = pageSize,
TotalCount = totalCount,
TotalPages = totalPages1
};
return Ok(viewModel);
}
catch (Exception ex)
{
var totalCount = _db.workOrders.Where(w => w.istemplate != true).Count();
var data1 = _db.workOrders.Where(w => w.istemplate != true).Include(w => w.Locations).Select(s=> new
{
s.Id,
s.WorkerOrderTitle,
s.DueDate,
s.Status,
s.Priority,
s.Locations.Name
}).OrderByDescending(d => d.Id).ToList().Skip((page - 1) * pageSize)
.Take(pageSize);
// Calculate the number of pages
var totalPages = (int)Math.Ceiling(totalCount / (double)pageSize);
// Create a view model containing the paged items and pagination metadata
var viewModel = new Pagination_DTO
{
Data = data1,
PageNumber = page,
PageSize = pageSize,
TotalCount = totalCount,
TotalPages = totalPages
};
return Ok(viewModel);
}
}
bool CheckDueDate(string dd, DateTime dueDate, DateTime currentDate)
{
return dd switch
{
"Today" => dueDate == currentDate,
"Tomorrow" => dueDate == currentDate.AddDays(1),
"Next Week" => dueDate >= currentDate.AddDays(1) && dueDate <= currentDate.AddDays(7),
"Next Month" => dueDate >= currentDate.AddDays(1) && dueDate <= currentDate.AddMonths(1),
"Over Due" => dueDate < currentDate,
_ => false
};
}
[HttpPost]
[Route("ChangeStatus")]
public async Task<IActionResult> ChangeStatus(int id, string status)
{
try
{
var data = await _db.workOrders.Where(w => w.Id == id).FirstOrDefaultAsync();
data.Status = status;
await _db.SaveChangesAsync();
return Ok(new DataResponse { Message = "Updated Successfully", Status = "200", Data = data });
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
[HttpPost]
[Route("AddComment")]
public async Task<IActionResult> AddComment([FromForm] Comments_DTO model)
{
try
{
var userId = _httpContext?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value ?? "";
Comments comments = new Comments();
comments.CreatedDate = DateTime.Now;
comments.UserId = userId;
comments.WorkerOrderId = model.WorkorderId;
comments.Commenttext = model.Text;
if (model.Document != null)
{
string fileName = ContentDispositionHeaderValue.Parse(model.Document.ContentDisposition).FileName.Trim('"');
string uniqueFileName = $"{Guid.NewGuid()}_{fileName}";
string uploadProfilePath = Path.Combine("Assets", "Documents");
string fullPath = Path.Combine(_webHostEnvironment.WebRootPath, uploadProfilePath, uniqueFileName);
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
// Copy the file to the server
using (var ms = System.IO.File.Create(fullPath))
{
await model.Document.CopyToAsync(ms);
}
// Update the user's image URL
var request = _httpContext.HttpContext.Request;
var domain = $"{request.Scheme}://{request.Host}";
comments.Documents = domain + "/" + Path.Combine(uploadProfilePath, uniqueFileName);
}
_db.Comments.Add(comments);
await _db.SaveChangesAsync();
return Ok(new DataResponse { Message = "Updated Successfully", Status = "200", Data = comments });
}
catch (Exception ex)
{
return BadRequest(new Response { Status = "Error", Message = ex.Message });
}
}
[HttpGet]
[Route("GetComments")]
public async Task<IActionResult> GetComments()
{
var data = await _db.Comments.Include(i => i.ApplicationUser).Select(s => new
{
s.Id,
s.Commenttext,
s.ApplicationUser.FirstName,
s.Documents
}).ToListAsync();
return Ok(data);
}
[HttpGet]
[Route("GetCommentsByWorkorderId")]
public async Task<IActionResult> GetCommentsByWorkorderId(int woid)
{
var data = await _db.Comments.Where(w => w.WorkerOrderId == woid).Include(i => i.ApplicationUser).Select(s => new
{
s.Id,
s.Commenttext,
s.ApplicationUser.FirstName,
s.Documents
}).ToListAsync();
return Ok(data);
}
}
}

View file

@ -0,0 +1,12 @@
namespace Api.SeaHavenIndustries.DTOs
{
public class Category_DTO
{
public string? Name { get; set; }
}
public class EditCategory_DTO
{
public int? Id { get; set; }
public string? Name { get; set; }
}
}

View file

@ -0,0 +1,11 @@
namespace Api.SeaHavenIndustries.DTOs
{
public class Comments_DTO
{
public string Text { get; set; }
public IFormFile? Document { get; set; }
public int WorkorderId { get; set; }
public DateTime CreatedDate { get; set; }
public string UserId { get; set; }
}
}

View file

@ -0,0 +1,9 @@
namespace Api.SeaHavenIndustries.DTOs
{
public class Contact_DTO
{
public string? Name { get; set; }
public string? PhoneNumber { get; set; }
public string? Email { get; set; }
}
}

View file

@ -0,0 +1,10 @@
namespace Api.SeaHavenIndustries.DTOs
{
public class EditContact_DTO
{
public int Id { get; set; }
public string? Name { get; set; }
public string? PhoneNumber { get; set; }
public string? Email { get; set; }
}
}

View file

@ -0,0 +1,9 @@
namespace Api.SeaHavenIndustries.DTOs
{
public class EditLocation_DTO
{
public int Id { get; set; }
public string? Title { get; set; }
public string? Name { get; set; }
}
}

View file

@ -0,0 +1,20 @@
using Data.SeaHavenIndustries;
namespace Api.SeaHavenIndustries.DTOs
{
public class EditQuote_DTO
{
public int id { get; set; }
public string? QuotId { get; set; }
public string? Date { get; set; }
public string? TT { get; set; }
public string? PO { get; set; }
public int? ContactId { get; set; }
public int? WorkorderId { get; set; }
public string? ProjectName { get; set; }
public string? SiteName { get; set; }
public string? SiteId { get; set; }
public string? BillingAddress { get; set; }
public ICollection<LineItem_DTO>? LineItems { get; set; }
}
}

View file

@ -0,0 +1,12 @@
using System.ComponentModel.DataAnnotations;
namespace Api.SeaHavenIndustries.DTOs
{
public class ForgetPassword_Dto
{
public string Email { get; set; }
[StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
public string? Password { get; set; }
public string? Code { get; set; }
}
}

View file

@ -0,0 +1,9 @@
namespace Api.SeaHavenIndustries.DTOs
{
public class LineItem_DTO
{
public int? LineitemNumber { get; set; }
public decimal? Lineitem { get; set; }
public string? Descriptions { get; set; }
}
}

View file

@ -0,0 +1,8 @@
namespace Api.SeaHavenIndustries.DTOs
{
public class Location_DTO
{
public string? Title { get; set; }
public string? Name { get; set; }
}
}

View file

@ -0,0 +1,11 @@
namespace Api.SeaHavenIndustries.DTOs
{
public class Pagination_DTO
{
public dynamic? Data { get; set; }
public int? PageNumber { get; set; }
public int? PageSize { get; set; }
public int? TotalCount { get; set; }
public int? TotalPages { get; set; }
}
}

View file

@ -0,0 +1,19 @@
using Data.SeaHavenIndustries;
namespace Api.SeaHavenIndustries.DTOs
{
public class Quote_DTO
{
public string? QuotId { get; set; }
public string? Date { get; set; }
public string? TT { get; set; }
public string? PO { get; set; }
public int? ContactId { get; set; }
public int? WorkorderId { get; set; }
public string? ProjectName { get; set; }
public string? SiteName { get; set; }
public string? SiteId { get; set; }
public string? BillingAddress { get; set; }
public ICollection<LineItem_DTO>? LineItems { get; set; }
}
}

View file

@ -0,0 +1,13 @@
namespace Api.SeaHavenIndustries.DTOs
{
public class Reporting_DTO
{
public int TotalCreatedWorkOrder { get; set; }
public int TotalCompleted { get; set; }
public int TotalSev1 { get; set; }
public int TotalSev2 { get; set; }
public int TotalSev3 { get; set; }
public int TotalSev4 { get; set; }
public int TotalSev5 { get; set; }
}
}

View file

@ -0,0 +1,9 @@
namespace Api.SeaHavenIndustries.DTOs
{
public class Roles_DTO
{
public string? Name { get; set; }
public string? Description { get; set; }
}
}

View file

@ -0,0 +1,17 @@
namespace Api.SeaHavenIndustries.DTOs
{
public class User_DTO
{
public string? Name { get; set; }
public string? Email { get; set; }
public string? Contact { get; set; }
public string? Role { get; set; }
}
public class EditUser_DTO
{
public string? Id { get; set; }
public string? Name { get; set; }
public string? Email { get; set; }
public string? Role { get; set; }
}
}

View file

@ -0,0 +1,74 @@
using Data.SeaHavenIndustries;
namespace Api.SeaHavenIndustries.DTOs
{
public class Workorder_DTO
{
public string? WorkerOrderNumber { get; set; }
public string? WorkerOrderTitle { get; set; }
public string? Description { get; set; }
public string? PO { get; set; }
public string? TT { get; set; }
//public int? ContactId { get; set; }
public string? AssignTo { get; set; }
public DateTime? DueDate { get; set; }
public string? Priority { get; set; }
public int? LocationId { get; set; }
public bool? istemplate { get; set; }
//public int? CategoryId { get; set; }
public List<IFormFile>? Attachments { get; set; }
public string? BeforPhotoIssue { get; set; }
public IFormFile? BeforPhotoAttachment { get; set; }
public string? AfterPhotoIssue { get; set; }
public IFormFile? AfterPhotoAttachment { get; set; }
public string? SignOffName { get; set; }
public IFormFile? SignOffAttachment { get; set; }
public string? SignOffSignature { get; set; }
public string? WorkOrderContacts { get; set; }
public string? WorkOrderCategories { get; set; }
public List<int> GetContactIds()
{
return WorkOrderContacts?.Split(',').Select(int.Parse).ToList() ?? new List<int>();
}
public List<int> GetCategoryIds()
{
return WorkOrderCategories?.Split(',').Select(int.Parse).ToList() ?? new List<int>();
}
}
public class EditWorkorder_DTO
{
public int? Id { get; set; }
public string? WorkerOrderNumber { get; set; }
public string? WorkerOrderTitle { get; set; }
public string? Description { get; set; }
public string? PO { get; set; }
public string? TT { get; set; }
//public int? ContactId { get; set; }
public string? AssignTo { get; set; }
public DateTime? DueDate { get; set; }
public string? Priority { get; set; }
public int? LocationId { get; set; }
//public int? CategoryId { get; set; }
public List<IFormFile>? Attachments { get; set; }
public string? BeforPhotoIssue { get; set; }
public IFormFile? BeforPhotoAttachment { get; set; }
public string? AfterPhotoIssue { get; set; }
public IFormFile? AfterPhotoAttachment { get; set; }
public string? SignOffName { get; set; }
public IFormFile? SignOffAttachment { get; set; }
public string? SignOffSignature { get; set; }
public string? WorkOrderContacts { get; set; }
public string? WorkOrderCategories { get; set; }
public List<int> GetContactIds()
{
return WorkOrderContacts?.Split(',').Select(int.Parse).ToList() ?? new List<int>();
}
public List<int> GetCategoryIds()
{
return WorkOrderCategories?.Split(',').Select(int.Parse).ToList() ?? new List<int>();
}
}
}

View file

@ -0,0 +1,105 @@

using SendGrid;
using SendGrid.Helpers.Mail;
namespace Api.SeaHavenIndustries.Helper
{
public class SendMessage
{
private IConfiguration _configuration;
//string keysapi = "";
public SendMessage(IConfiguration configuration)
{
_configuration = configuration;
//keysapi = _configuration.GetValue<string>("SendGrid:ApiKey");
}
public async Task<bool> SendEMail(string emailTo, string subject, string body)
{
try
{
//MailMessage mail = new MailMessage();
//mail.From = new MailAddress("infoesquall@codevoir.com"); //IMPORTANT: This must be same as your smtp authentication address.
//mail.To.Add(emailTo);
//mail.Subject = subject;
//mail.Body = body;
//mail.IsBodyHtml = true;
//SmtpClient smtp = new SmtpClient("mail.codevoir.com");
//NetworkCredential Credentials = new NetworkCredential("infoesquall@codevoir.com", "Abc123!@#");
//smtp.UseDefaultCredentials = false;
//smtp.Credentials = Credentials;
//smtp.Port = 8889; //25 alternative port number is 8889
//smtp.EnableSsl = false;
//smtp.Send(mail);
//var apiKey = Environment.GetEnvironmentVariable("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\r\n");
//var apiKey1 = Environment.GetEnvironmentVariable("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");
// var apiKey2 = Environment.GetEnvironmentVariable("SENDGRID_API_KEY");
var apiKey = _configuration.GetValue<string>("SendGrid:ApiKey");
//var apiKey = "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";
var client = new SendGridClient(apiKey);
var from = new EmailAddress("tech@seahavenind.com", "Sea haven Industries");
//var subject = "Sending with SendGrid is Fun";
var to = new EmailAddress(emailTo, "");
var apiKey3 = Environment.GetEnvironmentVariable("SendGrid:ApiKey");
var plainTextContent = "";
var htmlContent = body;
var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
var response = await client.SendEmailAsync(msg);
var dd = response.Body.ReadAsStringAsync();
return true;
}
catch (Exception ex)
{
return false;
}
}
public async Task<bool> SendEMailAttachment(string emailTo, string subject, byte[] pdfBytes)
{
try
{
var apiKey = _configuration.GetValue<string>("SendGrid:ApiKey");
//var apiKey = "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";
var client = new SendGridClient(apiKey);
var from = new EmailAddress("tech@seahavenind.com", "Sea haven Industries");
//var subject = "Sending with SendGrid is Fun";
var to = new EmailAddress(emailTo, "");
var apiKey3 = Environment.GetEnvironmentVariable("SendGrid:ApiKey");
var plainTextContent = "Please find the attached PDF";
var htmlContent = "";
var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, null);
// Specify the content type for the attachment
var attachment = new SendGrid.Helpers.Mail.Attachment
{
Content = Convert.ToBase64String(pdfBytes),
Filename = "Workorder.pdf",
Type = "application/pdf", // Use the correct MIME type for PDF
Disposition = "attachment",
ContentId = "Attachment" // Optional: ContentId for inline attachments
};
msg.Attachments = new List<SendGrid.Helpers.Mail.Attachment> { attachment };
var response = await client.SendEmailAsync(msg);
var dd = response.Body.ReadAsStringAsync();
return true;
}
catch (Exception ex)
{
return false;
}
}
}
}

View file

@ -0,0 +1,10 @@
using Microsoft.AspNetCore.Components.Forms;
namespace Api.SeaHavenIndustries.Helper.ViewModel
{
public class FileUploadVM
{
public IBrowserFile? file { get; set; }
public string? Name { get; set; }
}
}

View file

@ -0,0 +1,12 @@
namespace Api.SeaHavenIndustries.Helper.ViewModel
{
public class UserRoleViewModel
{
public string? Id { get; set; }
public string? UserName { get; set; }
public string? Email { get; set; }
public string? RoleName { get; set; }
public string? Status { get; set; }
public string? Date { get; set; }
}
}

View file

@ -0,0 +1,104 @@
using Api.SeaHavenIndustries.Helper;
using Data.SeaHavenIndustries;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.ResponseCompression;
using Microsoft.EntityFrameworkCore;
using Microsoft.IdentityModel.Tokens;
using Microsoft.OpenApi.Models;
using System.Text;
var builder = WebApplication.CreateBuilder(args);
ConfigurationManager configuration = builder.Configuration;
builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(configuration.GetConnectionString("DefaultConnection")));
builder.Services.AddIdentity<ApplicationUser, IdentityRole>(options =>
{
options.User.RequireUniqueEmail = false;
})
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
builder.Services.AddControllers().AddJsonOptions(options =>
{
options.JsonSerializerOptions.MaxDepth = 264; // or any other desired value
});
builder.Services.AddResponseCompression(opts =>
{
opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(
new[] { "application/octet-stream" });
});
builder.Services.AddCors(option =>
option.AddDefaultPolicy(builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()));
builder.Services.AddScoped<SendMessage>();
builder.Services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(options =>
{
options.SaveToken = true;
options.RequireHttpsMetadata = false;
options.TokenValidationParameters = new TokenValidationParameters()
{
ValidateIssuer = true,
ValidateAudience = true,
ValidAudience = configuration["JWT:ValidAudience"],
ValidIssuer = configuration["JWT:ValidIssuer"],
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configuration["JWT:Secret"]))
};
});
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Seahaven", Version = "v1" });
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme()
{
Name = "Authorization",
Type = SecuritySchemeType.ApiKey,
Scheme = "Bearer",
BearerFormat = "JWT",
In = ParameterLocation.Header,
Description = "JWT Authorization header using the Bearer scheme. \r\n\r\n Enter 'Bearer' [space] and then your token in the text input below.\r\n\r\nExample: \"Bearer 12345abcdef\"",
});
c.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Id = "Bearer"
}
},
new string[] {}
}
});
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment() || app.Environment.IsProduction())
{
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Sari");
c.RoutePrefix = string.Empty;
});
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCors();
app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();
app.Run();

View file

@ -0,0 +1,41 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:44666",
"sslPort": 44317
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5141",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7195;http://localhost:5141",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View file

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View file

@ -0,0 +1,23 @@
{
"ConnectionStrings": {
//"DefaultConnection": "Server=DESKTOP-64LC14O\SQLEXPRESS;Database=SeahavenIndustries;TrustServerCertificate=True;Trusted_Connection=True;MultipleActiveResultSets=true",
// Test database
"DefaultConnection": "Server=SQL5112.site4now.net;Initial Catalog=db_a7141e_seahavenindustries;User Id=db_a7141e_seahavenindustries_admin;Password=Abc123!@#;MultipleActiveResultSets=true"
//Client Database
//"DefaultConnection": "Server=SQL5112.site4now.net;Initial Catalog=db_a7141e_seahavenindustry;User Id=db_a7141e_seahavenindustry_admin;Password=Abc123!@#;MultipleActiveResultSets=true",
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"JWT": {
"ValidAudience": "http://localhost:4200",
"ValidIssuer": "http://localhost:7195",
"Secret": "JWTAuthenticationHIGHsecuredPasswordVVVp1OH7Xzyr"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

View file

@ -0,0 +1,71 @@

using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data;
using System.Linq;
namespace Data.SeaHavenIndustries
{
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
foreach (var foreignKey in builder.Model.GetEntityTypes().SelectMany
(e => e.GetForeignKeys()))
{
foreignKey.DeleteBehavior = DeleteBehavior.Restrict;
}
}
public DbSet<Category> Categories { get; set; }
public DbSet<Locations> Locations { get; set; }
public DbSet<Contacts> Contacts { get; set; }
public DbSet<WorkOrder> workOrders { get; set; }
public DbSet<Template> Templates { get; set; }
public DbSet<Comments> Comments { get; set; }
public DbSet<Quotes> Quotes { get; set; }
public DbSet<QuotesLineItems> QuotesLines { get; set; }
public DbSet<ForgetPasswordCode> ForgetPasswordCodes { get; set; }
public DbSet<WorkOrderContacts> WorkOrderContacts { get; set; }
public DbSet<WorkOrderCategories> workOrderCategories { get; set; }
public DbSet<WorkOrderAttachments> workOrderAttachments { get; set; }
}
public class ApplicationUser : IdentityUser
{
public string? FirstName { get; set; }
public string? LastName { get; set; }
public string? UniqueName { get; set; }
public string? Locations { get; set; }
public string? Contact { get; set; }
public DateTime? CreatedDate { get; set; }
public DateTime? DeletedDate { get; set; }
public bool? IsDeleted { get; set; }
public string? UserImage { get; set; }
public int? Type { get; set; } // 1 for users 0 for admin
public ICollection<Template>? Templates { get; set; }
public ICollection<WorkOrder>? WorkOrders { get; set; }
}
public class FullAuditEntity
{
[Key]
public int Id { get; set; }
public bool? IsDeleted { get; set; }
public string? createdby { get; set; }
public string? DeleterUserId { get; set; }
public DateTime? DeletionTime { get; set; }
public DateTime? CreatedDate { get; set; }
public DateTime? LastModificationTime { get; set; }
public int? LastModifierUserId { get; set; }
}
}

View file

@ -0,0 +1,63 @@
using System.ComponentModel.DataAnnotations;
namespace Data.SeaHavenIndustries
{
public static class UserRoles
{
public const string Admin = "ADMIN";
}
public class RegisterModel
{
[EmailAddress]
[Required(ErrorMessage = "Email is required")]
public string? Email { get; set; }
[Required(ErrorMessage = "Password is required")]
public string? Password { get; set; }
public int CountryId { get; set; }
public string? UserDisplayName { get; set; }
public string? PhoneNumber { get; set; }
}
public class RegisterUserModel
{
[EmailAddress]
[Required(ErrorMessage = "Email is required")]
public string? Email { get; set; }
[Required(ErrorMessage = "Password is required")]
public string? Password { get; set; }
}
public class LoginModel
{
[Required(ErrorMessage = "User Name is required")]
public string? Username { get; set; }
[Required(ErrorMessage = "Password is required")]
public string? Password { get; set; }
}
public class ChangePasswords
{
[Required(ErrorMessage = "Currentpassword is required")]
public string? Currentpassword { get; set; }
[Required(ErrorMessage = "Newpassword is required")]
public string? Newpassword { get; set; }
[Compare("Newpassword", ErrorMessage = "Password and Confirmation Password must match.")]
public string? Confirmpassword { get; set; }
}
public class Response
{
public string? Status { get; set; }
public string? Message { get; set; }
}
public class DataResponse
{
public string? Status { get; set; }
public string? Message { get; set; }
public dynamic? Data { get; set; }
}
}

View file

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.4" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,768 @@
// <auto-generated />
using System;
using Data.SeaHavenIndustries;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Data.SeaHavenIndustries.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20231215102707_initialdb")]
partial class initialdb
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.12")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Data.SeaHavenIndustries.ApplicationUser", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<int>("AccessFailedCount")
.HasColumnType("int");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("nvarchar(max)");
b.Property<string>("Contact")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DeletedDate")
.HasColumnType("datetime2");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("bit");
b.Property<string>("FirstName")
.HasColumnType("nvarchar(max)");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("LastName")
.HasColumnType("nvarchar(max)");
b.Property<string>("Locations")
.HasColumnType("nvarchar(max)");
b.Property<bool>("LockoutEnabled")
.HasColumnType("bit");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("datetimeoffset");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<string>("PasswordHash")
.HasColumnType("nvarchar(max)");
b.Property<string>("PhoneNumber")
.HasColumnType("nvarchar(max)");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("bit");
b.Property<string>("SecurityStamp")
.HasColumnType("nvarchar(max)");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("bit");
b.Property<int?>("Type")
.HasColumnType("int");
b.Property<string>("UniqueName")
.HasColumnType("nvarchar(max)");
b.Property<string>("UserImage")
.HasColumnType("nvarchar(max)");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex")
.HasFilter("[NormalizedUserName] IS NOT NULL");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("Data.SeaHavenIndustries.Category", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<string>("DeleterUserId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2");
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<string>("createdby")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Categories");
});
modelBuilder.Entity("Data.SeaHavenIndustries.Comments", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<string>("DeleterUserId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2");
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<string>("Latitude")
.HasColumnType("nvarchar(max)");
b.Property<string>("Longitude")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.HasColumnType("nvarchar(max)");
b.Property<int?>("WorkerOrderId")
.HasColumnType("int");
b.Property<string>("createdby")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("WorkerOrderId");
b.ToTable("Comments");
});
modelBuilder.Entity("Data.SeaHavenIndustries.Contacts", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<string>("DeleterUserId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2");
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2");
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<string>("PhoneNumber")
.HasColumnType("nvarchar(max)");
b.Property<string>("createdby")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Contacts");
});
modelBuilder.Entity("Data.SeaHavenIndustries.Locations", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<string>("DeleterUserId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2");
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<string>("Latitude")
.HasColumnType("nvarchar(max)");
b.Property<string>("Longitude")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.HasColumnType("nvarchar(max)");
b.Property<string>("createdby")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Locations");
});
modelBuilder.Entity("Data.SeaHavenIndustries.Template", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("AfterPhotoAttachment")
.HasColumnType("nvarchar(max)");
b.Property<string>("AfterPhotoIssue")
.HasColumnType("nvarchar(max)");
b.Property<string>("AssignTo")
.HasColumnType("nvarchar(450)");
b.Property<string>("Attachments")
.HasColumnType("nvarchar(max)");
b.Property<string>("BeforPhotoAttachment")
.HasColumnType("nvarchar(max)");
b.Property<string>("BeforPhotoIssue")
.HasColumnType("nvarchar(max)");
b.Property<int?>("CategoryId")
.HasColumnType("int");
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<string>("DeleterUserId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DueDate")
.HasColumnType("datetime2");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2");
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<int?>("LocationId")
.HasColumnType("int");
b.Property<string>("PO")
.HasColumnType("nvarchar(max)");
b.Property<string>("POC")
.HasColumnType("nvarchar(max)");
b.Property<string>("Priority")
.HasColumnType("nvarchar(max)");
b.Property<string>("SignOffName")
.HasColumnType("nvarchar(max)");
b.Property<string>("SignOffSignature")
.HasColumnType("nvarchar(max)");
b.Property<string>("Status")
.HasColumnType("nvarchar(max)");
b.Property<string>("TT")
.HasColumnType("nvarchar(max)");
b.Property<string>("WorkerOrderNumber")
.HasColumnType("nvarchar(max)");
b.Property<string>("WorkerOrderTitle")
.HasColumnType("nvarchar(max)");
b.Property<string>("createdby")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("AssignTo");
b.HasIndex("CategoryId");
b.HasIndex("LocationId");
b.ToTable("Template");
});
modelBuilder.Entity("Data.SeaHavenIndustries.WorkerOrder", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("AfterPhotoAttachment")
.HasColumnType("nvarchar(max)");
b.Property<string>("AfterPhotoIssue")
.HasColumnType("nvarchar(max)");
b.Property<string>("AssignTo")
.HasColumnType("nvarchar(450)");
b.Property<string>("Attachments")
.HasColumnType("nvarchar(max)");
b.Property<string>("BeforPhotoAttachment")
.HasColumnType("nvarchar(max)");
b.Property<string>("BeforPhotoIssue")
.HasColumnType("nvarchar(max)");
b.Property<int?>("CategoryId")
.HasColumnType("int");
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<string>("DeleterUserId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DueDate")
.HasColumnType("datetime2");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2");
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<int?>("LocationId")
.HasColumnType("int");
b.Property<string>("PO")
.HasColumnType("nvarchar(max)");
b.Property<string>("POC")
.HasColumnType("nvarchar(max)");
b.Property<string>("Priority")
.HasColumnType("nvarchar(max)");
b.Property<string>("SignOffName")
.HasColumnType("nvarchar(max)");
b.Property<string>("SignOffSignature")
.HasColumnType("nvarchar(max)");
b.Property<string>("Status")
.HasColumnType("nvarchar(max)");
b.Property<string>("TT")
.HasColumnType("nvarchar(max)");
b.Property<string>("WorkerOrderNumber")
.HasColumnType("nvarchar(max)");
b.Property<string>("WorkerOrderTitle")
.HasColumnType("nvarchar(max)");
b.Property<string>("createdby")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("AssignTo");
b.HasIndex("CategoryId");
b.HasIndex("LocationId");
b.ToTable("WorkerOrder");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex")
.HasFilter("[NormalizedName] IS NOT NULL");
b.ToTable("AspNetRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)");
b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)");
b.Property<string>("RoleId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)");
b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider")
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
b.Property<string>("ProviderKey")
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
b.Property<string>("ProviderDisplayName")
.HasColumnType("nvarchar(max)");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("nvarchar(450)");
b.Property<string>("RoleId")
.HasColumnType("nvarchar(450)");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("nvarchar(450)");
b.Property<string>("LoginProvider")
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
b.Property<string>("Name")
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
b.Property<string>("Value")
.HasColumnType("nvarchar(max)");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("Data.SeaHavenIndustries.Comments", b =>
{
b.HasOne("Data.SeaHavenIndustries.WorkerOrder", "WorkerOrder")
.WithMany("Comments")
.HasForeignKey("WorkerOrderId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("WorkerOrder");
});
modelBuilder.Entity("Data.SeaHavenIndustries.Template", b =>
{
b.HasOne("Data.SeaHavenIndustries.ApplicationUser", "AssignToUser")
.WithMany("Templates")
.HasForeignKey("AssignTo")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Data.SeaHavenIndustries.Category", "Category")
.WithMany("Templates")
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Data.SeaHavenIndustries.Locations", "Locations")
.WithMany("Templates")
.HasForeignKey("LocationId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("AssignToUser");
b.Navigation("Category");
b.Navigation("Locations");
});
modelBuilder.Entity("Data.SeaHavenIndustries.WorkerOrder", b =>
{
b.HasOne("Data.SeaHavenIndustries.ApplicationUser", "AssignToUser")
.WithMany("WorkerOrder")
.HasForeignKey("AssignTo")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Data.SeaHavenIndustries.Category", "Category")
.WithMany("WorkerOrder")
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Data.SeaHavenIndustries.Locations", "Locations")
.WithMany("WorkerOrder")
.HasForeignKey("LocationId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("AssignToUser");
b.Navigation("Category");
b.Navigation("Locations");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("Data.SeaHavenIndustries.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("Data.SeaHavenIndustries.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("Data.SeaHavenIndustries.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("Data.SeaHavenIndustries.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Data.SeaHavenIndustries.ApplicationUser", b =>
{
b.Navigation("Templates");
b.Navigation("WorkerOrder");
});
modelBuilder.Entity("Data.SeaHavenIndustries.Category", b =>
{
b.Navigation("Templates");
b.Navigation("WorkerOrder");
});
modelBuilder.Entity("Data.SeaHavenIndustries.Locations", b =>
{
b.Navigation("Templates");
b.Navigation("WorkerOrder");
});
modelBuilder.Entity("Data.SeaHavenIndustries.WorkerOrder", b =>
{
b.Navigation("Comments");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,494 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Data.SeaHavenIndustries.Migrations
{
/// <inheritdoc />
public partial class initialdb : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AspNetRoles",
columns: table => new
{
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
Name = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
NormalizedName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AspNetUsers",
columns: table => new
{
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
FirstName = table.Column<string>(type: "nvarchar(max)", nullable: true),
LastName = table.Column<string>(type: "nvarchar(max)", nullable: true),
UniqueName = table.Column<string>(type: "nvarchar(max)", nullable: true),
Locations = table.Column<string>(type: "nvarchar(max)", nullable: true),
Contact = table.Column<string>(type: "nvarchar(max)", nullable: true),
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
DeletedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
UserImage = table.Column<string>(type: "nvarchar(max)", nullable: true),
Type = table.Column<int>(type: "int", nullable: true),
UserName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
NormalizedUserName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
Email = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
NormalizedEmail = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
EmailConfirmed = table.Column<bool>(type: "bit", nullable: false),
PasswordHash = table.Column<string>(type: "nvarchar(max)", nullable: true),
SecurityStamp = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(max)", nullable: true),
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: true),
PhoneNumberConfirmed = table.Column<bool>(type: "bit", nullable: false),
TwoFactorEnabled = table.Column<bool>(type: "bit", nullable: false),
LockoutEnd = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
LockoutEnabled = table.Column<bool>(type: "bit", nullable: false),
AccessFailedCount = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Categories",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
createdby = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeleterUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierUserId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Categories", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Contacts",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: true),
Email = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
createdby = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeleterUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierUserId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Contacts", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Locations",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(max)", nullable: true),
Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
Latitude = table.Column<string>(type: "nvarchar(max)", nullable: true),
Longitude = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
createdby = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeleterUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierUserId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Locations", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AspNetRoleClaims",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
RoleId = table.Column<string>(type: "nvarchar(450)", nullable: false),
ClaimType = table.Column<string>(type: "nvarchar(max)", nullable: true),
ClaimValue = table.Column<string>(type: "nvarchar(max)", 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.Restrict);
});
migrationBuilder.CreateTable(
name: "AspNetUserClaims",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
ClaimType = table.Column<string>(type: "nvarchar(max)", nullable: true),
ClaimValue = table.Column<string>(type: "nvarchar(max)", 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.Restrict);
});
migrationBuilder.CreateTable(
name: "AspNetUserLogins",
columns: table => new
{
LoginProvider = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
ProviderKey = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
ProviderDisplayName = table.Column<string>(type: "nvarchar(max)", nullable: true),
UserId = table.Column<string>(type: "nvarchar(450)", 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.Restrict);
});
migrationBuilder.CreateTable(
name: "AspNetUserRoles",
columns: table => new
{
UserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
RoleId = table.Column<string>(type: "nvarchar(450)", 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.Restrict);
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "AspNetUserTokens",
columns: table => new
{
UserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
LoginProvider = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
Name = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
Value = table.Column<string>(type: "nvarchar(max)", 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.Restrict);
});
migrationBuilder.CreateTable(
name: "Template",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
WorkerOrderNumber = table.Column<string>(type: "nvarchar(max)", nullable: true),
WorkerOrderTitle = table.Column<string>(type: "nvarchar(max)", nullable: true),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
PO = table.Column<string>(type: "nvarchar(max)", nullable: true),
TT = table.Column<string>(type: "nvarchar(max)", nullable: true),
POC = table.Column<string>(type: "nvarchar(max)", nullable: true),
AssignTo = table.Column<string>(type: "nvarchar(450)", nullable: true),
DueDate = table.Column<DateTime>(type: "datetime2", nullable: true),
Priority = table.Column<string>(type: "nvarchar(max)", nullable: true),
Status = table.Column<string>(type: "nvarchar(max)", nullable: true),
LocationId = table.Column<int>(type: "int", nullable: true),
CategoryId = table.Column<int>(type: "int", nullable: true),
Attachments = table.Column<string>(type: "nvarchar(max)", nullable: true),
BeforPhotoIssue = table.Column<string>(type: "nvarchar(max)", nullable: true),
BeforPhotoAttachment = table.Column<string>(type: "nvarchar(max)", nullable: true),
AfterPhotoIssue = table.Column<string>(type: "nvarchar(max)", nullable: true),
AfterPhotoAttachment = table.Column<string>(type: "nvarchar(max)", nullable: true),
SignOffName = table.Column<string>(type: "nvarchar(max)", nullable: true),
SignOffSignature = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
createdby = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeleterUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierUserId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Template", x => x.Id);
table.ForeignKey(
name: "FK_Template_AspNetUsers_AssignTo",
column: x => x.AssignTo,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Template_Categories_CategoryId",
column: x => x.CategoryId,
principalTable: "Categories",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Template_Locations_LocationId",
column: x => x.LocationId,
principalTable: "Locations",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "WorkerOrder",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
WorkerOrderNumber = table.Column<string>(type: "nvarchar(max)", nullable: true),
WorkerOrderTitle = table.Column<string>(type: "nvarchar(max)", nullable: true),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
PO = table.Column<string>(type: "nvarchar(max)", nullable: true),
TT = table.Column<string>(type: "nvarchar(max)", nullable: true),
POC = table.Column<string>(type: "nvarchar(max)", nullable: true),
AssignTo = table.Column<string>(type: "nvarchar(450)", nullable: true),
DueDate = table.Column<DateTime>(type: "datetime2", nullable: true),
Priority = table.Column<string>(type: "nvarchar(max)", nullable: true),
Status = table.Column<string>(type: "nvarchar(max)", nullable: true),
LocationId = table.Column<int>(type: "int", nullable: true),
CategoryId = table.Column<int>(type: "int", nullable: true),
Attachments = table.Column<string>(type: "nvarchar(max)", nullable: true),
BeforPhotoIssue = table.Column<string>(type: "nvarchar(max)", nullable: true),
BeforPhotoAttachment = table.Column<string>(type: "nvarchar(max)", nullable: true),
AfterPhotoIssue = table.Column<string>(type: "nvarchar(max)", nullable: true),
AfterPhotoAttachment = table.Column<string>(type: "nvarchar(max)", nullable: true),
SignOffName = table.Column<string>(type: "nvarchar(max)", nullable: true),
SignOffSignature = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
createdby = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeleterUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierUserId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_WorkerOrder", x => x.Id);
table.ForeignKey(
name: "FK_WorkerOrder_AspNetUsers_AssignTo",
column: x => x.AssignTo,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_WorkerOrder_Categories_CategoryId",
column: x => x.CategoryId,
principalTable: "Categories",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_WorkerOrder_Locations_LocationId",
column: x => x.LocationId,
principalTable: "Locations",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Comments",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(max)", nullable: true),
Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
Latitude = table.Column<string>(type: "nvarchar(max)", nullable: true),
Longitude = table.Column<string>(type: "nvarchar(max)", nullable: true),
WorkerOrderId = table.Column<int>(type: "int", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
createdby = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeleterUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierUserId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Comments", x => x.Id);
table.ForeignKey(
name: "FK_Comments_WorkerOrder_WorkerOrderId",
column: x => x.WorkerOrderId,
principalTable: "WorkerOrder",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
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");
migrationBuilder.CreateIndex(
name: "IX_Comments_WorkerOrderId",
table: "Comments",
column: "WorkerOrderId");
migrationBuilder.CreateIndex(
name: "IX_Template_AssignTo",
table: "Template",
column: "AssignTo");
migrationBuilder.CreateIndex(
name: "IX_Template_CategoryId",
table: "Template",
column: "CategoryId");
migrationBuilder.CreateIndex(
name: "IX_Template_LocationId",
table: "Template",
column: "LocationId");
migrationBuilder.CreateIndex(
name: "IX_WorkerOrder_AssignTo",
table: "WorkerOrder",
column: "AssignTo");
migrationBuilder.CreateIndex(
name: "IX_WorkerOrder_CategoryId",
table: "WorkerOrder",
column: "CategoryId");
migrationBuilder.CreateIndex(
name: "IX_WorkerOrder_LocationId",
table: "WorkerOrder",
column: "LocationId");
}
/// <inheritdoc />
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: "Comments");
migrationBuilder.DropTable(
name: "Contacts");
migrationBuilder.DropTable(
name: "Template");
migrationBuilder.DropTable(
name: "AspNetRoles");
migrationBuilder.DropTable(
name: "WorkerOrder");
migrationBuilder.DropTable(
name: "AspNetUsers");
migrationBuilder.DropTable(
name: "Categories");
migrationBuilder.DropTable(
name: "Locations");
}
}
}

View file

@ -0,0 +1,768 @@
// <auto-generated />
using System;
using Data.SeaHavenIndustries;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Data.SeaHavenIndustries.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20231219074535_changesinaddwork")]
partial class changesinaddwork
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.12")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Data.SeaHavenIndustries.ApplicationUser", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<int>("AccessFailedCount")
.HasColumnType("int");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("nvarchar(max)");
b.Property<string>("Contact")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DeletedDate")
.HasColumnType("datetime2");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("bit");
b.Property<string>("FirstName")
.HasColumnType("nvarchar(max)");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("LastName")
.HasColumnType("nvarchar(max)");
b.Property<string>("Locations")
.HasColumnType("nvarchar(max)");
b.Property<bool>("LockoutEnabled")
.HasColumnType("bit");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("datetimeoffset");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<string>("PasswordHash")
.HasColumnType("nvarchar(max)");
b.Property<string>("PhoneNumber")
.HasColumnType("nvarchar(max)");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("bit");
b.Property<string>("SecurityStamp")
.HasColumnType("nvarchar(max)");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("bit");
b.Property<int?>("Type")
.HasColumnType("int");
b.Property<string>("UniqueName")
.HasColumnType("nvarchar(max)");
b.Property<string>("UserImage")
.HasColumnType("nvarchar(max)");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex")
.HasFilter("[NormalizedUserName] IS NOT NULL");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("Data.SeaHavenIndustries.Category", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<string>("DeleterUserId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2");
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<string>("createdby")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Categories");
});
modelBuilder.Entity("Data.SeaHavenIndustries.Comments", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<string>("DeleterUserId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2");
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<string>("Latitude")
.HasColumnType("nvarchar(max)");
b.Property<string>("Longitude")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.HasColumnType("nvarchar(max)");
b.Property<int?>("WorkerOrderId")
.HasColumnType("int");
b.Property<string>("createdby")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("WorkerOrderId");
b.ToTable("Comments");
});
modelBuilder.Entity("Data.SeaHavenIndustries.Contacts", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<string>("DeleterUserId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2");
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2");
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<string>("PhoneNumber")
.HasColumnType("nvarchar(max)");
b.Property<string>("createdby")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Contacts");
});
modelBuilder.Entity("Data.SeaHavenIndustries.Locations", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<string>("DeleterUserId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2");
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<string>("Latitude")
.HasColumnType("nvarchar(max)");
b.Property<string>("Longitude")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.HasColumnType("nvarchar(max)");
b.Property<string>("createdby")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Locations");
});
modelBuilder.Entity("Data.SeaHavenIndustries.Template", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("AfterPhotoAttachment")
.HasColumnType("nvarchar(max)");
b.Property<string>("AfterPhotoIssue")
.HasColumnType("nvarchar(max)");
b.Property<string>("AssignTo")
.HasColumnType("nvarchar(450)");
b.Property<string>("Attachments")
.HasColumnType("nvarchar(max)");
b.Property<string>("BeforPhotoAttachment")
.HasColumnType("nvarchar(max)");
b.Property<string>("BeforPhotoIssue")
.HasColumnType("nvarchar(max)");
b.Property<int?>("CategoryId")
.HasColumnType("int");
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<string>("DeleterUserId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DueDate")
.HasColumnType("datetime2");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2");
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<int?>("LocationId")
.HasColumnType("int");
b.Property<string>("PO")
.HasColumnType("nvarchar(max)");
b.Property<string>("POC")
.HasColumnType("nvarchar(max)");
b.Property<string>("Priority")
.HasColumnType("nvarchar(max)");
b.Property<string>("SignOffName")
.HasColumnType("nvarchar(max)");
b.Property<string>("SignOffSignature")
.HasColumnType("nvarchar(max)");
b.Property<string>("Status")
.HasColumnType("nvarchar(max)");
b.Property<string>("TT")
.HasColumnType("nvarchar(max)");
b.Property<string>("WorkerOrderNumber")
.HasColumnType("nvarchar(max)");
b.Property<string>("WorkerOrderTitle")
.HasColumnType("nvarchar(max)");
b.Property<string>("createdby")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("AssignTo");
b.HasIndex("CategoryId");
b.HasIndex("LocationId");
b.ToTable("Templates");
});
modelBuilder.Entity("Data.SeaHavenIndustries.WorkOrder", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("AfterPhotoAttachment")
.HasColumnType("nvarchar(max)");
b.Property<string>("AfterPhotoIssue")
.HasColumnType("nvarchar(max)");
b.Property<string>("AssignTo")
.HasColumnType("nvarchar(450)");
b.Property<string>("Attachments")
.HasColumnType("nvarchar(max)");
b.Property<string>("BeforPhotoAttachment")
.HasColumnType("nvarchar(max)");
b.Property<string>("BeforPhotoIssue")
.HasColumnType("nvarchar(max)");
b.Property<int?>("CategoryId")
.HasColumnType("int");
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<string>("DeleterUserId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DueDate")
.HasColumnType("datetime2");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2");
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<int?>("LocationId")
.HasColumnType("int");
b.Property<string>("PO")
.HasColumnType("nvarchar(max)");
b.Property<string>("POC")
.HasColumnType("nvarchar(max)");
b.Property<string>("Priority")
.HasColumnType("nvarchar(max)");
b.Property<string>("SignOffName")
.HasColumnType("nvarchar(max)");
b.Property<string>("SignOffSignature")
.HasColumnType("nvarchar(max)");
b.Property<string>("Status")
.HasColumnType("nvarchar(max)");
b.Property<string>("TT")
.HasColumnType("nvarchar(max)");
b.Property<string>("WorkerOrderNumber")
.HasColumnType("nvarchar(max)");
b.Property<string>("WorkerOrderTitle")
.HasColumnType("nvarchar(max)");
b.Property<string>("createdby")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("AssignTo");
b.HasIndex("CategoryId");
b.HasIndex("LocationId");
b.ToTable("workOrders");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex")
.HasFilter("[NormalizedName] IS NOT NULL");
b.ToTable("AspNetRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)");
b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)");
b.Property<string>("RoleId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)");
b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider")
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
b.Property<string>("ProviderKey")
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
b.Property<string>("ProviderDisplayName")
.HasColumnType("nvarchar(max)");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("nvarchar(450)");
b.Property<string>("RoleId")
.HasColumnType("nvarchar(450)");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("nvarchar(450)");
b.Property<string>("LoginProvider")
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
b.Property<string>("Name")
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
b.Property<string>("Value")
.HasColumnType("nvarchar(max)");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("Data.SeaHavenIndustries.Comments", b =>
{
b.HasOne("Data.SeaHavenIndustries.WorkOrder", "WorkOrder")
.WithMany("Comments")
.HasForeignKey("WorkerOrderId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("WorkOrder");
});
modelBuilder.Entity("Data.SeaHavenIndustries.Template", b =>
{
b.HasOne("Data.SeaHavenIndustries.ApplicationUser", "AssignToUser")
.WithMany("Templates")
.HasForeignKey("AssignTo")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Data.SeaHavenIndustries.Category", "Category")
.WithMany("Templates")
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Data.SeaHavenIndustries.Locations", "Locations")
.WithMany("Templates")
.HasForeignKey("LocationId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("AssignToUser");
b.Navigation("Category");
b.Navigation("Locations");
});
modelBuilder.Entity("Data.SeaHavenIndustries.WorkOrder", b =>
{
b.HasOne("Data.SeaHavenIndustries.ApplicationUser", "AssignToUser")
.WithMany("WorkOrders")
.HasForeignKey("AssignTo")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Data.SeaHavenIndustries.Category", "Category")
.WithMany("WorkOrders")
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Data.SeaHavenIndustries.Locations", "Locations")
.WithMany("workOrders")
.HasForeignKey("LocationId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("AssignToUser");
b.Navigation("Category");
b.Navigation("Locations");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("Data.SeaHavenIndustries.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("Data.SeaHavenIndustries.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("Data.SeaHavenIndustries.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("Data.SeaHavenIndustries.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Data.SeaHavenIndustries.ApplicationUser", b =>
{
b.Navigation("Templates");
b.Navigation("WorkOrders");
});
modelBuilder.Entity("Data.SeaHavenIndustries.Category", b =>
{
b.Navigation("Templates");
b.Navigation("WorkOrders");
});
modelBuilder.Entity("Data.SeaHavenIndustries.Locations", b =>
{
b.Navigation("Templates");
b.Navigation("workOrders");
});
modelBuilder.Entity("Data.SeaHavenIndustries.WorkOrder", b =>
{
b.Navigation("Comments");
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,319 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Data.SeaHavenIndustries.Migrations
{
/// <inheritdoc />
public partial class changesinaddwork : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Comments_WorkerOrder_WorkerOrderId",
table: "Comments");
migrationBuilder.DropForeignKey(
name: "FK_Template_AspNetUsers_AssignTo",
table: "Template");
migrationBuilder.DropForeignKey(
name: "FK_Template_Categories_CategoryId",
table: "Template");
migrationBuilder.DropForeignKey(
name: "FK_Template_Locations_LocationId",
table: "Template");
migrationBuilder.DropTable(
name: "WorkerOrder");
migrationBuilder.DropPrimaryKey(
name: "PK_Template",
table: "Template");
migrationBuilder.RenameTable(
name: "Template",
newName: "Templates");
migrationBuilder.RenameIndex(
name: "IX_Template_LocationId",
table: "Templates",
newName: "IX_Templates_LocationId");
migrationBuilder.RenameIndex(
name: "IX_Template_CategoryId",
table: "Templates",
newName: "IX_Templates_CategoryId");
migrationBuilder.RenameIndex(
name: "IX_Template_AssignTo",
table: "Templates",
newName: "IX_Templates_AssignTo");
migrationBuilder.AddPrimaryKey(
name: "PK_Templates",
table: "Templates",
column: "Id");
migrationBuilder.CreateTable(
name: "workOrders",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
WorkerOrderNumber = table.Column<string>(type: "nvarchar(max)", nullable: true),
WorkerOrderTitle = table.Column<string>(type: "nvarchar(max)", nullable: true),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
PO = table.Column<string>(type: "nvarchar(max)", nullable: true),
TT = table.Column<string>(type: "nvarchar(max)", nullable: true),
POC = table.Column<string>(type: "nvarchar(max)", nullable: true),
AssignTo = table.Column<string>(type: "nvarchar(450)", nullable: true),
DueDate = table.Column<DateTime>(type: "datetime2", nullable: true),
Priority = table.Column<string>(type: "nvarchar(max)", nullable: true),
Status = table.Column<string>(type: "nvarchar(max)", nullable: true),
LocationId = table.Column<int>(type: "int", nullable: true),
CategoryId = table.Column<int>(type: "int", nullable: true),
Attachments = table.Column<string>(type: "nvarchar(max)", nullable: true),
BeforPhotoIssue = table.Column<string>(type: "nvarchar(max)", nullable: true),
BeforPhotoAttachment = table.Column<string>(type: "nvarchar(max)", nullable: true),
AfterPhotoIssue = table.Column<string>(type: "nvarchar(max)", nullable: true),
AfterPhotoAttachment = table.Column<string>(type: "nvarchar(max)", nullable: true),
SignOffName = table.Column<string>(type: "nvarchar(max)", nullable: true),
SignOffSignature = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
createdby = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeleterUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierUserId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_workOrders", x => x.Id);
table.ForeignKey(
name: "FK_workOrders_AspNetUsers_AssignTo",
column: x => x.AssignTo,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_workOrders_Categories_CategoryId",
column: x => x.CategoryId,
principalTable: "Categories",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_workOrders_Locations_LocationId",
column: x => x.LocationId,
principalTable: "Locations",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_workOrders_AssignTo",
table: "workOrders",
column: "AssignTo");
migrationBuilder.CreateIndex(
name: "IX_workOrders_CategoryId",
table: "workOrders",
column: "CategoryId");
migrationBuilder.CreateIndex(
name: "IX_workOrders_LocationId",
table: "workOrders",
column: "LocationId");
migrationBuilder.AddForeignKey(
name: "FK_Comments_workOrders_WorkerOrderId",
table: "Comments",
column: "WorkerOrderId",
principalTable: "workOrders",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Templates_AspNetUsers_AssignTo",
table: "Templates",
column: "AssignTo",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Templates_Categories_CategoryId",
table: "Templates",
column: "CategoryId",
principalTable: "Categories",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Templates_Locations_LocationId",
table: "Templates",
column: "LocationId",
principalTable: "Locations",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Comments_workOrders_WorkerOrderId",
table: "Comments");
migrationBuilder.DropForeignKey(
name: "FK_Templates_AspNetUsers_AssignTo",
table: "Templates");
migrationBuilder.DropForeignKey(
name: "FK_Templates_Categories_CategoryId",
table: "Templates");
migrationBuilder.DropForeignKey(
name: "FK_Templates_Locations_LocationId",
table: "Templates");
migrationBuilder.DropTable(
name: "workOrders");
migrationBuilder.DropPrimaryKey(
name: "PK_Templates",
table: "Templates");
migrationBuilder.RenameTable(
name: "Templates",
newName: "Template");
migrationBuilder.RenameIndex(
name: "IX_Templates_LocationId",
table: "Template",
newName: "IX_Template_LocationId");
migrationBuilder.RenameIndex(
name: "IX_Templates_CategoryId",
table: "Template",
newName: "IX_Template_CategoryId");
migrationBuilder.RenameIndex(
name: "IX_Templates_AssignTo",
table: "Template",
newName: "IX_Template_AssignTo");
migrationBuilder.AddPrimaryKey(
name: "PK_Template",
table: "Template",
column: "Id");
migrationBuilder.CreateTable(
name: "WorkerOrder",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
AssignTo = table.Column<string>(type: "nvarchar(450)", nullable: true),
CategoryId = table.Column<int>(type: "int", nullable: true),
LocationId = table.Column<int>(type: "int", nullable: true),
AfterPhotoAttachment = table.Column<string>(type: "nvarchar(max)", nullable: true),
AfterPhotoIssue = table.Column<string>(type: "nvarchar(max)", nullable: true),
Attachments = table.Column<string>(type: "nvarchar(max)", nullable: true),
BeforPhotoAttachment = table.Column<string>(type: "nvarchar(max)", nullable: true),
BeforPhotoIssue = table.Column<string>(type: "nvarchar(max)", nullable: true),
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
DeleterUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
DueDate = table.Column<DateTime>(type: "datetime2", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierUserId = table.Column<int>(type: "int", nullable: true),
PO = table.Column<string>(type: "nvarchar(max)", nullable: true),
POC = table.Column<string>(type: "nvarchar(max)", nullable: true),
Priority = table.Column<string>(type: "nvarchar(max)", nullable: true),
SignOffName = table.Column<string>(type: "nvarchar(max)", nullable: true),
SignOffSignature = table.Column<string>(type: "nvarchar(max)", nullable: true),
Status = table.Column<string>(type: "nvarchar(max)", nullable: true),
TT = table.Column<string>(type: "nvarchar(max)", nullable: true),
WorkerOrderNumber = table.Column<string>(type: "nvarchar(max)", nullable: true),
WorkerOrderTitle = table.Column<string>(type: "nvarchar(max)", nullable: true),
createdby = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_WorkerOrder", x => x.Id);
table.ForeignKey(
name: "FK_WorkerOrder_AspNetUsers_AssignTo",
column: x => x.AssignTo,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_WorkerOrder_Categories_CategoryId",
column: x => x.CategoryId,
principalTable: "Categories",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_WorkerOrder_Locations_LocationId",
column: x => x.LocationId,
principalTable: "Locations",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_WorkerOrder_AssignTo",
table: "WorkerOrder",
column: "AssignTo");
migrationBuilder.CreateIndex(
name: "IX_WorkerOrder_CategoryId",
table: "WorkerOrder",
column: "CategoryId");
migrationBuilder.CreateIndex(
name: "IX_WorkerOrder_LocationId",
table: "WorkerOrder",
column: "LocationId");
migrationBuilder.AddForeignKey(
name: "FK_Comments_WorkerOrder_WorkerOrderId",
table: "Comments",
column: "WorkerOrderId",
principalTable: "WorkerOrder",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Template_AspNetUsers_AssignTo",
table: "Template",
column: "AssignTo",
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Template_Categories_CategoryId",
table: "Template",
column: "CategoryId",
principalTable: "Categories",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Template_Locations_LocationId",
table: "Template",
column: "LocationId",
principalTable: "Locations",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
}
}

View file

@ -0,0 +1,780 @@
// <auto-generated />
using System;
using Data.SeaHavenIndustries;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Data.SeaHavenIndustries.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20231219110203_changesinaddwork2")]
partial class changesinaddwork2
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.12")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Data.SeaHavenIndustries.ApplicationUser", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<int>("AccessFailedCount")
.HasColumnType("int");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("nvarchar(max)");
b.Property<string>("Contact")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DeletedDate")
.HasColumnType("datetime2");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("bit");
b.Property<string>("FirstName")
.HasColumnType("nvarchar(max)");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<string>("LastName")
.HasColumnType("nvarchar(max)");
b.Property<string>("Locations")
.HasColumnType("nvarchar(max)");
b.Property<bool>("LockoutEnabled")
.HasColumnType("bit");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("datetimeoffset");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<string>("PasswordHash")
.HasColumnType("nvarchar(max)");
b.Property<string>("PhoneNumber")
.HasColumnType("nvarchar(max)");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("bit");
b.Property<string>("SecurityStamp")
.HasColumnType("nvarchar(max)");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("bit");
b.Property<int?>("Type")
.HasColumnType("int");
b.Property<string>("UniqueName")
.HasColumnType("nvarchar(max)");
b.Property<string>("UserImage")
.HasColumnType("nvarchar(max)");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex")
.HasFilter("[NormalizedUserName] IS NOT NULL");
b.ToTable("AspNetUsers", (string)null);
});
modelBuilder.Entity("Data.SeaHavenIndustries.Category", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<string>("DeleterUserId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2");
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<string>("createdby")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Categories");
});
modelBuilder.Entity("Data.SeaHavenIndustries.Comments", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<string>("DeleterUserId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2");
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<string>("Latitude")
.HasColumnType("nvarchar(max)");
b.Property<string>("Longitude")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.HasColumnType("nvarchar(max)");
b.Property<int?>("WorkerOrderId")
.HasColumnType("int");
b.Property<string>("createdby")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("WorkerOrderId");
b.ToTable("Comments");
});
modelBuilder.Entity("Data.SeaHavenIndustries.Contacts", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<string>("DeleterUserId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2");
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2");
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<string>("PhoneNumber")
.HasColumnType("nvarchar(max)");
b.Property<string>("createdby")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Contacts");
});
modelBuilder.Entity("Data.SeaHavenIndustries.Locations", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<string>("DeleterUserId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2");
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<string>("Latitude")
.HasColumnType("nvarchar(max)");
b.Property<string>("Longitude")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.HasColumnType("nvarchar(max)");
b.Property<string>("createdby")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Locations");
});
modelBuilder.Entity("Data.SeaHavenIndustries.Template", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("AfterPhotoAttachment")
.HasColumnType("nvarchar(max)");
b.Property<string>("AfterPhotoIssue")
.HasColumnType("nvarchar(max)");
b.Property<string>("AssignTo")
.HasColumnType("nvarchar(450)");
b.Property<string>("Attachments")
.HasColumnType("nvarchar(max)");
b.Property<string>("BeforPhotoAttachment")
.HasColumnType("nvarchar(max)");
b.Property<string>("BeforPhotoIssue")
.HasColumnType("nvarchar(max)");
b.Property<int?>("CategoryId")
.HasColumnType("int");
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<string>("DeleterUserId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DueDate")
.HasColumnType("datetime2");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2");
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<int?>("LocationId")
.HasColumnType("int");
b.Property<string>("PO")
.HasColumnType("nvarchar(max)");
b.Property<string>("POC")
.HasColumnType("nvarchar(max)");
b.Property<string>("Priority")
.HasColumnType("nvarchar(max)");
b.Property<string>("SignOffName")
.HasColumnType("nvarchar(max)");
b.Property<string>("SignOffSignature")
.HasColumnType("nvarchar(max)");
b.Property<string>("Status")
.HasColumnType("nvarchar(max)");
b.Property<string>("TT")
.HasColumnType("nvarchar(max)");
b.Property<string>("WorkerOrderNumber")
.HasColumnType("nvarchar(max)");
b.Property<string>("WorkerOrderTitle")
.HasColumnType("nvarchar(max)");
b.Property<string>("createdby")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("AssignTo");
b.HasIndex("CategoryId");
b.HasIndex("LocationId");
b.ToTable("Templates");
});
modelBuilder.Entity("Data.SeaHavenIndustries.WorkOrder", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("AfterPhotoAttachment")
.HasColumnType("nvarchar(max)");
b.Property<string>("AfterPhotoIssue")
.HasColumnType("nvarchar(max)");
b.Property<string>("AssignTo")
.HasColumnType("nvarchar(450)");
b.Property<string>("Attachments")
.HasColumnType("nvarchar(max)");
b.Property<string>("BeforPhotoAttachment")
.HasColumnType("nvarchar(max)");
b.Property<string>("BeforPhotoIssue")
.HasColumnType("nvarchar(max)");
b.Property<int?>("CategoryId")
.HasColumnType("int");
b.Property<int?>("ContactId")
.HasColumnType("int");
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<string>("DeleterUserId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DueDate")
.HasColumnType("datetime2");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2");
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<int?>("LocationId")
.HasColumnType("int");
b.Property<string>("PO")
.HasColumnType("nvarchar(max)");
b.Property<string>("Priority")
.HasColumnType("nvarchar(max)");
b.Property<string>("SignOffAttachment")
.HasColumnType("nvarchar(max)");
b.Property<string>("SignOffName")
.HasColumnType("nvarchar(max)");
b.Property<string>("SignOffSignature")
.HasColumnType("nvarchar(max)");
b.Property<string>("Status")
.HasColumnType("nvarchar(max)");
b.Property<string>("TT")
.HasColumnType("nvarchar(max)");
b.Property<string>("WorkerOrderNumber")
.HasColumnType("nvarchar(max)");
b.Property<string>("WorkerOrderTitle")
.HasColumnType("nvarchar(max)");
b.Property<string>("createdby")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("AssignTo");
b.HasIndex("CategoryId");
b.HasIndex("ContactId");
b.HasIndex("LocationId");
b.ToTable("workOrders");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex")
.HasFilter("[NormalizedName] IS NOT NULL");
b.ToTable("AspNetRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)");
b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)");
b.Property<string>("RoleId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)");
b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider")
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
b.Property<string>("ProviderKey")
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
b.Property<string>("ProviderDisplayName")
.HasColumnType("nvarchar(max)");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("nvarchar(450)");
b.Property<string>("RoleId")
.HasColumnType("nvarchar(450)");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles", (string)null);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("nvarchar(450)");
b.Property<string>("LoginProvider")
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
b.Property<string>("Name")
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
b.Property<string>("Value")
.HasColumnType("nvarchar(max)");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens", (string)null);
});
modelBuilder.Entity("Data.SeaHavenIndustries.Comments", b =>
{
b.HasOne("Data.SeaHavenIndustries.WorkOrder", "WorkOrder")
.WithMany("Comments")
.HasForeignKey("WorkerOrderId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("WorkOrder");
});
modelBuilder.Entity("Data.SeaHavenIndustries.Template", b =>
{
b.HasOne("Data.SeaHavenIndustries.ApplicationUser", "AssignToUser")
.WithMany("Templates")
.HasForeignKey("AssignTo")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Data.SeaHavenIndustries.Category", "Category")
.WithMany("Templates")
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Data.SeaHavenIndustries.Locations", "Locations")
.WithMany("Templates")
.HasForeignKey("LocationId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("AssignToUser");
b.Navigation("Category");
b.Navigation("Locations");
});
modelBuilder.Entity("Data.SeaHavenIndustries.WorkOrder", b =>
{
b.HasOne("Data.SeaHavenIndustries.ApplicationUser", "AssignToUser")
.WithMany("WorkOrders")
.HasForeignKey("AssignTo")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Data.SeaHavenIndustries.Category", "Category")
.WithMany("WorkOrders")
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Data.SeaHavenIndustries.Contacts", "POC")
.WithMany()
.HasForeignKey("ContactId")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Data.SeaHavenIndustries.Locations", "Locations")
.WithMany("workOrders")
.HasForeignKey("LocationId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("AssignToUser");
b.Navigation("Category");
b.Navigation("Locations");
b.Navigation("POC");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("Data.SeaHavenIndustries.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("Data.SeaHavenIndustries.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("Data.SeaHavenIndustries.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("Data.SeaHavenIndustries.ApplicationUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
});
modelBuilder.Entity("Data.SeaHavenIndustries.ApplicationUser", b =>
{
b.Navigation("Templates");
b.Navigation("WorkOrders");
});
modelBuilder.Entity("Data.SeaHavenIndustries.Category", b =>
{
b.Navigation("Templates");
b.Navigation("WorkOrders");
});
modelBuilder.Entity("Data.SeaHavenIndustries.Locations", b =>
{
b.Navigation("Templates");
b.Navigation("workOrders");
});
modelBuilder.Entity("Data.SeaHavenIndustries.WorkOrder", b =>
{
b.Navigation("Comments");
});
#pragma warning restore 612, 618
}
}
}

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