mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 03:43:11 +00:00
initial commit for api changes
This commit is contained in:
parent
f7260919b5
commit
9a23c41b21
10 changed files with 276 additions and 63 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.8" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.8" />
|
||||||
<PackageReference Include="SendGrid" Version="9.29.3" />
|
<PackageReference Include="SendGrid" Version="9.29.3" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||||
|
<PackageReference Include="PasswordGenerator" Version="2.1.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ using System.Diagnostics;
|
||||||
namespace Api.SeaHavenIndustries.Controllers
|
namespace Api.SeaHavenIndustries.Controllers
|
||||||
{
|
{
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("[controller]")]
|
[Route("api/Authentication")]
|
||||||
public class AuthenticationController : Controller
|
public class AuthenticationController : Controller
|
||||||
{
|
{
|
||||||
private readonly UserManager<ApplicationUser> _userManager;
|
private readonly UserManager<ApplicationUser> _userManager;
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,13 @@ using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using SendGrid.Helpers.Mail;
|
||||||
|
|
||||||
namespace Api.SeaHavenIndustries.Controllers
|
namespace Api.SeaHavenIndustries.Controllers
|
||||||
{
|
{
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("[controller]")]
|
[Route("api/Contact")]
|
||||||
public class ContactController : Controller
|
public class ContactController : Controller
|
||||||
{
|
{
|
||||||
private readonly UserManager<ApplicationUser> _userManager;
|
private readonly UserManager<ApplicationUser> _userManager;
|
||||||
|
|
@ -110,6 +111,45 @@ namespace Api.SeaHavenIndustries.Controllers
|
||||||
return Ok(viewModel);
|
return Ok(viewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[Route("GetContacts")]
|
||||||
|
public async Task<IActionResult> GetContacts()
|
||||||
|
{
|
||||||
|
var data = await _db.Contacts.ToListAsync();
|
||||||
|
return Ok(data);
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
[Route("GetLocations")]
|
||||||
|
public async Task<IActionResult> GetLocations()
|
||||||
|
{
|
||||||
|
var data = await _db.Locations.Select(s => new LocationViewModel
|
||||||
|
{
|
||||||
|
Id = s.Id,
|
||||||
|
Name = s.Title + " - " + s.Name
|
||||||
|
}).ToListAsync();
|
||||||
|
return Ok(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[Route("GetCategories")]
|
||||||
|
public async Task<IActionResult> GetCategories()
|
||||||
|
{
|
||||||
|
var data = await _db.Categories.ToListAsync();
|
||||||
|
return Ok(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[Route("GetUsers")]
|
||||||
|
public async Task<IActionResult> GetUsers()
|
||||||
|
{
|
||||||
|
var filteredUsers = await (from user in _db.Users
|
||||||
|
where !(from userRole in _db.UserRoles
|
||||||
|
join role in _db.Roles on userRole.RoleId equals role.Id
|
||||||
|
where role.Name == "Admin" || role.Name == "Manager"
|
||||||
|
select userRole.UserId).Contains(user.Id)
|
||||||
|
select user).ToListAsync();
|
||||||
|
return Ok(filteredUsers);
|
||||||
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("AddLocation")]
|
[Route("AddLocation")]
|
||||||
public async Task<IActionResult> AddLocation(Location_DTO model)
|
public async Task<IActionResult> AddLocation(Location_DTO model)
|
||||||
|
|
@ -207,5 +247,11 @@ namespace Api.SeaHavenIndustries.Controllers
|
||||||
return Ok(viewModel);
|
return Ok(viewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class LocationViewModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? Name { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ namespace Api.SeaHavenIndustries.Controllers
|
||||||
{
|
{
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("[controller]")]
|
[Route("api/Quotes")]
|
||||||
public class QuotesController : Controller
|
public class QuotesController : Controller
|
||||||
{
|
{
|
||||||
private readonly UserManager<ApplicationUser> _userManager;
|
private readonly UserManager<ApplicationUser> _userManager;
|
||||||
|
|
@ -32,8 +32,10 @@ namespace Api.SeaHavenIndustries.Controllers
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Random rnd = new Random();
|
||||||
|
int id = rnd.Next(1, 99999);
|
||||||
Quotes quotes = new Quotes();
|
Quotes quotes = new Quotes();
|
||||||
quotes.QuotId = model.QuotId;
|
quotes.QuotId = id.ToString();
|
||||||
quotes.ContactId = model.ContactId;
|
quotes.ContactId = model.ContactId;
|
||||||
quotes.PO = model.PO;
|
quotes.PO = model.PO;
|
||||||
quotes.TT = model.TT;
|
quotes.TT = model.TT;
|
||||||
|
|
@ -67,7 +69,7 @@ namespace Api.SeaHavenIndustries.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPut]
|
||||||
[Route("EditQuote")]
|
[Route("EditQuote")]
|
||||||
public async Task<IActionResult> EditQuote([FromBody] EditQuote_DTO model)
|
public async Task<IActionResult> EditQuote([FromBody] EditQuote_DTO model)
|
||||||
{
|
{
|
||||||
|
|
@ -121,10 +123,11 @@ namespace Api.SeaHavenIndustries.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpDelete]
|
||||||
[Route("DeleteQuote")]
|
[Route("DeleteQuote")]
|
||||||
public IActionResult DeleteQuote(int id)
|
public IActionResult DeleteQuote(EditQuote_DTO model)
|
||||||
{
|
{
|
||||||
|
int id = model.id;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var data = _db.Quotes.Where(w => w.Id == id).FirstOrDefault();
|
var data = _db.Quotes.Where(w => w.Id == id).FirstOrDefault();
|
||||||
|
|
@ -159,11 +162,18 @@ namespace Api.SeaHavenIndustries.Controllers
|
||||||
{
|
{
|
||||||
s.Id,
|
s.Id,
|
||||||
QuoteId = "QO-" + s.QuotId,
|
QuoteId = "QO-" + s.QuotId,
|
||||||
WOID = s.WorkOrder != null ? s.WorkOrder.WorkerOrderNumber : "",
|
WorkOrder = s.WorkOrder != null ? s.WorkOrder.WorkerOrderNumber : "",
|
||||||
s.ProjectName,
|
s.ProjectName,
|
||||||
TotalAmount = "$" + s.LineItems.Sum(s => s.Lineitem.Value).ToString(),
|
TotalAmount = "$" + s.LineItems.Sum(s => s.Lineitem.Value).ToString(),
|
||||||
siteName = s.SiteName,
|
s.SiteName,
|
||||||
status = s.Status
|
s.SiteId,
|
||||||
|
s.PO,
|
||||||
|
s.TT,
|
||||||
|
s.BillingAddress,
|
||||||
|
s.Status,
|
||||||
|
s.ContactId,
|
||||||
|
s.Date,
|
||||||
|
lineitems = s.LineItems.Select(q => new { q.Descriptions, q.Lineitem, q.LineitemNumber}),
|
||||||
}).OrderByDescending(d => d.Id).ToList().Skip((page - 1) * pageSize)
|
}).OrderByDescending(d => d.Id).ToList().Skip((page - 1) * pageSize)
|
||||||
.Take(pageSize);
|
.Take(pageSize);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
using Api.SeaHavenIndustries.DTOs;
|
using Api.SeaHavenIndustries.DTOs;
|
||||||
using Api.SeaHavenIndustries.Helper;
|
using Api.SeaHavenIndustries.Helper;
|
||||||
|
using Api.SeaHavenIndustries.Models;
|
||||||
using Data.SeaHavenIndustries;
|
using Data.SeaHavenIndustries;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PasswordGenerator;
|
||||||
|
using SendGrid.Helpers.Mail;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
|
|
@ -12,7 +15,7 @@ namespace Api.SeaHavenIndustries.Controllers
|
||||||
{
|
{
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("[controller]")]
|
[Route("api/User")]
|
||||||
public class UserController : Controller
|
public class UserController : Controller
|
||||||
{
|
{
|
||||||
private readonly UserManager<ApplicationUser> _userManager;
|
private readonly UserManager<ApplicationUser> _userManager;
|
||||||
|
|
@ -25,46 +28,106 @@ namespace Api.SeaHavenIndustries.Controllers
|
||||||
_db = db;
|
_db = db;
|
||||||
_sendemail = sendemail;
|
_sendemail = sendemail;
|
||||||
}
|
}
|
||||||
|
[Route("")]
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<IActionResult> GetUsers()
|
||||||
|
{
|
||||||
|
_db.ChangeTracker.Clear();
|
||||||
|
|
||||||
|
var allUsers = _db.Users.Select(s => new UserRoleViewModel
|
||||||
|
{
|
||||||
|
RoleName = s.PhoneNumber,
|
||||||
|
Email = s.Email,
|
||||||
|
Name = s.FirstName,
|
||||||
|
Date = s.CreatedDate != null ? s.CreatedDate.Value.Date.ToString("MMM dd yyyy") : "",
|
||||||
|
Status = s.UniqueName,
|
||||||
|
Id = s.Id
|
||||||
|
}).AsQueryable();
|
||||||
|
return Ok(allUsers);
|
||||||
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("AddUser")]
|
[Route("AddUser")]
|
||||||
public async Task<IActionResult> AddUser(User_DTO model)
|
public async Task<IActionResult> AddUser(User_DTO user)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
var model = new ApplicationUser
|
||||||
|
{
|
||||||
|
UserName = user.Email,
|
||||||
|
FirstName = user.Name,
|
||||||
|
Email = user.Email,
|
||||||
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ApplicationUser user = new ApplicationUser();
|
_db.ChangeTracker.Clear();
|
||||||
user.EmailConfirmed = true;
|
var exist = _db.Set<ApplicationUser>().Find(model.Id);
|
||||||
user.UserName = model.Email;
|
if (exist == null)
|
||||||
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 ?? "");
|
model.EmailConfirmed = true;
|
||||||
|
model.UserName = model.Email;
|
||||||
|
model.CreatedDate = DateTime.Now;
|
||||||
|
model.UniqueName = "Active";
|
||||||
|
model.PhoneNumber = user.Role;
|
||||||
|
|
||||||
|
var pwd = new Password(8).IncludeLowercase().IncludeUppercase().IncludeSpecial().IncludeNumeric();
|
||||||
|
var password = pwd.Next();
|
||||||
|
|
||||||
|
var result = await _userManager.CreateAsync(model, password);
|
||||||
|
if (result.Succeeded)
|
||||||
|
{
|
||||||
|
await _userManager.AddToRoleAsync(model, user.Role ?? "");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return BadRequest(new Response { Status = "Error", Message = result.Errors.FirstOrDefault()?.Description ?? "error" });
|
||||||
|
}
|
||||||
|
var request = HttpContext?.Request;
|
||||||
|
//var domain = $"{request?.Scheme}://{request?.Host}";
|
||||||
|
var domain = "http://shoc-ui-app.s3-website-us-east-1.amazonaws.com/#";
|
||||||
|
string subject = "Login Information";
|
||||||
|
string greeting = $"Dear {model.FirstName},\n\n";
|
||||||
|
string loginLink = $"Click here to login:<a href='{domain}/Login'>Login</a>\n";
|
||||||
|
string passwordInfo = $"Your password is: {password}\n\n";
|
||||||
|
string body = $"{greeting}\n\n{loginLink}\n\n{passwordInfo}";
|
||||||
|
await _sendemail.SendEMail(model?.Email ?? "", subject, body);
|
||||||
}
|
}
|
||||||
else
|
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);
|
|
||||||
|
|
||||||
|
var exist1 = await _userManager.Users.FirstAsync(w => w.Id == model.Id);
|
||||||
|
|
||||||
|
var existingRole = await _userManager.GetRolesAsync(exist1);
|
||||||
|
|
||||||
|
// Remove from roles if any exist
|
||||||
|
if (existingRole != null && existingRole.Any() && existingRole.FirstOrDefault() != exist1.PhoneNumber)
|
||||||
|
{
|
||||||
|
await _userManager.RemoveFromRolesAsync(exist1, existingRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update user details
|
||||||
|
exist1.FirstName = model.FirstName;
|
||||||
|
exist1.LastName = model.LastName;
|
||||||
|
exist1.Contact = model.Contact;
|
||||||
|
exist1.PhoneNumber = model.PhoneNumber;
|
||||||
|
|
||||||
|
// Optionally, detach the entity if you're about to attach it again
|
||||||
|
_db.Entry(exist1).State = EntityState.Detached;
|
||||||
|
|
||||||
|
// Add to role after setting properties
|
||||||
|
await _userManager.AddToRoleAsync(exist1, user.Role ?? "");
|
||||||
|
var result = await _userManager.UpdateAsync(exist1);
|
||||||
|
//await _context.SaveChangesAsync();
|
||||||
|
}
|
||||||
return Ok(new DataResponse { Message = "Updated Successfully", Status = "200" });
|
return Ok(new DataResponse { Message = "Updated Successfully", Status = "200" });
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new Response { Status = "Error", Message = ex.Message });
|
return BadRequest(new Response { Status = "Error", Message = ex.Message });
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[HttpPost]
|
[HttpPut]
|
||||||
[Route("EditUser")]
|
[Route("EditUser")]
|
||||||
public async Task<IActionResult> EditUser(EditUser_DTO user)
|
public async Task<IActionResult> EditUser(EditUser_DTO user)
|
||||||
{
|
{
|
||||||
|
|
@ -79,6 +142,7 @@ namespace Api.SeaHavenIndustries.Controllers
|
||||||
exist.NormalizedUserName = user.Email.ToUpper();
|
exist.NormalizedUserName = user.Email.ToUpper();
|
||||||
exist.CreatedDate = DateTime.Now;
|
exist.CreatedDate = DateTime.Now;
|
||||||
exist.UniqueName = "Active";
|
exist.UniqueName = "Active";
|
||||||
|
exist.PhoneNumber = user.Role;
|
||||||
var existingRole = await _userManager.GetRolesAsync(exist);
|
var existingRole = await _userManager.GetRolesAsync(exist);
|
||||||
|
|
||||||
if (existingRole != null && existingRole.Any())
|
if (existingRole != null && existingRole.Any())
|
||||||
|
|
@ -95,11 +159,17 @@ namespace Api.SeaHavenIndustries.Controllers
|
||||||
return BadRequest(new Response { Status = "Error", Message = ex.Message });
|
return BadRequest(new Response { Status = "Error", Message = ex.Message });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public class DeleteUserRequest
|
||||||
[HttpGet]
|
|
||||||
[Route("DeleteUser")]
|
|
||||||
public async Task<IActionResult> DeleteUser(string id)
|
|
||||||
{
|
{
|
||||||
|
public string Id { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpDelete]
|
||||||
|
[Route("DeleteUser")]
|
||||||
|
public async Task<IActionResult> DeleteUser(EditUser_DTO req)
|
||||||
|
{
|
||||||
|
string id = req.Id;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var data = await _db.Users.Where(w => w.Id == id).FirstOrDefaultAsync();
|
var data = await _db.Users.Where(w => w.Id == id).FirstOrDefaultAsync();
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Data.SqlClient;
|
using Microsoft.Data.SqlClient;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using SendGrid.Helpers.Mail;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
|
|
@ -16,7 +17,7 @@ namespace Api.SeaHavenIndustries.Controllers
|
||||||
{
|
{
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("[controller]")]
|
[Route("api/WorkOrder")]
|
||||||
public class WorkOrderController : Controller
|
public class WorkOrderController : Controller
|
||||||
{
|
{
|
||||||
private readonly UserManager<ApplicationUser> _userManager;
|
private readonly UserManager<ApplicationUser> _userManager;
|
||||||
|
|
@ -76,28 +77,31 @@ namespace Api.SeaHavenIndustries.Controllers
|
||||||
|
|
||||||
#region Images of workorder
|
#region Images of workorder
|
||||||
workOrder.workOrderAttachments = workOrder.workOrderAttachments == null ? new List<WorkOrderAttachments>() : workOrder.workOrderAttachments;
|
workOrder.workOrderAttachments = workOrder.workOrderAttachments == null ? new List<WorkOrderAttachments>() : workOrder.workOrderAttachments;
|
||||||
foreach (var attachment in model.Attachments)
|
if (model.Attachments != null)
|
||||||
{
|
{
|
||||||
string fileName = ContentDispositionHeaderValue.Parse(attachment.ContentDisposition).FileName.Trim('"');
|
foreach (var attachment in model.Attachments)
|
||||||
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);
|
string fileName = ContentDispositionHeaderValue.Parse(attachment.ContentDisposition).FileName.Trim('"');
|
||||||
}
|
string uniqueFileName = $"{Guid.NewGuid()}_{fileName}";
|
||||||
|
|
||||||
// Update the user's image URL
|
string uploadProfilePath = Path.Combine("Assets", "Documents");
|
||||||
var request = _httpContext.HttpContext.Request;
|
string fullPath = Path.Combine(_webHostEnvironment.WebRootPath, uploadProfilePath, uniqueFileName);
|
||||||
var domain = $"{request.Scheme}://{request.Host}";
|
|
||||||
var imagesPath = domain + "/" + Path.Combine(uploadProfilePath, uniqueFileName);
|
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
|
||||||
workOrder.workOrderAttachments.Add(new WorkOrderAttachments { Attachments = imagesPath });
|
|
||||||
}
|
// 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)
|
if (model.BeforPhotoAttachment != null)
|
||||||
{
|
{
|
||||||
|
|
@ -751,5 +755,57 @@ namespace Api.SeaHavenIndustries.Controllers
|
||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
return Ok(data);
|
return Ok(data);
|
||||||
}
|
}
|
||||||
|
[HttpGet]
|
||||||
|
[Route("GetworkordersDD")]
|
||||||
|
public async Task<IActionResult> GetworkordersDD()
|
||||||
|
{
|
||||||
|
_db.ChangeTracker.Clear();
|
||||||
|
|
||||||
|
var data = await _db.workOrders.Where(w => w.istemplate != true).Include(w => w.Locations).Include(w => w.AssignToUser).ToListAsync();
|
||||||
|
return Ok(data);
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
[Route("Getworkorders")]
|
||||||
|
public async Task<IActionResult> Getworkorders()
|
||||||
|
{
|
||||||
|
_db.ChangeTracker.Clear();
|
||||||
|
var data = await _db.workOrders
|
||||||
|
.Where(w => w.istemplate != true)
|
||||||
|
.AsSplitQuery()
|
||||||
|
.Include(w => w.Locations)
|
||||||
|
.Include(w => w.AssignToUser).Select(s => new WorkorderFilterVM
|
||||||
|
{
|
||||||
|
Id = s.Id,
|
||||||
|
Priority = s.Priority,
|
||||||
|
Status = s.Status,
|
||||||
|
WorkerOrderNumber = s.WorkerOrderNumber,
|
||||||
|
WorkerOrderTitle = s.WorkerOrderTitle,
|
||||||
|
DueDate = s.DueDate,
|
||||||
|
AssignToUserName = s.AssignToUser.FirstName,
|
||||||
|
LocationName = s.Locations.Name,
|
||||||
|
LocationId = s.LocationId,
|
||||||
|
PO = s.PO,
|
||||||
|
TT = s.TT,
|
||||||
|
}).ToListAsync();
|
||||||
|
return Ok(data);
|
||||||
|
}
|
||||||
|
public class WorkorderFilterVM
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public int? LocationId { get; set; }
|
||||||
|
public string? WorkerOrderNumber { get; set; }
|
||||||
|
public string? BillingAddress { get; set; } = "Amazon.com Services LLC 410 Terry Ave,North Seattle, Washington, 98109";
|
||||||
|
|
||||||
|
public string? WorkerOrderTitle { get; set; }
|
||||||
|
public string? LocationName { get; set; }
|
||||||
|
public string? AssignToUserName { get; set; }
|
||||||
|
public string? Priority { get; set; }
|
||||||
|
public string? Status { get; set; }
|
||||||
|
public DateTime? DueDate { get; set; }
|
||||||
|
public string? Dispatcher { get; set; }
|
||||||
|
public string? Scheduler { get; set; }
|
||||||
|
public string? PO { get; set; }
|
||||||
|
public string? TT { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
14
Api.SeaHavenIndustries/Models/UserRoleViewModel.cs
Normal file
14
Api.SeaHavenIndustries/Models/UserRoleViewModel.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
namespace Api.SeaHavenIndustries.Models
|
||||||
|
{
|
||||||
|
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? Name { get; set; }
|
||||||
|
|
||||||
|
public string? Status { get; set; }
|
||||||
|
public string? Date { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
//"DefaultConnection": "Server=DESKTOP-64LC14O\SQLEXPRESS;Database=SeahavenIndustries;TrustServerCertificate=True;Trusted_Connection=True;MultipleActiveResultSets=true",
|
//"DefaultConnection": "Server=DESKTOP-64LC14O\SQLEXPRESS;Database=SeahavenIndustries;TrustServerCertificate=True;Trusted_Connection=True;MultipleActiveResultSets=true",
|
||||||
|
|
||||||
// Test database
|
// Test database
|
||||||
"DefaultConnection": "Server=SQL5112.site4now.net;Initial Catalog=db_a7141e_seahavenindustries;User Id=db_a7141e_seahavenindustries_admin;Password=Abc123!@#;MultipleActiveResultSets=true"
|
//"DefaultConnection": "Server=SQL5112.site4now.net;Initial Catalog=db_a7141e_seahavenindustries;User Id=db_a7141e_seahavenindustries_admin;Password=Abc123!@#;MultipleActiveResultSets=true"
|
||||||
|
|
||||||
//Client Database
|
//Client Database
|
||||||
//"DefaultConnection": "Server=SQL5112.site4now.net;Initial Catalog=db_a7141e_seahavenindustry;User Id=db_a7141e_seahavenindustry_admin;Password=Abc123!@#;MultipleActiveResultSets=true",
|
"DefaultConnection": "Server=SQL5112.site4now.net;Initial Catalog=db_a7141e_seahavenindustry;User Id=db_a7141e_seahavenindustry_admin;Password=Abc123!@#;MultipleActiveResultSets=true"
|
||||||
},
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
|
|
@ -14,6 +14,9 @@
|
||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"SendGrid": {
|
||||||
|
"ApiKey": "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"
|
||||||
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"JWT": {
|
"JWT": {
|
||||||
"ValidAudience": "http://localhost:4200",
|
"ValidAudience": "http://localhost:4200",
|
||||||
|
|
|
||||||
13
Api.SeaHavenIndustries/aws-beanstalk-tools-defaults.json
Normal file
13
Api.SeaHavenIndustries/aws-beanstalk-tools-defaults.json
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
{
|
||||||
|
"region" : "us-east-1",
|
||||||
|
"configuration" : "Debug",
|
||||||
|
"framework" : "net8.0",
|
||||||
|
"self-contained" : true,
|
||||||
|
"application" : "SeaHavenIndustries",
|
||||||
|
"environment" : "SeaHavenIndustries-dev",
|
||||||
|
"enable-xray" : false,
|
||||||
|
"enhanced-health-type" : "basic",
|
||||||
|
"additional-options" : "",
|
||||||
|
"proxy-server" : "nginx"
|
||||||
|
}
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
//"DefaultConnection": "Server=.;Database=SeahavenIndustries;TrustServerCertificate=True;Trusted_Connection=True;MultipleActiveResultSets=true",
|
//"DefaultConnection": "Server=.;Database=SeahavenIndustries;TrustServerCertificate=True;Trusted_Connection=True;MultipleActiveResultSets=true",
|
||||||
//"DefaultConnection": "Server=.\\SqlExpress;Database=SeahavenIndustries;TrustServerCertificate=True;Trusted_Connection=True;MultipleActiveResultSets=true",
|
//"DefaultConnection": "Server=.\\SqlExpress;Database=SeahavenIndustries;TrustServerCertificate=True;Trusted_Connection=True;MultipleActiveResultSets=true",
|
||||||
// Test database
|
// Test database
|
||||||
"DefaultConnection": "Server=SQL5112.site4now.net;Initial Catalog=db_a7141e_seahavenindustries;User Id=db_a7141e_seahavenindustries_admin;Password=Abc123!@#;MultipleActiveResultSets=true",
|
//"DefaultConnection": "Server=SQL5112.site4now.net;Initial Catalog=db_a7141e_seahavenindustries;User Id=db_a7141e_seahavenindustries_admin;Password=Abc123!@#;MultipleActiveResultSets=true",
|
||||||
|
|
||||||
//Client Database
|
//Client Database
|
||||||
//"DefaultConnection": "Server=SQL5112.site4now.net;Initial Catalog=db_a7141e_seahavenindustry;User Id=db_a7141e_seahavenindustry_admin;Password=Abc123!@#;MultipleActiveResultSets=true",
|
"DefaultConnection": "Server=SQL5112.site4now.net;Initial Catalog=db_a7141e_seahavenindustry;User Id=db_a7141e_seahavenindustry_admin;Password=Abc123!@#;MultipleActiveResultSets=true",
|
||||||
"excelconnection": "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 8.0;HDR=YES'"
|
"excelconnection": "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 8.0;HDR=YES'"
|
||||||
},
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue