FullCodeTransfer/January2026

This commit is contained in:
rowell_m_soriano 2026-01-20 07:44:30 +08:00
commit 8313b112fc
3404 changed files with 757265 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,12 @@
{
"Version": 1,
"WorkspaceRootPath": "D:\\sourcecode\\NonInventPurchasing\\",
"Documents": [],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": []
}
]
}

View File

@ -0,0 +1,6 @@
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CPRNIMS.Infrastructure\CPRNIMS.Infrastructure.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,70 @@
using CPRNIMS.Infrastructure.ViewModel;
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Core.Facades
{
public class FacadeAttachment
{
public AttachmentVM SaveAttachment(byte[] contentBytes, string filePath,
IImageEncoder imageEncoder, string fileName, int extesionId)
{
using (var image = Image.Load(contentBytes))
{
image.Save("wwwroot/" + filePath, imageEncoder);
}
var attachment = new AttachmentVM
{
URL = filePath,
FileName = fileName,
ExtesionId = extesionId
};
return attachment;
}
public (IImageFormat imageFormat, IImageEncoder imageEncoder, string)
GetImageFormatAndEncoder(string contentValueBytes)
{
IImageFormat imageFormat;
IImageEncoder imageEncoder;
if (contentValueBytes.StartsWith("data:image/png"))
{
imageFormat = PngFormat.Instance;
imageEncoder = new PngEncoder();
}
else if (contentValueBytes.StartsWith("data:image/jpeg"))
{
imageFormat = JpegFormat.Instance;
imageEncoder = new JpegEncoder();
}
else
{
return (null, null, "UnsupportedFormat"); // Handle other formats if needed
}
return (imageFormat, imageEncoder, "Format is valid");
}
public (bool, string) CheckFileSize(byte[] contentValueBytes, int maxSizeInBytes)
{
using (var image = Image.Load(contentValueBytes))
{
// Check image size
if (contentValueBytes.Length > maxSizeInBytes)
{
return (false, "InValidFileSize"); // Image size exceeds the limit
}
return (true, "ValidFileSize");
}
}
}
}

View File

@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CaptchaGen.NetCore" Version="1.1.2" />
<PackageReference Include="Google.Apis.Drive.v3" Version="1.67.0.3373" />
<PackageReference Include="Microsoft.AspNet.Identity.Core" Version="2.2.4" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Core" Version="1.2.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CPRNIMS.Infrastructure\CPRNIMS.Infrastructure.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,19 @@
using CPRNIMS.Infrastructure.Dto.Account;
using CPRNIMS.Infrastructure.Entities.Account;
using CPRNIMS.Infrastructure.ViewModel.Account;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Contracts.Account
{
public interface IAccount
{
Task<List<UserRights>> GetUserRights(AccountDto accountDto);
Task<List<ControllerAccess>> GetControllerAccessByUserId(string userId);
Task<List<Departments>> GetDepartment();
Task<UserRights> PutPostUserAccess(AccountDto itemDto);
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Contracts.Account
{
public interface IAttachment
{
Task<Infrastructure.Entities.Account.Attachment> CreateUpdateAttachment(Infrastructure.Entities.Account.Attachment attachment, string userId);
Task<List<Infrastructure.Entities.Account.Attachment>> GetAttachmentById(string userId);
Task<List<Infrastructure.Entities.Account.Attachment>> GetAllAttachment();
Task<List<Infrastructure.Entities.Account.Attachment>> GetAttachmentByType(string userId, int fileType);
Task DeleteSignatureAsync(int id);
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Contracts.Account
{
public interface IControllerAccess
{
Task<List<Infrastructure.Entities.Account.ControllerAccess>> GetControllerAccessByUserId(string userId);
}
}

View File

@ -0,0 +1,14 @@
using CPRNIMS.Infrastructure.Entities.Account;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Contracts.Account
{
public interface IDepartment
{
Task<List<Departments>> GetDepartment();
}
}

View File

@ -0,0 +1,20 @@
using CPRNIMS.Infrastructure.Entities.Account;
using CPRNIMS.Infrastructure.Entities.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Contracts.Account
{
public interface IForgotPassword
{
Task ForgotPassword(ForgotPassword forgotPassword);
Task SaveUpdateOTPAsync(Otps forgotPassword, bool isPassChanged);
Task SaveToken(ForgotPassword forgotPassword);
Task OptimizeMessageBody(ForgotPassword forgotPassword);
Task<bool> ValidateOTP(Otps forgotPassword);
Task<bool> ValidateTokenURLForgotPassword(ForgotPassword forgotPassword);
}
}

View File

@ -0,0 +1,57 @@
using CPRNIMS.Infrastructure.Dto.Canvass;
using CPRNIMS.Infrastructure.Entities.Canvass;
using CPRNIMS.Infrastructure.Entities.Purchasing;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Contracts.Canvass
{
public interface ICanvass
{
#region Post Put
Task<RFQ> PostPerSupplierToken(CanvassDto CanvassDto);
Task<ForCanvassFollowUp> PutSupplierCanvass(long canvassSupplierId);
Task<PRDetails> PostCanvass(CanvassDto CanvassDto);
Task<Suppliers> PostPutSupplier(CanvassDto CanvassDto);
Task<Suppliers> PostTaggingSupplier(CanvassDto CanvassDto);
Task<Suppliers> PostApprovedSupp(CanvassDto CanvassDto);
Task<CanvassDetail> PostSuggestedSupp(CanvassDto CanvassDto);
Task<CanvassDetail> PutSuppUnitPrice(CanvassDto CanvassDto);
Task<CanvassDetail> PutSuppBidDetails(CanvassDto canvassDto);
Task<Suppliers> PostPutMySupplier(CanvassDto canvassDto);
Task<Suppliers> PostPutItemTagging(CanvassDto canvassDto);
Task<CanvassSupplier> UnlockFormLink(CanvassDto canvassDto);
#endregion
#region Get
Task<List<PRDetails>> GetCanvassById(CanvassDto CanvassDto);
Task<List<WOResponse>> GetCanvassWOResponse(CanvassDto CanvassDto);
Task<List<WOResponseById>> GetWOResponseBySuppId(CanvassDto CanvassDto);
Task<List<Suppliers>> GetSupplierById(CanvassDto CanvassDto);
Task<List<RFQReference>> GetRFQ(CanvassDto CanvassDto);
Task<List<BiddingItem>> GetSupplierBid(CanvassDto CanvassDto);
Task<List<RFQPerSupplier>> GetSupplierBidByItem(CanvassDto CanvassDto);
Task<List<SupplierBidById>> GetSupplierBidById(CanvassDto CanvassDto);
Task<List<PerSupplier>> GetCanvassPerSupplier(CanvassDto CanvassDto);
Task<List<PRDetails>> GetCanvassPerSupplierEmail(CanvassDto CanvassDto);
Task<List<PRDetails>> GetCanvassPerSupplierId(CanvassDto itemCodeDto);
Task<List<ItemListWOEmail>> GetItemSupplierWOEmail(CanvassDto CanvassDto);
Task<List<Suppliers>> GetSupplierItemWOEmail(CanvassDto CanvassDto);
Task<List<PRDetails>> GetCanvassByPRNo(CanvassDto CanvassDto);
Task<List<CanvassGroupByPRNo>> GetCanvassGroupByPRNo(CanvassDto CanvassDto);
Task<List<PRDetails>> GetCanvassByItemNo(CanvassDto CanvassDto);
Task<List<PRDetails>> GetPRItemList(CanvassDto CanvassDto);
Task<List<PRDetails>> GetPRItem(CanvassDto CanvassDto);
Task<List<Infrastructure.Entities.Canvass.PRList>> GetPRListByPRNo(CanvassDto canvassDto);
Task<List<ForCanvass>> GetForCanvassPerItem(CanvassDto CanvassDto);
Task<int> GetCanvassNo();
Task<List<ForCanvassFollowUp>> GetCanvassForFollowUp(CanvassDto itemDto);
Task<List<Suppliers>> GetMySuppliers(CanvassDto CanvassDto);
Task<List<MyPRWOCanvass>> GetMyPRWOCanvass(CanvassDto itemDto);
Task<List<AlternativeOfferDetails>> GetAlternativeOfferByPRDetailId(CanvassDto itemDto);
Task<List<AllForCanvass>> GetAllForCanvass();
#endregion
}
}

View File

@ -0,0 +1,18 @@
using CPRNIMS.Infrastructure.Dto.Finance;
using CPRNIMS.Infrastructure.Entities.Finance;
using CPRNIMS.Infrastructure.Entities.Purchasing;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Contracts.Finance
{
public interface IRR
{
Task<List<ForPayment>> GetAllClosedPO(RRDetailsDto itemDto);
Task<List<ReceivingDetail>> GetRRDetailByPO(RRDetailsDto itemDto);
Task<RRDetail> PostPutPayment(RRDetailsDto itemDto);
}
}

View File

@ -0,0 +1,24 @@
using CPRNIMS.Infrastructure.Dto.Inventory;
using CPRNIMS.Infrastructure.Entities.Inventory;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Contracts.Inventory
{
public interface IInventory
{
Task<List<Lot>> GetLotNo(InventoryDto itemDto);
Task<List<Lot>> GetLotNoById(InventoryDto itemDto);//
Task<List<LotQtyByItem>> GetLotQtyByItem(InventoryDto itemDto);
Task<List<Infrastructure.Entities.Inventory.Inventory>> GetInventoryByUserId(InventoryDto itemDto);
Task<List<RequestItemDetail>> GetRequestedItemByUserId(InventoryDto itemDto);
Task<List<ItemDetail>> GetInventoryById(InventoryDto itemDto);
Task<Infrastructure.Entities.Inventory.Inventory> PostPutReqApproval(InventoryDto itemDto);
Task<RequestItem> PostPutReqItems(InventoryDto itemDto);
Task<Lot> PostPutLotNo(InventoryDto itemDto);
Task<ItemDetail> PostPutLotBin(InventoryDto itemDto);
}
}

View File

@ -0,0 +1,31 @@
using CPRNIMS.Infrastructure.Dto.Items;
using CPRNIMS.Infrastructure.Entities.Account;
using CPRNIMS.Infrastructure.Entities.Items;
using CPRNIMS.Infrastructure.Entities.Purchasing;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Contracts.Items
{
public interface IItem
{
Task<List<Departments>> GetDepartment(ItemCodeDto itemCode);
Task<List<ItemList>> GetItemList(ItemCodeDto itemCode);
Task<List<ItemCart>> GetItemCart(ItemDto itemDto);
Task<List<Item>> GetItemDetail(ItemDto itemDto);
Task<List<ItemLocalization>> GetItemLocalization(ItemDto itemDto);
Task<List<ItemCategory>> GetItemCateg(ItemDto itemDto);
Task<List<ItemColor>> GetItemColor(ItemDto itemDto);
Task<List<UnitOfMessure>> GetItemUOM(ItemDto itemDto);
Task<List<NotifUserKey>> GetNotifUserKey(ItemDto itemDto);
Task<long> GetPRNo();
Task<ItemCart> PostPurchRequest(ItemDto itemDto);
Task<ItemCodeDto> PostPutItem(ItemCodeDto itemDto);
Task<Item> PutItemDetail(ItemDto itemDto);
Task<ItemCart> PostPutItemCart(ItemDto itemDto);
Task<ItemCart> PostPutItemPath(ItemDto itemDto);
}
}

View File

@ -0,0 +1,70 @@
using CPRNIMS.Infrastructure.Dto.PO;
using CPRNIMS.Infrastructure.Entities.Canvass;
using CPRNIMS.Infrastructure.Entities.Common;
using CPRNIMS.Infrastructure.Entities.LocalDb.NonInvent;
using CPRNIMS.Infrastructure.Entities.PO;
using CPRNIMS.Infrastructure.ViewModel.PO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Contracts.PO
{
public interface IPurchaseOrder
{
#region Get
Task<List<IncomingShipmentDto>> GetIncomingShipment(PODto itemDto);
Task<List<IndexCard>> GetIndexCard(PODto poDto);
Task<List<PurchaseOrder>> GetForPOApprovalByPRNo(PODto PODto);
Task<List<ForPOApproval>> GetForPOApproval(PODto PODto);
Task<List<ApprovedPO>> GetApprovedPO(PODto PODto);
Task<List<ItemListForPO>> GetApprovedPOPerEmail(PODto PODto);
Task<List<CreatedPOPerSupId>> GetCreatedPOPerSupId(PODto pODto);
Task<List<RFQReference>> GetRFQ(PODto PODto);
Task<List<ForPO>> GetForPO(PODto PODto);
Task<List<ItemListForPO>> GetForPOPerSuppEmail(PODto PODto);
Task<List<BiddingApproval>> GetForBiddingApproval(PODto PODto);
Task<List<RFQPerSupplier>> GetSupplierBidByItem(PODto PODto);
Task<List<RFQPerSupplier>> GetSupplierBidById(PODto PODto);
Task<List<PaymentTerm>> GetPaymentTerms(PODto pODto);
Task<List<PortOfDischarges>> GetPortOfDischarge(PODto pODto);
Task<List<PRWOCanvass>> GetPRWOCanvass(PODto itemDto);
Task<List<CentralPONo>> GetLatestPO(PODto pODto);
Task<List<SystemSettings>> GetLatestPO2(PODto pODto);
Task<List<DocRequired>> GetDocRequired(PODto pODto);
Task<List<OtherCharges>> GetOtherCharges(PODto itemDto);
Task<List<Suppliers>> GetSuppliers(PODto itemDto);
Task<List<CreatedPO>> GetCreatedPO(PODto pODto);
Task<List<POItemDetail>> GetPOItemDetail(PODto pODto);
Task<List<CreatedPO>> GetMyCreatedPO(PODto pODto);
Task<List<Incoterm>> GetIncoterms(PODto itemDto);
Task<List<PRPOSummaryCount>> GetPRPOSummaryReport(PODto itemDto);
Task<List<PRPOSummaryItem>> GetPRPOSummaryItem(PODto itemDto);
PODto CreatePoDto(POVM PODto, byte docRequirementId, int otherChargesId, long prDetailsId
, decimal unitPrice, decimal amount, long prNo, decimal quantity,string Specification);
Task Prerequisite(POVM poVM);
#endregion
#region Post Put
Task<OtherCharges> PostPutOtherCharges(PODto dto);
Task<PurchaseOrder> PostApprovedPO(PODto PODto);
Task<PurchaseOrder> PostPutPO(PODto PODto);
Task<OtherCharges> PostSuppCharges(PODto poDto);
Task<CustomPO> PostPutCustomPO(PODto pODto);
Task<DocRequired>PostSuppDocRequirements(PODto poDto);
Task<PurchaseOrder> PostPOToSupplier(PODto PODto);
Task<Suppliers> PostApprovedSupplier(PODto PODto);
Task<PurchaseOrder> PostApprovedSuggested(PODto PODto);
Task<PurchaseOrder> PutPRItemDetails(PODto pODto);
Task<Infrastructure.Entities.PO.PurchaseOrder> PutMyPONo(PODto pODto);
Task<Infrastructure.Entities.PO.PurchaseOrder> PutPOItemDetail(PODto pODto);
Task <CustomPO> ApprovedSelectedPO(PODto dto);
Task <DocRequired> PostPutDocRequired(PODto dto);
Task<CustomPO> PutPOCancel(PODto poDto);
Task<Incoterm> PostPutIncoterms(PODto pODto);
Task<bool> DeleteIncShip(PODto poDto);
Task<bool> PostIncShipFollowUp(PODto pODto);
#endregion
}
}

View File

@ -0,0 +1,39 @@
using CPRNIMS.Infrastructure.Dto.PR;
using CPRNIMS.Infrastructure.Entities.Common;
using CPRNIMS.Infrastructure.Entities.Purchasing;
using CPRNIMS.Infrastructure.Entities.SMTP;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Contracts.PR
{
public interface IPRequest
{
Task<List<ForReceiving>> GetItemDetailForReceiving(PRDto PRDto);
Task<List<ForRR>> GetPRByRRId(PRDto PRDto);
Task<List<ReceivingDetail>> GetRRDetailByPO(PRDto PRDto);
Task<List<ForReceiving>> GetForReceiving(PRDto PRDto);
Task<List<Dashboard>> GetDashBoard(PRDto PRDto);
Task<List<ItemApproval>> GetMyPR(PRDto PRDto);
Task<List<PRList>> GetAllPR(PRDto PRDto);
Task<List<Infrastructure.Entities.Canvass.PRList>> GetPRListByPRNo(PRDto PRDto);
Task<List<NotifUserKey>> GetNotifUserKey(PRDto PRDto);
Task<List<PRDetails>> GetPRDetailByPRNo(PRDto PRDto);
Task<List<PRTracking>> GetPRStatusById(PRDto PRDto);
Task<List<RRReport>> GetDetailedPRTracking(PRDto PRDto);
Task<List<AlternativeOffer>> GetSupplierAlternativeOffer(PRDto PRDto);
Task<List<AlternativeOfferDetails>> GetSupplierAlterOfferDetails(PRDto PRDto);
Task<List<NotificationById>> GetNotificationById(PRDto PRDto);
Task<List<PRDto>> GetApproverName(PRDto PRDto);
Task<MessageResponse> PRItemRemoval(PRDto pRDto);
Task<PRDetails> PostPRApproveReject(PRDto PRDto);
Task<PRDetails> PostPutReceiving(PRDto PRDto);
Task<PRDetails> PutPOClose(PRDto PRDto);
Task<PRDetails> PutItemDetail(PRDto PRDto);
Task<PRDetails> PostPutDeniedItem(PRDto PRDto);
Task<AlternativeOfferDetails> PutSupplierAlterOffer(PRDto pRDto);
}
}

View File

@ -0,0 +1,24 @@
using CPRNIMS.Infrastructure.Dto.Items;
using CPRNIMS.Infrastructure.Entities.Purchasing;
using CPRNIMS.Infrastructure.Entities.Receiving;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Contracts.Receiving
{
public interface IReceiving
{
Task<List<ReceivingDetail>> GetRRDetailByPO(ItemDto itemDto);
Task<List<RRDetail>> GetRRDetail(ItemDto itemDto);
Task<List<ForReceiving>> GetForReceiving(ItemDto itemDto);
Task<List<RR>> GetRR(ItemDto itemDto);
Task<List<RRSeries>> GetLatestRRNo(ItemDto itemDto);
Task<PRDetails> PostPutReceiving(ItemDto itemDto);
Task<PRDetails> PutPOClose(ItemDto itemDto);
Task<RRSeries> PutRRNoSeries(ItemDto itemDto);
Task <List<Infrastructure.Entities.Receiving.RRReport>> GetRRReport (ItemDto itemDto);
}
}

View File

@ -0,0 +1,19 @@
using CPRNIMS.Infrastructure.Dto.SMTP;
using CPRNIMS.Infrastructure.Entities.SMTP;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Contracts.SMTP
{
public interface ISMTP
{
Task<List<SMTPCredential>> GetMySmtp(SMTPCredentialDto itemDto);
Task<List<SMTPCredential>> GetAllSmtp(SMTPCredentialDto itemDto);
Task<List<SMTPCredential>> GetSMTPCredential(SMTPCredentialDto itemDto);
Task<SMTPCredential> PostPutSmtp(SMTPCredentialDto itemDto);
Task<SMTPCredential> GetMySmtpById(SMTPCredentialDto itemDto);
}
}

View File

@ -0,0 +1,100 @@
using CPRNIMS.Domain.Contracts.Account;
using CPRNIMS.Infrastructure.Database;
using CPRNIMS.Infrastructure.Dto.Account;
using CPRNIMS.Infrastructure.Entities.Account;
using Google;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Services.Account
{
public class Account : IAccount
{
private readonly NonInventoryDbContext _accountDbContext;
public Account(NonInventoryDbContext applicationDbContext)
{
_accountDbContext = applicationDbContext;
}
public async Task<List<Infrastructure.Entities.Account.ControllerAccess>> GetControllerAccessByUserId(string userId)
{
try
{
var getMyControllerAccess = await _accountDbContext.ControllerAccess
.FromSqlRaw($"EXEC GetElementAccessByUserId @UserId = '{userId}'")
.ToListAsync();
return getMyControllerAccess ?? new List<Infrastructure.Entities.Account.ControllerAccess>();
}
catch (Exception ex)
{
ex.ToString();
throw;
}
}
public async Task<List<Departments>> GetDepartment()
{
try
{
var departments = await _accountDbContext.Departments
.Where(d => d.IsActive == true)
.ToListAsync();
return departments;
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<UserRights>> GetUserRights(AccountDto accountDto)
{
try
{
var allItems = await _accountDbContext.UserRights
.FromSqlRaw($"EXEC GetUserRights @UserId = '{accountDto.UserId}',@IsNotExist = '{accountDto.IsNotExist}'")
.ToListAsync();
return allItems ?? new List<UserRights>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<UserRights> PutPostUserAccess(AccountDto itemDto)
{
try
{
await _accountDbContext.Database
.ExecuteSqlRawAsync("EXEC PutPostUserAccess @ContAccId,@AdminUserId,@UserId,@AccessTypeId,@UserAccessId,@IsActive",
new SqlParameter("@ContAccId", itemDto.ContAccId),
new SqlParameter("@AdminUserId", itemDto.AdminUserId),
new SqlParameter("@UserId", itemDto.UserId),
new SqlParameter("@AccessTypeId", itemDto.AccessTypeId),
new SqlParameter("@UserAccessId", itemDto.UserAccessId),
new SqlParameter("@IsActive", itemDto.IsActive));
return new UserRights();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
}
}

View File

@ -0,0 +1,142 @@
using CPRNIMS.Domain.Contracts.Account;
using CPRNIMS.Infrastructure.Database;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Services.Account
{
public class Attachment : IAttachment
{
private readonly NonInventoryDbContext _NonInventoryDbContext;
public Attachment(NonInventoryDbContext NonInventoryDbContext)
{
_NonInventoryDbContext = NonInventoryDbContext;
}
public async Task<Infrastructure.Entities.Account.Attachment> CreateUpdateAttachment(Infrastructure.Entities.Account.Attachment attachment, string userId)
{
try
{
var updateProfile = _NonInventoryDbContext.Attachments.
SingleOrDefault(a => a.AttachmentId == userId);
if (updateProfile != null)
{
updateProfile.URL = attachment.URL;
updateProfile.FileName = attachment.FileName;
updateProfile.ExtensionId = attachment.ExtensionId;
updateProfile.UpdatedDate = attachment.UpdatedDate;
updateProfile.UpdatedBy = attachment.UpdatedBy;
await _NonInventoryDbContext.SaveChangesAsync();
return updateProfile;
}
else
{
await _NonInventoryDbContext.AddAsync(attachment);
await _NonInventoryDbContext.SaveChangesAsync();
return updateProfile;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.InnerException);
throw;
}
}
public Task<Infrastructure.Entities.Account.Attachment> CreateAttachment(Infrastructure.Entities.Account.Attachment attachment)
{
throw new NotImplementedException();
}
public Task DeleteSignatureAsync(int id)
{
throw new NotImplementedException();
}
public async Task<List<Infrastructure.Entities.Account.Attachment>> GetAttachmentById(string userId)
{
var updateProfile = await _NonInventoryDbContext.Attachments
.Where(s => s.AttachmentId == userId)
.ToListAsync();
if (updateProfile != null || updateProfile.Count == 1)
{
return updateProfile;
}
else
{
return null;
}
}
public async Task<List<Infrastructure.Entities.Account.Attachment>> GetAllAttachment()
{
var allAttachments = await (from a in _NonInventoryDbContext.Attachments
join aft in _NonInventoryDbContext.AttachmentFileTypes on a.AttachmentTypeId equals aft.AttachmentTypeId into aftGroup
from aft in aftGroup.DefaultIfEmpty()
join ae in _NonInventoryDbContext.AttachmentExtensions on a.ExtensionId equals ae.ExtensionId into aeGroup
from ae in aeGroup.DefaultIfEmpty()
select new Infrastructure.Entities.Account.Attachment
{
FileName = a.FileName,
AttachmentId = a.AttachmentId,
URL = a.URL,
AttachmentFileType = aft,
AttachmentExtention = ae,
CreatedBy = a.CreatedBy,
CreatedDate = a.CreatedDate,
UpdatedBy = a.UpdatedBy,
UpdatedDate = a.UpdatedDate
}).ToListAsync();
if (allAttachments != null || allAttachments.Count == 1)
{
return allAttachments;
}
else
{
return null;
}
}
public async Task<List<Infrastructure.Entities.Account.Attachment>> GetAttachmentByType(string userId, int fileType)
{
var allAttachments = await (from a in _NonInventoryDbContext.Attachments
join aft in _NonInventoryDbContext.AttachmentFileTypes
on a.AttachmentTypeId equals aft.AttachmentTypeId into aftGroup
from aft in aftGroup.DefaultIfEmpty()
join ae in _NonInventoryDbContext.AttachmentExtensions on a.ExtensionId equals ae.ExtensionId into aeGroup
from ae in aeGroup.DefaultIfEmpty()
where a.AttachmentId == userId && aft.AttachmentTypeId == fileType
select new Infrastructure.Entities.Account.Attachment
{
FileName = a.FileName,
AttachmentId = a.AttachmentId,
URL = a.URL,
AttachmentFileType = aft,
AttachmentExtention = ae,
CreatedBy = a.CreatedBy,
CreatedDate = a.CreatedDate,
UpdatedBy = a.UpdatedBy,
UpdatedDate = a.UpdatedDate
}).ToListAsync();
if (allAttachments != null || allAttachments.Count == 1)
{
return allAttachments;
}
else
{
return null;
}
}
}
}

View File

@ -0,0 +1,39 @@
using CPRNIMS.Domain.Contracts.Account;
using CPRNIMS.Infrastructure.Database;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Services.Account
{
public class ControllerAccess : IControllerAccess
{
private readonly NonInventoryDbContext _dbContext;
public ControllerAccess(NonInventoryDbContext dbContext)
{
_dbContext = dbContext;
}
public async Task<List<Infrastructure.Entities.Account.ControllerAccess>> GetControllerAccessByUserId(string userId)
{
try
{
var getMyControllerAccess = await _dbContext.ControllerAccess
.FromSqlRaw($"EXEC GetElementAccessByUserId @UserId = '{userId}'")
.ToListAsync();
return getMyControllerAccess ?? new List<Infrastructure.Entities.Account.ControllerAccess>();
}
catch (Exception ex)
{
ex.ToString();
throw;
}
}
}
}

View File

@ -0,0 +1,39 @@
using CPRNIMS.Domain.Contracts.Account;
using CPRNIMS.Infrastructure.Database;
using CPRNIMS.Infrastructure.Entities.Account;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Services.Account
{
public class Department : IDepartment
{
private readonly NonInventoryDbContext _dbContext;
public Department(NonInventoryDbContext applicationDbContext)
{
_dbContext = applicationDbContext;
}
public async Task<List<Departments>> GetDepartment()
{
try
{
var departments = await _dbContext.Departments
.Where(d => d.IsActive == true)
.ToListAsync();
return departments;
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
}
}

View File

@ -0,0 +1,160 @@
using CPRNIMS.Domain.Contracts.Account;
using CPRNIMS.Infrastructure.Database;
using CPRNIMS.Infrastructure.Entities.Common;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Services.Account
{
public class ForgotPassword : IForgotPassword
{
private readonly NonInventoryDbContext _purchasingDbContext;
public ForgotPassword(NonInventoryDbContext purchasingDbContext)
{
_purchasingDbContext = purchasingDbContext;
}
public async Task<bool> ValidateTokenURLForgotPassword(Infrastructure.Entities.Account.ForgotPassword forgotPassword)
{
var isValid = await _purchasingDbContext.ForgotPasswords
.FirstOrDefaultAsync(fp => fp.ServerURIToken == forgotPassword.ServerURIToken);
if (isValid != null)
{
return true;
}
return false;
}
async Task IForgotPassword.SaveToken(Infrastructure.Entities.Account.ForgotPassword forgotPassword)
{
try
{
var isEmailExist = await _purchasingDbContext.ForgotPasswords
.Where(tv => tv.IsValid == true)
.FirstOrDefaultAsync(fp => fp.Email == forgotPassword.Email)
;
if (isEmailExist != null)
{
forgotPassword.UpdatedDate = DateTime.Now;
forgotPassword.UpdatedBy = forgotPassword.Email;
forgotPassword.ServerURIToken = forgotPassword.ServerURIToken;
await _purchasingDbContext.SaveChangesAsync();
}
else
{
forgotPassword.IsValid = true;
await _purchasingDbContext.ForgotPasswords.AddAsync(forgotPassword);
await _purchasingDbContext.SaveChangesAsync();
}
}
catch (Exception ex)
{
ex.ToString();
throw;
}
}
async Task IForgotPassword.ForgotPassword(Infrastructure.Entities.Account.ForgotPassword forgotPassword)
{
await _purchasingDbContext.ForgotPasswords.AddAsync(forgotPassword);
await _purchasingDbContext.SaveChangesAsync();
}
public Task OptimizeMessageBody(Infrastructure.Entities.Account.ForgotPassword forgotPassword)
{
throw new NotImplementedException();
}
public async Task<bool> ValidateOTP(Otps forgotPassword)
{
DateTime currentDateTime = DateTime.Now;
var expiredOTP = await _purchasingDbContext.Otps
.FirstOrDefaultAsync(otp => otp.Email == forgotPassword.Email
&& otp.IsValid == true
&& otp.CreatedDate < currentDateTime.AddMinutes(-30));
if (expiredOTP != null)
{
await SetOTPInvalidAsync(expiredOTP.OTP);
return expiredOTP != null;
}
var isValid = await _purchasingDbContext.Otps
.FirstOrDefaultAsync(otp =>
otp.OTP == forgotPassword.OTP && otp.Email == forgotPassword.Email
&& otp.CreatedDate > DateTime.Now.AddMinutes(-30)); // Use '-' to subtract 30 minutes
return isValid != null;
}
public async Task SetOTPInvalidAsync(string otp)
{
try
{
var isOTPExist = await _purchasingDbContext.Otps
.Where(tv => tv.IsValid == true)
.FirstOrDefaultAsync(fp => fp.OTP == otp);
if (isOTPExist != null)
{
isOTPExist.IsValid = false;
isOTPExist.UpdatedDate = DateTime.Now;
isOTPExist.UpdatedBy = "SysAdmin";
await _purchasingDbContext.SaveChangesAsync();
}
else
{
}
}
catch (Exception ex)
{
ex.ToString();
throw;
}
}
public async Task SaveUpdateOTPAsync(Otps forgotPassword, bool isPassChanged)
{
try
{
var isEmailExist = await _purchasingDbContext.Otps
.Where(tv => tv.IsValid == true)
.FirstOrDefaultAsync(fp => fp.Email == forgotPassword.Email);
if (isPassChanged == true)
{
if (isEmailExist != null)
{
isEmailExist.IsValid = false;
isEmailExist.UpdatedDate = DateTime.Now;
isEmailExist.UpdatedBy = forgotPassword.Email;
await _purchasingDbContext.SaveChangesAsync();
}
}
else
{
if (isEmailExist != null)
{
isEmailExist.UpdatedDate = DateTime.Now;
isEmailExist.UpdatedBy = forgotPassword.Email;
isEmailExist.OTP = forgotPassword.OTP;
await _purchasingDbContext.SaveChangesAsync();
}
else
{
forgotPassword.IsValid = true;
await _purchasingDbContext.Otps.AddAsync(forgotPassword);
await _purchasingDbContext.SaveChangesAsync();
}
}
}
catch (Exception ex)
{
ex.ToString();
throw;
}
}
}
}

View File

@ -0,0 +1,113 @@
using CPRNIMS.Infrastructure.Database;
using CPRNIMS.Infrastructure.Entities.Account;
using CPRNIMS.Infrastructure.Models;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Services.Account
{
public class UserClaimsManager
{
private readonly UserManager<ApplicationUser> _userManager;
private readonly NonInventoryDbContext _dbContext;
RoleManager<IdentityRole> _roleManager;
public UserClaimsManager(UserManager<ApplicationUser> userManager,
NonInventoryDbContext dbContext, RoleManager<IdentityRole> roleManager)
{
_userManager = userManager;
_dbContext = dbContext;
_roleManager = roleManager;
}
public async Task<List<object>> GetAllUsersProfile()
{
try
{
var usersWithRolesAndAttachments = await (from user in _userManager.Users
join userRole in _dbContext.IdentityUserRoles on user.Id equals userRole.UserId into userRoles
from ur in userRoles.DefaultIfEmpty()
join role in _dbContext.Roles on ur.RoleId equals role.Id into roles
from r in roles.DefaultIfEmpty()
join attachment in _dbContext.Attachments on user.Id equals attachment.AttachmentId into attachments
from a in attachments.DefaultIfEmpty()
select new
{
user.Id,
Role = r != null ? r.Name ?? "N/A" : "N/A",
URL = a != null ? a.URL ?? "N/A" : "N/A",
FileName = a != null ? a.FileName ?? "N/A" : "N/A",
user.Company,
user.DepartmentId,
user.UserName,
user.FullName,
user.Email,
user.EmailConfirmed,
Address = user.Address ?? "N/A",
PhoneNumber = user.PhoneNumber ?? "N/A",
user.LockoutEnd,
user.LockoutEnabled,
user.CreatedBy,
user.UpdatedBy,
user.CreatedDate,
user.UpdatedDate
}).ToListAsync();
return usersWithRolesAndAttachments.Cast<object>().ToList();
}
catch (Exception ex)
{
ex.ToString();
throw;
}
}
public async Task AssignUserRole(RegisterModel registerModel)
{
var user = await _userManager.FindByIdAsync(registerModel.Id);
if (user != null)
{
// Check if the role exists, if not, create it
if (!await _roleManager.RoleExistsAsync(registerModel.Role))
{
await _roleManager.CreateAsync(new IdentityRole(registerModel.Role));
}
// Assign the user to the role
await _userManager.AddToRoleAsync(user, registerModel.Role);
}
}
public async Task AddCustomClaim(RegisterModel registerModel)
{
var user = await _userManager.FindByIdAsync(registerModel.Id);
if (user != null)
{
// Define your role claim
var roleClaim = new Claim(ClaimTypes.Role, registerModel.Role);
// Use UserManager.AddClaimAsync to add the role claim to the user
var result = await _userManager.AddClaimAsync(user, roleClaim);
// Optionally, add additional custom claims here if needed
}
}
public async Task UpdateCustomClaim(RegisterModel appUser, string currentClaim)
{
var user = await _userManager.FindByIdAsync(appUser.Id);
if (user != null)
{
// Define your custom claim
var claim = new Claim(appUser.Role, currentClaim);
var newClaim = new Claim(appUser.Role, appUser.Role);
await _userManager.ReplaceClaimAsync(user, claim, newClaim);
}
}
}
}

View File

@ -0,0 +1,654 @@
using CPRNIMS.Domain.Contracts.Canvass;
using CPRNIMS.Infrastructure.Database;
using CPRNIMS.Infrastructure.Dto.Canvass;
using CPRNIMS.Infrastructure.Entities.Canvass;
using CPRNIMS.Infrastructure.Entities.Purchasing;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using System.Data;
using static CPRNIMS.Domain.Services.OutputParamMessage;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Services.Canvass
{
public class Canvass : ICanvass
{
private readonly NonInventoryDbContext _dbContext;
public Canvass(NonInventoryDbContext dbContext)
{
_dbContext = dbContext;
}
#region Get
public async Task<List<ItemListWOEmail>> GetItemSupplierWOEmail(CanvassDto CanvassDto)
{
try
{
var allItems = await _dbContext.ItemListWOEmails
.FromSqlRaw($"EXEC GetItemSupplierWOEmail @PRNo = '{CanvassDto.PRNo}'")
.ToListAsync();
return allItems ?? new List<ItemListWOEmail>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<BiddingItem>> GetSupplierBid(CanvassDto CanvassDto)
{
var allItems = await _dbContext.BiddingItems
.FromSqlRaw($"EXEC GetSupplierBid @UserId,@IsHistory",
new SqlParameter("@UserId", CanvassDto.UserId),
new SqlParameter("@IsHistory", CanvassDto.IsHistory))
.ToListAsync();
return allItems ?? new List<BiddingItem>();
}
public async Task<List<PerSupplier>> GetCanvassPerSupplier(CanvassDto CanvassDto)
{
try
{
var allItems = await _dbContext.PerSuppliers
.FromSqlRaw($"EXEC GetCanvassPerSupplier @UserId",
new SqlParameter("@UserId", CanvassDto.UserId))
.ToListAsync();
return allItems ?? new List<PerSupplier>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<RFQPerSupplier>> GetSupplierBidByItem(CanvassDto CanvassDto)
{
var allItems = await _dbContext.RFQPerSuppliers
.FromSqlRaw($"EXEC GetSupplierBidByItem @UserId,@Status,@ItemNo,@CanvassId,@IsHistory,@PRDetailsId",
new SqlParameter("@UserId", CanvassDto.UserId),
new SqlParameter("@Status", CanvassDto.Status),
new SqlParameter("@ItemNo", CanvassDto.ItemNo),
new SqlParameter("@CanvassId", CanvassDto.CanvassId),
new SqlParameter("@IsHistory", CanvassDto.IsHistory),
new SqlParameter("@PRDetailsId", CanvassDto.PRDetailsId))
.ToListAsync();
return allItems ?? new List<RFQPerSupplier>();
}
public async Task<List<PRDetails>> GetCanvassById(CanvassDto CanvassDto)
{
var allItems = await _dbContext.PRDetails
.FromSqlRaw("EXEC GetCanvassById @UserId",
new SqlParameter("@UserId", CanvassDto.UserId))
.ToListAsync();
return allItems ?? new List<PRDetails>();
}
public async Task<List<PRDetails>> GetCanvassByItemNo(CanvassDto CanvassDto)
{
var allItems = await _dbContext.PRDetails
.FromSqlRaw($"EXEC GetCanvassByItemNo @UserId, @ItemNo",
new SqlParameter("@UserId", CanvassDto.UserId),
new SqlParameter("@ItemNo", CanvassDto.ItemNo))
.ToListAsync();
return allItems ?? new List<PRDetails>();
}
public async Task<List<PRDetails>> GetCanvassByPRNo(CanvassDto CanvassDto)
{
var allItems = await _dbContext.PRDetails
.FromSqlRaw("EXEC GetCanvassByPRNo @UserId, @PRNo",
new SqlParameter("@UserId", CanvassDto.UserId),
new SqlParameter("@PRNo", CanvassDto.PRNo))
.ToListAsync();
return allItems ?? new List<PRDetails>();
}
public async Task<List<CanvassGroupByPRNo>> GetCanvassGroupByPRNo(CanvassDto CanvassDto)
{
var allItems = await _dbContext.CanvassGroupByPRNos
.FromSqlRaw("EXEC GetCanvassGroupByPRNo @UserId,@PRNo,@AggreItemNo,@IsTagging",
new SqlParameter("@UserId", CanvassDto.UserId),
new SqlParameter("@PRNo", CanvassDto.PRNo),
new SqlParameter("@AggreItemNo", CanvassDto.AggreItemNo ?? "N/A"),
new SqlParameter("@IsTagging", CanvassDto.IsTagging))
.ToListAsync();
return allItems ?? new List<CanvassGroupByPRNo>();
}
public async Task<List<Suppliers>> GetSupplierItemWOEmail(CanvassDto CanvassDto)
{
try
{
var allItems = await _dbContext.Suppliers
.FromSqlRaw($"EXEC GetSupplierItemWOEmail @ItemNo = '{CanvassDto.ItemNo}'")
.ToListAsync();
return allItems ?? new List<Suppliers>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<Suppliers>> GetSupplierById(CanvassDto CanvassDto)
{
try
{
var allItems = await _dbContext.Suppliers
.FromSqlRaw($"EXEC GetSupplierById @SupplierId",
new SqlParameter("@SupplierId", CanvassDto.SupplierId))
.ToListAsync();
return allItems ?? new List<Suppliers>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<RFQReference>> GetRFQ(CanvassDto CanvassDto)
{
try
{
var allItems = await _dbContext.RFQReferences
.FromSqlRaw($"EXEC GetRFQPerSupplier @SupplierId,@UserId",
new SqlParameter("@SupplierId", CanvassDto.SupplierId),
new SqlParameter("@UserId", CanvassDto.UserId))
.ToListAsync();
return allItems ?? new List<RFQReference>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<PRDetails>> GetPRItemList(CanvassDto CanvassDto)
{
try
{
var allItems = await _dbContext.PRDetails
.FromSqlRaw($"EXEC GetPRItemList @UserId = '{CanvassDto.UserId}'")
.ToListAsync();
return allItems ?? new List<PRDetails>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<PRDetails>> GetCanvassPerSupplierEmail(CanvassDto CanvassDto)
{
try
{
var allItems = await _dbContext.PRDetails
.FromSqlRaw($"EXEC GetCanvassPerSupplierEmail @UserId = '{CanvassDto.UserId}', @EmailAddress = '{CanvassDto.EmailAddress}'")
.ToListAsync();
return allItems ?? new List<PRDetails>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<PRDetails>> GetPRItem(CanvassDto CanvassDto)
{
try
{
var allItems = await _dbContext.PRDetails
.FromSqlRaw($"EXEC GetPRItem @UserId = '{CanvassDto.UserId}', @ItemNo = {CanvassDto.ItemNo}")
.ToListAsync();
return allItems ?? new List<PRDetails>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<WOResponse>> GetCanvassWOResponse(CanvassDto CanvassDto)
{
try
{
var allItems = await _dbContext.WOResponses
.FromSqlRaw($"EXEC GetCanvassWOResponse @UserId = '{CanvassDto.UserId}'")
.ToListAsync();
return allItems ?? new List<WOResponse>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<int> GetCanvassNo()
{
try
{
var latestCanvassNo = await _dbContext.Canvasses
.OrderByDescending(ic => ic.CanvassNo)
.FirstOrDefaultAsync();
if (latestCanvassNo != null)
{
return latestCanvassNo.CanvassNo;
}
else
{
return 0;
}
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<WOResponseById>> GetWOResponseBySuppId(CanvassDto CanvassDto)
{
try
{
var allItems = await _dbContext.WOResponseByIds
.FromSqlRaw($"EXEC GetWOResponseBySuppId @UserId = '{CanvassDto.UserId}',@SupplierId = '{CanvassDto.SupplierId}'")
.ToListAsync();
return allItems ?? new List<WOResponseById>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<RFQ> PostPerSupplierToken(CanvassDto CanvassDto)
{
try
{
await _dbContext.Database
.ExecuteSqlRawAsync("EXEC PostPerSupplierToken @UserId,@SupplierId,@PRNo,@ItemNo,@CanvassNo,@PRDetailsId",
new SqlParameter("@UserId", CanvassDto.UserId),
new SqlParameter("@SupplierId", CanvassDto.SupplierId),
new SqlParameter("@PRNo", CanvassDto.PRNo),
new SqlParameter("@ItemNo", CanvassDto.ItemNo),
new SqlParameter("@CanvassNo", CanvassDto.CanvassNo),
new SqlParameter("@PRDetailsId", CanvassDto.PRDetailsId));
return new RFQ();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<SupplierBidById>> GetSupplierBidById(CanvassDto CanvassDto)
{
try
{
var allItems = await _dbContext.SupplierBidByIds
.FromSqlRaw($"EXEC GetSupplierBidById @CanvassDetailId",
new SqlParameter("@CanvassDetailId", CanvassDto.CanvassDetailId))
.ToListAsync();
return allItems ?? new List<SupplierBidById>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<Suppliers>> GetMySuppliers(CanvassDto CanvassDto)
{
try
{
var allItems = await _dbContext.Suppliers
.FromSqlRaw($"EXEC GetMySuppliers @UserId,@SupplierId",
new SqlParameter("@UserId", CanvassDto.UserId),
new SqlParameter("@SupplierId", CanvassDto.SupplierId))
.ToListAsync();
return allItems ?? new List<Suppliers>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<MyPRWOCanvass>> GetMyPRWOCanvass(CanvassDto itemDto)
{
var allItems = await _dbContext.MyPRWOCanvass
.FromSqlRaw($"EXEC GetMyPRWOCanvass @UserId,@SupplierId,@Query",
new SqlParameter("@UserId", itemDto.UserId),
new SqlParameter("@SupplierId", itemDto.SupplierId),
new SqlParameter("@Query", itemDto.Query))
.ToListAsync();
return allItems ?? new List<MyPRWOCanvass>();
}
public async Task<List<Infrastructure.Entities.Canvass.PRList>>
GetPRListByPRNo(CanvassDto canvassDto)
{
var allItems = await _dbContext.PRItemList
.FromSqlRaw($"EXEC GetPRListByPRNo @PRNo,@UserId",
new SqlParameter("@UserId", canvassDto.UserId),
new SqlParameter("@PRNo", canvassDto.PRNo))
.ToListAsync();
return allItems ?? new List<Infrastructure.Entities.Canvass.PRList>();
}
public async Task<List<PRDetails>> GetCanvassPerSupplierId(CanvassDto itemCodeDto)
{
var allItems = await _dbContext.PRDetails
.FromSqlRaw($"EXEC GetCanvassPerSupplierId @UserId,@SupplierId",
new SqlParameter("@UserId", itemCodeDto.UserId),
new SqlParameter("@SupplierId", itemCodeDto.SupplierId))
.ToListAsync();
return allItems ?? new List<PRDetails>();
}
public async Task<List<AlternativeOfferDetails>>
GetAlternativeOfferByPRDetailId(CanvassDto canvassDto)
{
var allItems = await _dbContext.AlternativeOfferDetails
.FromSqlRaw($"EXEC GetAlternativeOfferByPRDetailId @UserId,@PRDetailsId",
new SqlParameter("@UserId", canvassDto.UserId),
new SqlParameter("@PRDetailsId", canvassDto.PRDetailsId))
.ToListAsync();
return allItems ?? new List<AlternativeOfferDetails>();
}
public async Task<List<ForCanvass>> GetForCanvassPerItem(CanvassDto CanvassDto)
{
var allItems = await _dbContext.ForCanvasses
.FromSqlRaw($"EXEC GetForCanvassPerItem @UserId,@ItemNo",
new SqlParameter("@UserId", CanvassDto.UserId),
new SqlParameter("@ItemNo", CanvassDto.ItemNo))
.ToListAsync();
return allItems ?? new List<ForCanvass>();
}
public async Task<List<ForCanvassFollowUp>> GetCanvassForFollowUp(CanvassDto canvassDto)
{
var allItems = await _dbContext.ForCanvassFollowUps
.FromSqlRaw($"EXEC GetCanvassForFollowUp")
.ToListAsync();
return allItems ?? new List<ForCanvassFollowUp>();
}
public async Task<List<AllForCanvass>> GetAllForCanvass()
{
var allForCanvass = await _dbContext.AllForCanvasses
.FromSqlRaw("EXEC GetAllForCanvass").ToListAsync();
return allForCanvass ?? new List<AllForCanvass>();
}
#endregion
#region Post Put
public async Task<Suppliers> PostApprovedSupp(CanvassDto CanvassDto)
{
try
{
await _dbContext.Database
.ExecuteSqlRawAsync("EXEC PostApprovedSupp @UserId,@CanvassId,@ItemNo",
new SqlParameter("@UserId", CanvassDto.UserId),
new SqlParameter("@CanvassId", CanvassDto.CanvassId != null ? CanvassDto.CanvassId : 0L),
new SqlParameter("@ItemNo", CanvassDto.ItemNo != null ? CanvassDto.ItemNo : 0L));
return new Suppliers();
}
catch (SqlException ex)
{
throw;
}
}
public async Task<CanvassDetail> PostSuggestedSupp(CanvassDto CanvassDto)
{
try
{
await _dbContext.Database
.ExecuteSqlRawAsync("EXEC PostSuggestedSupp @UserId,@CanvassDetailId,@ItemNo,@SupplierId,@CanvassId",
new SqlParameter("@UserId", CanvassDto.UserId),
new SqlParameter("@CanvassDetailId", CanvassDto.CanvassDetailId),
new SqlParameter("@ItemNo", CanvassDto.ItemNo),
new SqlParameter("@SupplierId", CanvassDto.SupplierId),
new SqlParameter("@CanvassId", CanvassDto.CanvassId));
return new CanvassDetail();
}
catch (SqlException ex)
{
throw;
}
}
public async Task<PRDetails> PostCanvass(CanvassDto CanvassDto)
{
try
{
await _dbContext.Database
.ExecuteSqlRawAsync("EXEC PostCanvass @UserId, @SupplierId, @Status,@Remarks",
new SqlParameter("@SupplierId", CanvassDto.SupplierId != null ? CanvassDto.SupplierId : 0L),
new SqlParameter("@UserId", CanvassDto.UserId),
new SqlParameter("@Status", CanvassDto.Status),
new SqlParameter("@Remarks", CanvassDto.Remarks ?? "N/A"));
return new PRDetails();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<Suppliers> PostTaggingSupplier(CanvassDto CanvassDto)
{
try
{
var (messCode, message) = CreateOutputParams();
await _dbContext.Database
.ExecuteSqlRawAsync($"EXEC PostPutSupplier @SupplierId, @ItemNo, @IsActive, @UserId, @SupplierName, " +
"@EmailAddress, @Address, @ContactNo, @ContactPerson,@IsTagging, @MessCode OUTPUT, @Message OUTPUT",
new SqlParameter("@SupplierId", CanvassDto.SupplierId != null ? CanvassDto.SupplierId : 0L),
new SqlParameter("@ItemNo", CanvassDto.ItemNo),
new SqlParameter("@IsActive", CanvassDto.IsActive),
new SqlParameter("@UserId", CanvassDto.UserId),
new SqlParameter("@SupplierName", CanvassDto.SupplierName),
new SqlParameter("@EmailAddress", CanvassDto.EmailAddress),
new SqlParameter("@Address", CanvassDto.Address ?? "NONE"),
new SqlParameter("@ContactNo", CanvassDto.ContactNo ?? "NONE"),
new SqlParameter("@ContactPerson", CanvassDto.ContactPerson ?? "NONE"),
new SqlParameter("@IsTagging", CanvassDto.IsTagging),
messCode,
message);
if ((byte)messCode.Value == 0)
{
throw new Exception(message.Value.ToString());
}
return new Suppliers();
}
catch (SqlException ex)
{
throw;
}
}
public async Task<Suppliers> PostPutItemTagging(CanvassDto canvassDto)
{
try
{
var (messCode, message) = CreateOutputParams();
await _dbContext.Database
.ExecuteSqlRawAsync($"EXEC PostPutItemTagging @SupplierId, @ItemNo, @IsActive, @UserId," +
"@MessCode OUTPUT, @Message OUTPUT",
new SqlParameter("@SupplierId", canvassDto.SupplierId != null ? canvassDto.SupplierId : 0L),
new SqlParameter("@ItemNo", canvassDto.ItemNo),
new SqlParameter("@IsActive", canvassDto.IsActive),
new SqlParameter("@UserId", canvassDto.UserId),
messCode,
message);
if ((byte)messCode.Value == 0)
{
throw new Exception(message.Value.ToString());
}
return new Suppliers();
}
catch (SqlException ex)
{
throw;
}
}
public async Task<Suppliers> PostPutSupplier(CanvassDto CanvassDto)
{
try
{
var messCode = new SqlParameter("@MessCode", SqlDbType.TinyInt) { Direction = ParameterDirection.Output };
var message = new SqlParameter("@Message", SqlDbType.VarChar, 8000) { Direction = ParameterDirection.Output };
await _dbContext.Database
.ExecuteSqlRawAsync($"EXEC PostPutSupplier @SupplierId, @ItemNo, @IsActive, @UserId, @SupplierName, " +
"@EmailAddress, @Address, @ContactNo, @ContactPerson,@IsTagging, @MessCode OUTPUT, @Message OUTPUT",
new SqlParameter("@SupplierId", CanvassDto.SupplierId != null ? CanvassDto.SupplierId : 0L),
new SqlParameter("@ItemNo", CanvassDto.ItemNo),
new SqlParameter("@IsActive", CanvassDto.IsActive),
new SqlParameter("@UserId", CanvassDto.UserId),
new SqlParameter("@SupplierName", CanvassDto.SupplierName),
new SqlParameter("@EmailAddress", CanvassDto.EmailAddress),
new SqlParameter("@Address", CanvassDto.Address ?? "NONE"),
new SqlParameter("@ContactNo", CanvassDto.ContactNo ?? "NONE"),
new SqlParameter("@ContactPerson", CanvassDto.ContactPerson ?? "NONE"),
new SqlParameter("@IsTagging", CanvassDto.IsTagging),
messCode,
message);
if ((byte)messCode.Value == 0)
{
throw new Exception(message.Value.ToString());
}
return new Suppliers();
}
catch (SqlException ex)
{
throw;
}
}
public async Task<Suppliers> PostPutMySupplier(CanvassDto canvassDto)
{
try
{
var messCode = new SqlParameter("@MessCode", SqlDbType.TinyInt) { Direction = ParameterDirection.Output };
var message = new SqlParameter("@Message", SqlDbType.VarChar, 8000) { Direction = ParameterDirection.Output };
await _dbContext.Database
.ExecuteSqlRawAsync($"EXEC PostPutMySupplier @SupplierId, @ItemNo, @IsActive, @UserId, @SupplierName," +
"@EmailAddress, @Address, @ContactNo, @ContactPerson,@TinNo,@LeadTime,@CurrencyId,@VatInc,@PaymentTermsId," +
"@MessCode OUTPUT, @Message OUTPUT",
new SqlParameter("@SupplierId", canvassDto.SupplierId != null ? canvassDto.SupplierId : 0L),
new SqlParameter("@ItemNo", canvassDto.ItemNo),
new SqlParameter("@IsActive", canvassDto.IsActive),
new SqlParameter("@UserId", canvassDto.UserId),
new SqlParameter("@SupplierName", canvassDto.SupplierName),
new SqlParameter("@EmailAddress", canvassDto.EmailAddress),
new SqlParameter("@Address", canvassDto.Address ?? "NONE"),
new SqlParameter("@ContactNo", canvassDto.ContactNo ?? "NONE"),
new SqlParameter("@ContactPerson", canvassDto.ContactPerson ?? "NONE"),
new SqlParameter("@TinNo", canvassDto.TinNo ?? "NONE"),
new SqlParameter("@LeadTime", canvassDto.LeadTime ?? "NONE"),
new SqlParameter("@CurrencyId", canvassDto.CurrencyId),
new SqlParameter("@VatInc", canvassDto.VatInc),
new SqlParameter("@PaymentTermsId", canvassDto.PaymentTermsId),
messCode,
message);
if ((byte)messCode.Value == 0)
{
throw new Exception(message.Value.ToString());
}
return new Suppliers();
}
catch (SqlException ex)
{
throw;
}
}
public async Task<CanvassDetail> PutSuppUnitPrice(CanvassDto CanvassDto)
{
try
{
await _dbContext.Database
.ExecuteSqlRawAsync($"EXEC PutSuppUnitPrice @UserId, @CanvassDetailId, @UnitPrice",
new SqlParameter("@CanvassDetailId", CanvassDto.CanvassDetailId != null ? CanvassDto.CanvassDetailId : 0L),
new SqlParameter("@UserId", CanvassDto.UserId),
new SqlParameter("@UnitPrice", CanvassDto.UnitPrice));
return new CanvassDetail();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<ForCanvassFollowUp> PutSupplierCanvass(long canvassSupplierId)
{
try
{
await _dbContext.Database
.ExecuteSqlRawAsync("EXEC PutCanvassForFollowUp @CanvassSupplierId",
new SqlParameter("@CanvassSupplierId", canvassSupplierId));
return new ForCanvassFollowUp();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<CanvassDetail> PutSuppBidDetails(CanvassDto canvassDto)
{
await _dbContext.Database
.ExecuteSqlRawAsync($"EXEC PutSuppBidDetails @UserId,@CanvassDetailId,@PRDetailsId,@UnitPrice,@Terms," +
$"@ItemName,@Specification,@Qty,@DeliveryDate,@CurrencyId,@Remarks,@Manufacturer,@UOMName,@IsReset",
new SqlParameter("@UserId", canvassDto.UserId),
new SqlParameter("@CanvassDetailId", canvassDto.CanvassDetailId),
new SqlParameter("@PRDetailsId", canvassDto.PRDetailsId),
new SqlParameter("@UnitPrice", canvassDto.UnitPrice),
new SqlParameter("@Terms", canvassDto.Terms),
new SqlParameter("@ItemName", canvassDto.ItemName),
new SqlParameter("@Specification", canvassDto.Specification),
new SqlParameter("@Qty", canvassDto.Qty),
new SqlParameter("@DeliveryDate", canvassDto.CommitmentDate),
new SqlParameter("@CurrencyId", canvassDto.CurrencyId),
new SqlParameter("@Remarks", canvassDto.Remarks),
new SqlParameter("@Manufacturer", canvassDto.Manufacturer),
new SqlParameter("@UOMName", canvassDto.UOMName),
new SqlParameter("@IsReset", canvassDto.IsReset));
return new CanvassDetail();
}
public async Task<CanvassSupplier> UnlockFormLink(CanvassDto canvassDto)
{
await _dbContext.Database
.ExecuteSqlRawAsync("EXEC UnlockFormLink @UserId,@CanvassSupplierId",
new SqlParameter("@UserId", canvassDto.UserId),
new SqlParameter("@CanvassSupplierId", canvassDto.CanvassSupplierId));
return new CanvassSupplier();
}
#endregion
}
}

View File

@ -0,0 +1,43 @@
using CPRNIMS.Infrastructure.Database;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Services
{
public class ErrorMessageService
{
private readonly NonInventoryDbContext _dbContext;
public ErrorMessageService(NonInventoryDbContext dbContext)
{
_dbContext = dbContext;
}
public async Task<List<Infrastructure.Entities.Account.ControllerAccess>> GetControllerAccessByUserId(string userId)
{
try
{
var getMyControllerAccess = await _dbContext.ControllerAccess
.FromSqlRaw($"EXEC GetElementAccessByUserId @UserId = '{userId}'")
.ToListAsync();
return getMyControllerAccess ?? new List<Infrastructure.Entities.Account.ControllerAccess>();
}
catch (Exception ex)
{
ex.ToString();
throw;
}
}
public async Task PostErrorMessage(Infrastructure.Entities.Common.ErrorMessage errorMessage)
{
await _dbContext.ErrorMessages.AddAsync(errorMessage);
await _dbContext.SaveChangesAsync();
}
}
}

View File

@ -0,0 +1,79 @@
using CPRNIMS.Domain.Contracts.Finance;
using CPRNIMS.Infrastructure.Database;
using CPRNIMS.Infrastructure.Dto.Finance;
using CPRNIMS.Infrastructure.Dto.Items;
using CPRNIMS.Infrastructure.Entities.Finance;
using CPRNIMS.Infrastructure.Entities.Purchasing;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Services.Finance
{
public class RR : IRR
{
private readonly NonInventoryDbContext _dbContext;
public RR(NonInventoryDbContext dbContext)
{
_dbContext = dbContext;
}
public async Task<List<ForPayment>> GetAllClosedPO(RRDetailsDto itemDto)
{
try
{
var allItems = await _dbContext.ForPayments
.FromSqlRaw($"EXEC GetAllClosedPO @UserId = '{itemDto.UserId}'")
.ToListAsync();
return allItems ?? new List<ForPayment>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<ReceivingDetail>> GetRRDetailByPO(RRDetailsDto itemDto)
{
try
{
var allItems = await _dbContext.ReceivingDetails
.FromSqlRaw($"EXEC GetRRDetailByPO @PONo,@POTypeId,@UserId",
new SqlParameter("@PONo", itemDto.PONo),
new SqlParameter("@POTypeId", itemDto.POTypeId),
new SqlParameter("@UserId", itemDto.UserId))
.ToListAsync();
return allItems ?? new List<ReceivingDetail>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<RRDetail> PostPutPayment(RRDetailsDto itemDto)
{
try
{
await _dbContext.Database
.ExecuteSqlRawAsync("EXEC PostPutPayment @UserId, @PONo, @POTypeId, @PRDetailsId",
new SqlParameter("@UserId", itemDto.UserId),
new SqlParameter("@PONo", itemDto.PONo),
new SqlParameter("@POTypeId", itemDto.POTypeId),
new SqlParameter("@PRDetailsId", itemDto.PRDetailsId));
return new RRDetail();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
}
}

View File

@ -0,0 +1,132 @@
using Google.Apis.Auth.OAuth2;
using Google.Apis.Drive.v3;
using Google.Apis.Services;
using Google.Apis.Util.Store;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Services
{
public class GoogleDriveService
{
private DriveService _driveService;
public GoogleDriveService(string serviceAccountKeyFilePath)
{
serviceAccountKeyFilePath = "wwwroot/GoogleSecurity/credentials.json";
InitializeDriveService(serviceAccountKeyFilePath);
}
private void InitializeDriveService(string serviceAccountKeyFilePath)
{
var credential = GoogleCredential.FromFile(serviceAccountKeyFilePath)
.CreateScoped(new[] { DriveService.ScopeConstants.Drive });
_driveService = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential
});
}
public async Task<string> UploadFileAsync(string filePath, string fileName)
{
var fileMetadata = new Google.Apis.Drive.v3.Data.File()
{
Name = fileName
};
FilesResource.CreateMediaUpload request;
using (var stream = new FileStream(filePath, FileMode.Open))
{
request = _driveService.Files.Create(fileMetadata, stream, "image/jpeg");
request.Fields = "id";
await request.UploadAsync();
}
var file = request.ResponseBody;
return file.Id;
}
public async Task UpdateFileAsync(string fileId, string newFilePath)
{
var fileMetadata = new Google.Apis.Drive.v3.Data.File();
using (var stream = new FileStream(newFilePath, FileMode.Open))
{
await _driveService.Files.Update(fileMetadata, fileId, stream, "image/jpeg").UploadAsync();
}
}
public async Task DeleteFileAsync(string fileId)
{
await _driveService.Files.Delete(fileId).ExecuteAsync();
}
public async Task<string> GetFileIdByNameAsync(string fileName)
{
//14uzoQM4pagf7F_CUZmwRxmaCAJ_8Nayg
fileName = "1.jpg";
var request = _driveService.Files.List();
request.Q = $"name='{fileName}'";
var response = await request.ExecuteAsync();
if (response.Files.Count > 0)
return response.Files[0].Id;
else
return null;
}
public async Task<string> GetFileIdByIdAsync(string fileName)
{
//14uzoQM4pagf7F_CUZmwRxmaCAJ_8Nayg
fileName = "1";
var request = _driveService.Files.List();
request.Q = $"name='{fileName}'";
var response = await request.ExecuteAsync();
if (response.Files.Count > 0)
return response.Files[0].Id;
else
return null;
}
public async Task<string> DownloadFileByNameAsync(string fileName, string downloadDirectory)
{
var fileId = await GetFileIdByNameAsync(fileName);
if (fileId != null)
{
var downloadPath = Path.Combine(downloadDirectory, fileName);
await DownloadFileByIdAsync(fileId, downloadPath);
return downloadPath;
}
else
{
throw new FileNotFoundException($"File with name '{fileName}' not found on Google Drive.");
}
}
public async Task DownloadFileByIdAsync(string fileId, string downloadPath)
{
var request = _driveService.Files.Get(fileId);
using (var stream = new FileStream(downloadPath, FileMode.Create))
{
await request.DownloadAsync(stream);
}
}
/* public async Task DownloadFileByNameAsync(string fileName, string downloadPath)
{
var fileId = await GetFileIdByNameAsync(fileName);
if (fileId != null)
{
await DownloadFileByIdAsync(fileId, downloadPath);
}
else
{
throw new FileNotFoundException($"File with name '{fileName}' not found on Google Drive.");
}
}
*/
}
}

View File

@ -0,0 +1,218 @@
using CPRNIMS.Domain.Contracts.Inventory;
using CPRNIMS.Infrastructure.Database;
using CPRNIMS.Infrastructure.Dto.Inventory;
using CPRNIMS.Infrastructure.Dto.Items;
using CPRNIMS.Infrastructure.Entities.Finance;
using CPRNIMS.Infrastructure.Entities.Inventory;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Services.Inventory
{
public class Inventory : IInventory
{
private readonly NonInventoryDbContext _dbContext;
public Inventory(NonInventoryDbContext dbContext)
{
_dbContext = dbContext;
}
public async Task<List<Infrastructure.Entities.Inventory.ItemDetail>> GetInventoryById(InventoryDto itemDto)
{
try
{
var allItems = await _dbContext.ItemDetails
.FromSqlRaw($"EXEC GetInventoryById @UserId = '{itemDto.UserId}',@InventoryId = '{itemDto.InventoryId}'")
.ToListAsync();
return allItems ?? new List<Infrastructure.Entities.Inventory.ItemDetail>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<Infrastructure.Entities.Inventory.Inventory>>
GetInventoryByUserId(InventoryDto itemDto)
{
try
{
if(itemDto.IsSorting == false)
{
itemDto.DateFrom=DateTime.Now;
itemDto.DateTo = DateTime.Now;
}
var allItems = await _dbContext.Inventories
.FromSqlRaw($"EXEC GetInventoryByUserId @UserId,@DateFrom,@DateTo,@IsSorting",
new SqlParameter("@UserId", itemDto.UserId),
new SqlParameter("@DateFrom", itemDto.DateFrom),
new SqlParameter("@DateTo", itemDto.DateTo),
new SqlParameter("@IsSorting", itemDto.IsSorting))
.ToListAsync();
return allItems ?? new List<Infrastructure.Entities.Inventory.Inventory>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<Lot>> GetLotNoById(InventoryDto itemDto)
{
try
{
var allItems = await _dbContext.Lots
.FromSqlRaw($"EXEC GetLotById @UserId = '{itemDto.UserId}'")
.ToListAsync();
return allItems ?? new List<Lot>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<Lot>> GetLotNo(InventoryDto itemDto)
{
var allItems = await _dbContext.Lots
.FromSqlRaw("EXEC GetLots @UserId",
new SqlParameter("@UserId", itemDto.UserId))
.ToListAsync();
return allItems ?? new List<Lot>();
}
public async Task<Lot> PostPutLotNo(InventoryDto itemDto)
{
try
{
await _dbContext.Database
.ExecuteSqlRawAsync("EXEC PostPutLotNo @UserId, @LotId, @LotTypeId,@LotName",
new SqlParameter("@LotId", itemDto.LotId != null ? itemDto.LotId : 0L),
new SqlParameter("@UserId", itemDto.UserId),
new SqlParameter("@LotTypeId", itemDto.LotTypeId),
new SqlParameter("@LotName", itemDto.LotName));
return new Lot();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<Infrastructure.Entities.Inventory.Inventory> PostPutReqApproval(InventoryDto itemDto)
{
try
{
await _dbContext.Database
.ExecuteSqlRawAsync("EXEC PostPutReqApproval @UserId, @ItemNo, @Status, @Remarks",
new SqlParameter("@ItemNo", itemDto.InventoryId != null ? itemDto.InventoryId : 0L),
new SqlParameter("@UserId", itemDto.UserId),
new SqlParameter("@Status", itemDto.Status),
new SqlParameter("@Remarks", itemDto.Remarks ?? "N/A"));
return new Infrastructure.Entities.Inventory.Inventory();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<ItemDetail> PostPutLotBin(InventoryDto itemDto)
{
try
{
await _dbContext.Database
.ExecuteSqlRawAsync("EXEC PostPutLotBin @UserId, @LotId, @InventoryId",
new SqlParameter("@InventoryId", itemDto.InventoryId),
new SqlParameter("@UserId", itemDto.UserId),
new SqlParameter("@LotId", itemDto.LotId));
return new ItemDetail();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<RequestItem> PostPutReqItems(InventoryDto itemDto)
{
try
{
if(itemDto.QtyReceived == null || itemDto.QtyReceived == 0)
{
itemDto.QtyReceived = 0;
}
if(itemDto.LotId == null || itemDto.LotId == 0)
{
itemDto.LotId = 0;
}
await _dbContext.Database
.ExecuteSqlRawAsync("EXEC PostPutReqItems @UserId, @RequestItemId, @ItemNo, @QtyRequest,@Status,@IsApproved,@QtyReceived,@LotId",
new SqlParameter("@UserId", itemDto.UserId),
new SqlParameter("@ItemNo", itemDto.ItemNo),
new SqlParameter("@RequestItemId", itemDto.RequestItemId != null ? itemDto.RequestItemId : 0L),
new SqlParameter("@QtyRequest", itemDto.QtyRequest),
new SqlParameter("@Status", itemDto.Status),
new SqlParameter("@IsApproved", itemDto.IsApproved),
new SqlParameter("@QtyReceived", itemDto.QtyReceived),
new SqlParameter("@LotId", itemDto.LotId));
return new RequestItem();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<RequestItemDetail>> GetRequestedItemByUserId(InventoryDto itemDto)
{
try
{
var allItems = await _dbContext.RequestItemDetails
.FromSqlRaw($"EXEC GetRequestedItemByUserId @UserId = '{itemDto.UserId}', " +
$"@RequestItemId = '{itemDto.RequestItemId}',@WithoutStocks = '{itemDto.WithoutStocks}'")
.ToListAsync();
return allItems ?? new List<RequestItemDetail>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<LotQtyByItem>> GetLotQtyByItem(InventoryDto itemDto)
{
try
{
var allItems = await _dbContext.LotQtyByItems
.FromSqlRaw($"EXEC GetLotQtyByItem @UserId = '{itemDto.UserId}', " +
$"@ItemNo = '{itemDto.ItemNo}',@LotId = '{itemDto.LotId}'")
.ToListAsync();
return allItems ?? new List<LotQtyByItem>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
}
}

View File

@ -0,0 +1,409 @@
using CPRNIMS.Domain.Contracts.Account;
using CPRNIMS.Domain.Contracts.Items;
using CPRNIMS.Infrastructure.Database;
using CPRNIMS.Infrastructure.Dto.Canvass;
using CPRNIMS.Infrastructure.Dto.Items;
using CPRNIMS.Infrastructure.Entities.Account;
using CPRNIMS.Infrastructure.Entities.Canvass;
using CPRNIMS.Infrastructure.Entities.Items;
using CPRNIMS.Infrastructure.Entities.Purchasing;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Services.Items
{
public class Item : IItem
{
private readonly NonInventoryDbContext _dbContext;
public Item(NonInventoryDbContext dbContext) {
_dbContext = dbContext;
}
public async Task<ItemCodeDto> PostPutItem(ItemCodeDto itemDto)
{
try
{
var messCodeParam = new SqlParameter("@MessCode", SqlDbType.TinyInt)
{
Direction = ParameterDirection.Output
};
var messageParam = new SqlParameter("@Message", SqlDbType.VarChar, 500)
{
Direction = ParameterDirection.Output
};
var itemCodeParam = new SqlParameter("@ItemCode", SqlDbType.BigInt)
{
Direction = ParameterDirection.Output
};
await _dbContext.Database.ExecuteSqlRawAsync(
"EXEC PostPutItem @ItemCodeId, @ItemName, @ItemDescription, @ItemCategoryId, @Status, @UserId, " +
"@ItemCode OUTPUT, @MessCode OUTPUT, @Message OUTPUT",
new SqlParameter("@ItemCodeId", itemDto.ItemCodeId != null ? itemDto.ItemCodeId : 0L),
new SqlParameter("@ItemName", itemDto.ItemName ?? (object)DBNull.Value),
new SqlParameter("@ItemDescription", itemDto.ItemDescription ?? (object)DBNull.Value),
new SqlParameter("@ItemCategoryId", itemDto.ItemCategoryId),
new SqlParameter("@Status", itemDto.Status != null ? itemDto.Status : 4),
new SqlParameter("@UserId", itemDto.UserId ?? (object)DBNull.Value),
itemCodeParam,
messCodeParam,
messageParam
);
var messCode = (byte)messCodeParam.Value;
var message = messageParam.Value?.ToString();
var itemCode = itemCodeParam.Value != DBNull.Value ? (long?)itemCodeParam.Value : null;
return new ItemCodeDto
{
ItemCodeId = Convert.ToInt64(itemCode),
ItemName = itemDto.ItemName,
ItemDescription = itemDto.ItemDescription,
ItemCategoryId = itemDto.ItemCategoryId,
Status = itemDto.Status,
UserId = itemDto.UserId
};
}
catch (Exception ex)
{
// You could log ex.Message or rethrow with a custom message
throw new Exception("An error occurred while executing PostPutItem.", ex);
}
}
public async Task<Infrastructure.Entities.Items.Item> PutItemDetail(ItemDto itemDto)
{
try
{
await _dbContext.Database
.ExecuteSqlRawAsync($"EXEC PutItemDetail @ItemCodeId,@ItemLocalId,@ItemTypeId,@UOMId,@ItemColorId,@IsActive," +
$"@UserId,@ItemNo,@PRTypeId,@PackagingTypeId,@Qty,@ItemAttachId,@ItemAttachPath,@IsCommon,@ItemCategoryId," +
$"@RequestTypeId,@ItemName,@ItemDescription,@IsMDLD",
new SqlParameter("@ItemCodeId", itemDto.ItemCodeId != null ? itemDto.ItemCodeId : 0L),
new SqlParameter("@ItemLocalId", itemDto.ItemLocalId),
new SqlParameter("@ItemTypeId", itemDto.ItemTypeId),
new SqlParameter("@UOMId", itemDto.UOMId),
new SqlParameter("@ItemColorId", itemDto.ItemColorId),
new SqlParameter("@IsActive", itemDto.IsActive),
new SqlParameter("@UserId", itemDto.UserId),
new SqlParameter("@ItemNo", itemDto.ItemNo),
new SqlParameter("@PRTypeId", itemDto.PRTypeId),
new SqlParameter("@PackagingTypeId", itemDto.PackagingTypeId),
new SqlParameter("@Qty", itemDto.Qty),
new SqlParameter("@ItemAttachId", itemDto.ItemAttachId != null ? itemDto.ItemAttachId : 0L),
new SqlParameter("@ItemAttachPath", itemDto.ItemAttachPath ?? "N/A"),
new SqlParameter("@IsCommon", itemDto.IsCommon),
new SqlParameter("@ItemCategoryId", itemDto.ItemCategoryId),
new SqlParameter("@RequestTypeId", itemDto.RequestTypeId),
new SqlParameter("@ItemName", itemDto.ItemName),
new SqlParameter("@ItemDescription", itemDto.ItemDescription),
new SqlParameter("@IsMDLD", itemDto.IsMDLD));
return new Infrastructure.Entities.Items.Item();
}
catch (Exception ex)
{
ex.ToString();
throw;
}
}
public async Task<List<ItemLocalization>> GetItemLocalization(ItemDto itemDto)
{
try
{
var localizations = await _dbContext.ItemLocalizations
.Where(ic => ic.IsActive == true &&
EF.Functions.Like(ic.ItemLocalName, $"%{itemDto.ItemLocalName}%"))
.Take(15)
.ToListAsync();
return localizations ?? new List<ItemLocalization>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<ItemCategory>> GetItemCateg(ItemDto itemDto)
{
try
{
if(itemDto.ItemCategoryId ==0 || itemDto.ItemCategoryId == null)
{
var categories = await _dbContext.ItemCategories
.Where(ic => ic.IsActive == true)
.ToListAsync();
return categories ?? new List<ItemCategory>();
}
else
{
var categories = await _dbContext.ItemCategories
.Where(ic => ic.IsActive == true && ic.ItemCategoryId == itemDto.ItemCategoryId)
.ToListAsync();
return categories ?? new List<ItemCategory>();
}
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<Infrastructure.Entities.Items.Item>> GetItemDetail(ItemDto itemDto)
{
try
{
var allItems = await _dbContext.Items
.FromSqlRaw($"EXEC GetItemDetail @ItemCodeId,@UserId",
new SqlParameter("@ItemCodeId", itemDto.ItemCodeId),
new SqlParameter("@UserId", itemDto.UserId))
.ToListAsync();
return allItems ?? new List<Infrastructure.Entities.Items.Item>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<ItemList>> GetItemList(ItemCodeDto itemCode)
{
try
{
var allItems = await _dbContext.ItemList
.FromSqlRaw($"EXEC GetItemList @UserId = '{itemCode.UserId}'")
.ToListAsync();
return allItems ?? new List<ItemList>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<ItemColor>> GetItemColor(ItemDto itemDto)
{
try
{
var colors = await _dbContext.ItemColors
.Where(ic => EF.Functions.Like(ic.ItemColorName, $"%{itemDto.ItemColorName}%"))
.Take(5)
.ToListAsync();
return colors ?? new List<ItemColor>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<UnitOfMessure>> GetItemUOM(ItemDto itemDto)
{
try
{
var uoms = await _dbContext.UnitOfMessures
.Where(ic => ic.IsActive == true &&
EF.Functions.Like(ic.UOMName, $"%{itemDto.UOMName}%"))
.Take(150)
.ToListAsync();
return uoms ?? new List<UnitOfMessure>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<ItemAttachement> PostPutItemPath(ItemDto itemDto)
{
try
{
var isExist = await _dbContext.ItemAttachements
.FirstOrDefaultAsync(ia => ia.IsActive == true
&& ia.ItemNo == itemDto.ItemNo);
if(isExist != null)
{
isExist.ItemAttachPath = itemDto.ItemAttachPath;
await _dbContext.SaveChangesAsync();
return new ItemAttachement();
}
else
{
return new ItemAttachement();
}
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<ItemCart> PostPutItemCart(ItemDto itemDto)
{
try
{
await _dbContext.Database
.ExecuteSqlRawAsync("EXEC PostPutItemCart @ItemCartId,@ItemNo,@UserId,@UOMId,@ItemColorId,@ItemCategoryId,@PackagingTypeId,@ItemAttachId,@ItemLocalId",
new SqlParameter("@ItemCartId", itemDto.ItemCartId != null ? itemDto.ItemCartId : 0L),
new SqlParameter("@ItemNo", itemDto.ItemNo != null ? itemDto.ItemNo : 0L),
new SqlParameter("@UOMId", itemDto.UOMId),
new SqlParameter("@ItemColorId", itemDto.ItemColorId),
new SqlParameter("@ItemCategoryId", itemDto.ItemCategoryId),
new SqlParameter("@PackagingTypeId", itemDto.PackagingTypeId),
new SqlParameter("@ItemAttachId", itemDto.ItemAttachId),
new SqlParameter("@UserId", itemDto.UserId),
new SqlParameter("@ItemLocalId", itemDto.ItemLocalId));
return new ItemCart();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<ItemCart>> GetItemCart(ItemDto itemDto)
{
try
{
var allItems = await _dbContext.ItemCarts
.FromSqlRaw($"EXEC GetItemCart @UserId,@RequestTypeId,@IsCount",
new SqlParameter("@UserId", itemDto.UserId),
new SqlParameter("@RequestTypeId", itemDto.RequestTypeId),
new SqlParameter("@IsCount", itemDto.IsCount))
.ToListAsync();
return allItems ?? new List<ItemCart>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<ItemCart> PostPurchRequest(ItemDto itemDto)
{
try
{
if(itemDto.RequestTypeId == 1)//Internal
{
itemDto.Status = 2;
itemDto.IsApproved = 2;
await _dbContext.Database
.ExecuteSqlRawAsync("EXEC PostPutReqItems @UserId, @RequestItemId, @ItemNo, @QtyRequest,@Status,@IsApproved,@QtyReceived,@LotId",
new SqlParameter("@UserId", itemDto.UserId),
new SqlParameter("@ItemNo", itemDto.ItemNo),
new SqlParameter("@RequestItemId", itemDto.RequestItemId != null ? itemDto.RequestItemId : 0L),
new SqlParameter("@QtyRequest", itemDto.Qty),
new SqlParameter("@Status", itemDto.Status),
new SqlParameter("@IsApproved", itemDto.IsApproved),
new SqlParameter("@QtyReceived", itemDto.QtyReceived),
new SqlParameter("@LotId", itemDto.LotId));
}
else
{
await _dbContext.Database
.ExecuteSqlRawAsync("EXEC PostPurchRequest @ItemCartId, @IsActive, @UserId,@ItemCount,@PRNo,@DateNeeded,@Qty,@ChargeTo,@Remarks",
new SqlParameter("@ItemCartId", itemDto.ItemCartId != null ? itemDto.ItemCartId : 0L),
new SqlParameter("@IsActive", 1),
new SqlParameter("@UserId", itemDto.UserId),
new SqlParameter("@ItemCount", itemDto.ItemCount),
new SqlParameter("@PRNo", itemDto.PRNo),
new SqlParameter("@DateNeeded", itemDto.DateNeeded),
new SqlParameter("@Qty", itemDto.Qty),
new SqlParameter("@ChargeTo", itemDto.ChargeTo),
new SqlParameter("@Remarks", itemDto.Remarks));
}
return new ItemCart();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<long> GetPRNo()
{
try
{
// Query the PRs table
var latestPR = await _dbContext.PRs
.OrderByDescending(ic => ic.PRNo) // Sort by PRNo in descending order
.FirstOrDefaultAsync(); // Retrieve the first record
if (latestPR != null)
{
return latestPR.PRNo;
}
else
{
return 0; // Example: Return 0 if no records found
}
}
catch (SqlException ex)
{
// Handle the exception (log, rethrow, etc.)
ex.ToString();
throw;
}
}
Task<ItemCart> IItem.PostPutItemPath(ItemDto itemDto)
{
throw new NotImplementedException();
}
public async Task <List<Departments>> GetDepartment(ItemCodeDto itemCode)
{
try
{
var departments = await _dbContext.Departments
.Where(d => d.IsActive == true)
.ToListAsync();
return departments;
}
catch (Exception ex)
{
// Log the exception or handle it as needed
throw;
}
}
public async Task<List<NotifUserKey>> GetNotifUserKey(ItemDto itemDto)
{
try
{
var allItems = await _dbContext.NotifUserKeys
.FromSqlRaw($"EXEC GetNotifUserKey @UserId,@Status,@PRDetailsId,@PRNo",
new SqlParameter("@UserId", itemDto.UserId),
new SqlParameter("@Status", itemDto.Status),
new SqlParameter("@PRDetailsId", itemDto.PRDetailsId),
new SqlParameter("@PRNo", itemDto.PRNo))
.ToListAsync();
return allItems ?? new List<NotifUserKey>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
}
}

View File

@ -0,0 +1,20 @@
using Microsoft.Data.SqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Services
{
public static class OutputParamMessage
{
public static (SqlParameter MessCode, SqlParameter Message) CreateOutputParams()
{
var messCode = new SqlParameter("@MessCode", SqlDbType.TinyInt) { Direction = ParameterDirection.Output };
var message = new SqlParameter("@Message", SqlDbType.VarChar, 8000) { Direction = ParameterDirection.Output };
return (messCode, message);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,323 @@
using CPRNIMS.Domain.Contracts.PR;
using CPRNIMS.Infrastructure.Database;
using CPRNIMS.Infrastructure.Dto.PR;
using CPRNIMS.Infrastructure.Entities.Common;
using CPRNIMS.Infrastructure.Entities.PO;
using CPRNIMS.Infrastructure.Entities.Purchasing;
using CPRNIMS.Infrastructure.Entities.SMTP;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using static CPRNIMS.Domain.Services.OutputParamMessage;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
namespace CPRNIMS.Domain.Services.PR
{
public class PRequest : IPRequest
{
private readonly NonInventoryDbContext _dbContext;
public PRequest(NonInventoryDbContext dbContext)
{
_dbContext = dbContext;
}
#region Get
public async Task<List<PRList>> GetAllPR(PRDto PRDto)
{
var allItems = await _dbContext.PRLists
.FromSqlRaw($"EXEC GetAllPR @UserId,@IsArchived",
new SqlParameter("@UserId", PRDto.UserId),
new SqlParameter("@IsArchived", PRDto.IsArchived))
.ToListAsync();
return allItems ?? new List<PRList>();
}
public async Task<List<PRDto>> GetApproverName(PRDto PRDto)
{
var result = await _dbContext.Approved
.Where(a => a.PRDetailsId == PRDto.PRDetailsId && (a.ApproverId == 1 || a.ApproverId == 2))
.GroupBy(a => a.PRDetailsId)
.Select(g => new PRDto
{
AttestedBy = g.Where(x => x.ApproverId == 1).Select(x => x.ApprovedBy).FirstOrDefault(),
ApprovedBy = g.Where(x => x.ApproverId == 2).Select(x => x.ApprovedBy).FirstOrDefault()
})
.ToListAsync();
return result ?? new List<PRDto>();
}
public async Task<List<ForRR>> GetPRByRRId(PRDto PRDto)
{
var allItems = await _dbContext.ForRRs
.FromSqlRaw($"EXEC GetPRByRRId @RRId = '{PRDto.RRId}',@UserId = '{PRDto.UserId}'")
.ToListAsync();
return allItems ?? new List<ForRR>();
}
public async Task<List<ForReceiving>> GetForReceiving(PRDto PRDto)
{
var allItems = await _dbContext.ForReceivings
.FromSqlRaw($"EXEC GetForReceiving @UserId,@IsDenied",
new SqlParameter("@UserId", PRDto.UserId),
new SqlParameter("@IsDenied", PRDto.IsDenied))
.ToListAsync();
return allItems ?? new List<ForReceiving>();
}
public async Task<List<ReceivingDetail>> GetRRDetailByPO(PRDto PRDto)
{
var allItems = await _dbContext.ReceivingDetails
.FromSqlRaw($"EXEC GetRRDetailByPO @PONo,@POTypeId,@UserId",
new SqlParameter("@PONo", PRDto.PONo),
new SqlParameter("@POTypeId", PRDto.POTypeId),
new SqlParameter("@UserId", PRDto.UserId))
.ToListAsync();
return allItems ?? new List<ReceivingDetail>();
}
public async Task<List<ForReceiving>> GetItemDetailForReceiving(PRDto PRDto)
{
var allItems = await _dbContext.ForReceivings
.FromSqlRaw("EXEC GetItemDetailForReceiving @UserId,@ItemNo",
new SqlParameter("@UserId", PRDto.UserId),
new SqlParameter("@ItemNo", PRDto.ItemNo))
.ToListAsync();
return allItems ?? new List<ForReceiving>();
}
public async Task<List<ItemApproval>> GetMyPR(PRDto PRDto)
{
var allItems = await _dbContext.ItemApprovals
.FromSqlRaw($"EXEC GetMyPR @UserId,@PRDetailsId",
new SqlParameter("@UserId", PRDto.UserId),
new SqlParameter("@PRDetailsId", PRDto.PRDetailsId))
.ToListAsync();
return allItems ?? new List<ItemApproval>();
}
public async Task<List<NotifUserKey>> GetNotifUserKey(PRDto PRDto)
{
var allItems = await _dbContext.NotifUserKeys
.FromSqlRaw($"EXEC GetNotifUserKey @UserId,@Status,@PRDetailsId,@PRNo",
new SqlParameter("@UserId", PRDto.UserId),
new SqlParameter("@Status", PRDto.Status),
new SqlParameter("@PRDetailsId", PRDto.PRDetailsId),
new SqlParameter("@PRNo", PRDto.PRNo))
.ToListAsync();
return allItems ?? new List<NotifUserKey>();
}
public async Task<List<PRDetails>> GetPRDetailByPRNo(PRDto PRDto)
{
var allItems = await _dbContext.PRDetails
.FromSqlRaw($"EXEC GetPRDetailByPRNo @UserId, @PRNo",
new SqlParameter("@UserId", PRDto.UserId),
new SqlParameter("@PRNo", PRDto.PRNo))
.ToListAsync();
return allItems ?? new List<PRDetails>();
}
public async Task<List<PRTracking>> GetPRStatusById(PRDto PRDto)
{
var allItems = await _dbContext.PRTrackings
.FromSqlRaw("EXEC GetPRStatusById @UserId,@PRDetailId",
new SqlParameter("@UserId", PRDto.UserId),
new SqlParameter("@PRDetailId", PRDto.PRDetailsId))
.ToListAsync();
return allItems ?? new List<PRTracking>();
}
public async Task<List<Dashboard>> GetDashBoard(PRDto PRDto)
{
var allItems = await _dbContext.Dashboards
.FromSqlRaw($"EXEC GetDashBoard @UserId",
new SqlParameter("@UserId", PRDto.UserId))
.ToListAsync();
return allItems ?? new List<Dashboard>();
}
public async Task<List<Infrastructure.Entities.Canvass.PRList>>
GetPRListByPRNo(PRDto PRDto)
{
var allItems = await _dbContext.PRItemList
.FromSqlRaw("EXEC GetPRListByPRNo @PRNo,@UserId",
new SqlParameter("@UserId", PRDto.UserId),
new SqlParameter("@PRNo", PRDto.PRNo))
.ToListAsync();
return new List<Infrastructure.Entities.Canvass.PRList>();
}
public async Task<List<RRReport>> GetDetailedPRTracking(PRDto PRDto)
{
var allItems = await _dbContext.DetailedPRTrackings
.FromSqlRaw("EXEC GetDetailedPRTracking @UserId",
new SqlParameter("@UserId", PRDto.UserId)).ToListAsync();
return allItems ?? new List<RRReport>();
}
public async Task<List<AlternativeOffer>> GetSupplierAlternativeOffer(PRDto PRDto)
{
var rfq = await _dbContext.AlternativeOffers
.FromSqlRaw("EXEC GetSupplierAlternativeOffer @UserId",
new SqlParameter("@UserId", PRDto.UserId)).ToListAsync();
return rfq ?? new List<AlternativeOffer>();
}
public async Task<List<AlternativeOfferDetails>> GetSupplierAlterOfferDetails(PRDto PRDto)
{
var rfq = await _dbContext.AlternativeOfferDetails
.FromSqlRaw("EXEC GetAlternativeOfferDetails @UserId,@CanvassDetailId",
new SqlParameter("@UserId", PRDto.UserId),
new SqlParameter("@CanvassDetailId", PRDto.CanvassDetailId)).ToListAsync();
return rfq ?? new List<AlternativeOfferDetails>();
}
#endregion
#region Post Put
public async Task<PRDetails> PostPRApproveReject(PRDto PRDto)
{
try
{
await _dbContext.Database
.ExecuteSqlRawAsync("EXEC PostPRApproveReject @UserId, @ItemNo, @Status, @PRDetailsId, @Remarks",
new SqlParameter("@ItemNo", PRDto.ItemNo != null ? PRDto.ItemNo : 0L),
new SqlParameter("@UserId", PRDto.UserId),
new SqlParameter("@Status", PRDto.Status),
new SqlParameter("@PRDetailsId", PRDto.PRDetailsId),
new SqlParameter("@Remarks", PRDto.Remarks ?? "N/A"));
return new PRDetails();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<PRDetails> PutItemDetail(PRDto PRDto)
{
try
{
await _dbContext.Database
.ExecuteSqlRawAsync($"EXEC PutPRItemDetail @UserId, @ItemLocalId, @UOMId, @ItemColorId," +
$"@Qty,@ItemCategoryId,@PRDetailsId,@Remarks,@ItemName,@ItemDescription",
new SqlParameter("@PRDetailsId", PRDto.PRDetailsId != null ? PRDto.PRDetailsId : 0L),
new SqlParameter("@ItemLocalId", PRDto.ItemLocalId),
new SqlParameter("@UOMId", PRDto.UOMId),
new SqlParameter("@ItemColorId", PRDto.ItemColorId),
new SqlParameter("@UserId", PRDto.UserId),
new SqlParameter("@Qty", PRDto.Qty),
new SqlParameter("@ItemCategoryId", PRDto.ItemCategoryId),
new SqlParameter("@Remarks", PRDto.Remarks),
new SqlParameter("@ItemName", PRDto.ItemName),
new SqlParameter("@ItemDescription", PRDto.ItemDescription));
return new PRDetails();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<PRDetails> PostPutDeniedItem(PRDto PRDto)
{
try
{
await _dbContext.Database
.ExecuteSqlRawAsync("EXEC PostPutDeniedItem @UserId,@PRDetailsId,@Remarks",
new SqlParameter("@UserId", PRDto.UserId),
new SqlParameter("@PRDetailsId", PRDto.PRDetailsId),
new SqlParameter("@Remarks", PRDto.Remarks ?? "N/A"));
return new PRDetails();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<PRDetails> PostPutReceiving(PRDto PRDto)
{
try
{
await _dbContext.Database
.ExecuteSqlRawAsync($"EXEC PostPutReceiving @UserId, @PONo, @POTypeId, @EmailAddress, @DRNo, @DocTypeId, @QuantityReceived,@RRNo,@PRDetailsId,@Remarks,@ReceivedDate,@IsCompleted",
new SqlParameter("@UserId", PRDto.UserId),
new SqlParameter("@PONo", PRDto.PONo),
new SqlParameter("@POTypeId", PRDto.POTypeId),
new SqlParameter("@EmailAddress", PRDto.EmailAddress),
new SqlParameter("@DRNo", PRDto.DRNo),
new SqlParameter("@DocTypeId", PRDto.DocTypeId),
new SqlParameter("@QuantityReceived", PRDto.QuantityReceived),
new SqlParameter("@RRNo", PRDto.RRNo),
new SqlParameter("@PRDetailsId", PRDto.PRDetailsId),
new SqlParameter("@Remarks", PRDto.Remarks ?? "N/A"),
new SqlParameter("@ReceivedDate", PRDto.ReceivedDate),
new SqlParameter("@IsCompleted", PRDto.IsCompleted));
return new PRDetails();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<PRDetails> PutPOClose(PRDto PRDto)
{
await _dbContext.Database
.ExecuteSqlRawAsync("EXEC PutPOClose @UserId, @PONo, @POTypeId, @EmailAddress,@PRDetailsId,@DocTypeId,@PRNo,@Remarks",
new SqlParameter("@UserId", PRDto.UserId),
new SqlParameter("@PONo", PRDto.PONo),
new SqlParameter("@POTypeId", PRDto.POTypeId),
new SqlParameter("@EmailAddress", PRDto.EmailAddress),
new SqlParameter("@DocTypeId", PRDto.DocTypeId),
new SqlParameter("@PRDetailsId", PRDto.PRDetailsId),
new SqlParameter("@PRNo", PRDto.PRNo),
new SqlParameter("@Remarks", PRDto.Remarks ?? "N/A"));
return new PRDetails();
}
public async Task<AlternativeOfferDetails> PutSupplierAlterOffer(PRDto pRDto)
{
await _dbContext.Database
.ExecuteSqlRawAsync("EXEC PutSupplierAlterOffer @UserId,@AlternativeOfferId,@CanvassDetailId",
new SqlParameter("@UserId", pRDto.UserId),
new SqlParameter("@AlternativeOfferId", pRDto.AlternativeOfferId),
new SqlParameter("@CanvassDetailId", pRDto.CanvassDetailId));
return new AlternativeOfferDetails();
}
public async Task<List<NotificationById>> GetNotificationById(PRDto PRDto)
{
var allItems = await _dbContext.NotificationByIds
.FromSqlRaw("EXEC GetNotificationById @UserId,@PRDetailsId,@AppsModuleId",
new SqlParameter("@UserId", PRDto.UserId),
new SqlParameter("@PRDetailsId", PRDto.PRDetailsId),
new SqlParameter("@AppsModuleId", PRDto.AppsModuleId))
.ToListAsync();
return allItems ?? new List<NotificationById>();
}
public async Task<MessageResponse> PRItemRemoval(PRDto prDto)
{
var (messCode, message) = CreateOutputParams();
await _dbContext.Database.ExecuteSqlRawAsync(
"EXEC PRItemRemoval @UserId,@PRDetailsId,@Remarks,@MessCode OUTPUT,@Message OUTPUT",
new SqlParameter("@UserId", prDto.UserId),
new SqlParameter("@PRDetailsId", prDto.PRDetailsId),
new SqlParameter("@Remarks", prDto.Remarks ?? (object)DBNull.Value),
messCode,
message
);
var response = new MessageResponse
{
Message = message.Value?.ToString(),
MessageCode = Convert.ToByte(messCode.Value)
};
return response;
}
#endregion
}
}

View File

@ -0,0 +1,227 @@
using CPRNIMS.Domain.Contracts.Receiving;
using CPRNIMS.Infrastructure.Database;
using CPRNIMS.Infrastructure.Dto.Items;
using CPRNIMS.Infrastructure.Entities.Purchasing;
using CPRNIMS.Infrastructure.Entities.Receiving;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Services.Receiving
{
public class Receiving : IReceiving
{
private readonly NonInventoryDbContext _dbContext;
public Receiving(NonInventoryDbContext dbContext)
{
_dbContext = dbContext;
}
#region Get
public async Task<List<Infrastructure.Entities.Receiving.RRReport>> GetRRReport(ItemDto itemDto)
{
try
{
if (!itemDto.IsSorting)
{
itemDto.DateFrom = DateTime.Today;
itemDto.DateTo = DateTime.Today.AddDays(1).AddSeconds(-1);
}
var allItems = await _dbContext.RRReports
.FromSqlRaw($"EXEC GetRRReport @DateFrom,@DateTo,@IsSorting",
new SqlParameter("@DateFrom", itemDto.DateFrom),
new SqlParameter("@DateTo", itemDto.DateTo),
new SqlParameter("@IsSorting", itemDto.IsSorting))
.ToListAsync();
return allItems ?? new List<Infrastructure.Entities.Receiving.RRReport>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<ForReceiving>> GetForReceiving(ItemDto itemDto)
{
try
{
var allItems = await _dbContext.ForReceivings
.FromSqlRaw($"EXEC GetForReceiving @UserId,@IsDenied",
new SqlParameter("@UserId", itemDto.UserId),
new SqlParameter("@IsDenied", itemDto.IsDenied))
.ToListAsync();
return allItems ?? new List<ForReceiving>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<RR>> GetRR(ItemDto itemDto)
{
try
{
var allItems = await _dbContext.RRs
.FromSqlRaw($"EXEC GetRR @UserId",
new SqlParameter("@UserId", itemDto.UserId))
.ToListAsync();
return allItems ?? new List<RR>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<RRSeries>> GetLatestRRNo(ItemDto itemDto)
{
try
{
return await _dbContext.RRSeries.FromSqlRaw("EXEC GetLatestRRNo @UserId",
new SqlParameter("@UserId",itemDto.UserId)).ToListAsync();
}
catch (Exception)
{
throw;
}
}
public async Task<List<ReceivingDetail>> GetRRDetailByPO(ItemDto itemDto)
{
try
{
var allItems = await _dbContext.ReceivingDetails
.FromSqlRaw($"EXEC GetRRDetailByPO @PONo,@POTypeId,@UserId",
new SqlParameter("@PONo", itemDto.PONo),
new SqlParameter("@POTypeId", itemDto.POTypeId),
new SqlParameter("@UserId", itemDto.UserId))
.ToListAsync();
return allItems ?? new List<ReceivingDetail>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<List<RRDetail>> GetRRDetail(ItemDto itemDto)
{
try
{
var allItems = await _dbContext.RRDetailss
.FromSqlRaw($"EXEC GetRRDetail @RRNo,@UserId",
new SqlParameter("@RRNo", itemDto.RRNo),
new SqlParameter("@UserId", itemDto.UserId))
.ToListAsync();
return allItems ?? new List<RRDetail>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
#endregion
#region Post Put
public async Task<PRDetails> PostPutReceiving(ItemDto itemDto)
{
try
{
await _dbContext.Database
.ExecuteSqlRawAsync($"EXEC PostPutReceiving @UserId, @PONo, @POTypeId, @EmailAddress, @DRNo, @DocTypeId, @QuantityReceived,@RRNo,@PRDetailsId,@Remarks,@ReceivedDate,@IsCompleted",
new SqlParameter("@UserId", itemDto.UserId),
new SqlParameter("@PONo", itemDto.PONo),
new SqlParameter("@POTypeId", itemDto.POTypeId),
new SqlParameter("@EmailAddress", itemDto.EmailAddress),
new SqlParameter("@DRNo", itemDto.DRNo),
new SqlParameter("@DocTypeId", itemDto.DocTypeId),
new SqlParameter("@QuantityReceived", itemDto.QuantityReceived),
new SqlParameter("@RRNo", itemDto.RRNo),
new SqlParameter("@PRDetailsId", itemDto.PRDetailsId),
new SqlParameter("@Remarks", itemDto.Remarks ?? "N/A"),
new SqlParameter("@ReceivedDate", itemDto.ReceivedDate),
new SqlParameter("@IsCompleted", itemDto.IsCompleted));
if (!isUpdated)
{
await UpdateRRNoSeriesAsync(itemDto.RRNo);
}
return new PRDetails();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
bool isUpdated=false;
public async Task<PRDetails> PutPOClose(ItemDto itemDto)
{
try
{
await _dbContext.Database
.ExecuteSqlRawAsync("EXEC PutPOClose @UserId, @PONo, @POTypeId, @EmailAddress,@PRDetailsId,@DocTypeId,@PRNo,@Remarks",
new SqlParameter("@UserId", itemDto.UserId),
new SqlParameter("@PONo", itemDto.PONo),
new SqlParameter("@POTypeId", itemDto.POTypeId),
new SqlParameter("@EmailAddress", itemDto.EmailAddress),
new SqlParameter("@DocTypeId", itemDto.DocTypeId),
new SqlParameter("@PRDetailsId", itemDto.PRDetailsId),
new SqlParameter("@PRNo", itemDto.PRNo),
new SqlParameter("@Remarks", itemDto.Remarks ?? "N/A"));
return new PRDetails();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
private async Task UpdateRRNoSeriesAsync(long rrNo)
{
try
{
var rrno = await _dbContext.RRSeries.FirstOrDefaultAsync(x => x.Id == 1);
if (rrno == null)
throw new Exception("RRSeries record with ID 1 not found.");
rrno.RRNo = rrNo;
await _dbContext.SaveChangesAsync();
isUpdated=true;
}
catch (Exception ex)
{
throw;
}
}
public async Task<RRSeries> PutRRNoSeries(ItemDto itemDto)
{
try
{
var rrno = await _dbContext.RRSeries.FirstOrDefaultAsync(x => x.Id == 1);
rrno.RRNo=itemDto.RRNo;
_dbContext.RRSeries.Update(rrno);
await _dbContext.SaveChangesAsync();
return rrno;
}
catch (Exception)
{
throw;
}
}
#endregion
}
}

View File

@ -0,0 +1,230 @@
using CPRNIMS.Domain.Contracts.SMTP;
using CPRNIMS.Infrastructure.Database;
using CPRNIMS.Infrastructure.Dto.Items;
using CPRNIMS.Infrastructure.Dto.SMTP;
using CPRNIMS.Infrastructure.Entities.Purchasing;
using System.Security.Cryptography;
using CPRNIMS.Infrastructure.Entities.SMTP;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.Services.SMTP
{
public class SMTP : ISMTP
{
private readonly NonInventoryDbContext _dbContext;
public SMTP(NonInventoryDbContext dbContext)
{
_dbContext = dbContext;
}
public async Task<List<SMTPCredential>> GetAllSmtp(SMTPCredentialDto itemDto)
{
try
{
var allItems = await _dbContext.SMTPCredentials
.FromSqlRaw($"EXEC GetAllSmtp @UserId = '{itemDto.UserId}'")
.ToListAsync();
return allItems ?? new List<SMTPCredential>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
private static readonly byte[] Key = GetPaddedKey("MDLD_1NV3NT0RY_2o24", 32);
public async Task<List<SMTPCredential>> GetSMTPCredential(SMTPCredentialDto itemDto)
{
try
{
var allCred = await _dbContext.SMTPCredentials
.FromSqlRaw($"EXEC GetSMTPCredential @UserId = '{itemDto.UserId}', @SMTPTypeId = {itemDto.SMTPTypeId}")
.ToListAsync();
foreach (var cred in allCred)
{
if (IsEncrypted(cred.Password))
{
cred.Password = DecryptString(cred.Password);
}
}
return allCred ?? new List<SMTPCredential>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
// Decrypt string method
private string DecryptString(string cipherText)
{
try
{
byte[] fullCipher = Convert.FromBase64String(cipherText);
byte[] iv = new byte[16];
byte[] cipherTextBytes = new byte[fullCipher.Length - 16];
Array.Copy(fullCipher, iv, iv.Length);
Array.Copy(fullCipher, iv.Length, cipherTextBytes, 0, cipherTextBytes.Length);
using (Aes aesAlg = Aes.Create())
{
aesAlg.Key = Key;
using (ICryptoTransform decryptor = aesAlg.CreateDecryptor(aesAlg.Key, iv))
using (MemoryStream msDecrypt = new MemoryStream(cipherTextBytes))
using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
using (StreamReader srDecrypt = new StreamReader(csDecrypt))
{
return srDecrypt.ReadToEnd();
}
}
}
catch (FormatException)
{
// If it's not a valid base64 string, it means it's already decrypted
return cipherText;
}
}
// Method to check if the password is encrypted
private bool IsEncrypted(string password)
{
try
{
// Try to convert from Base64
Convert.FromBase64String(password);
return true;
}
catch (FormatException)
{
// If it fails, it's not Base64 encoded, hence not encrypted
return false;
}
}
public async Task<List<SMTPCredential>> GetMySmtp(SMTPCredentialDto itemDto)
{
try
{
var allItems = await _dbContext.SMTPCredentials
/* .FromSqlRaw("EXEC GetMySmtp @UserId = {0}", itemDto.UserId, )*/
.FromSqlRaw($"EXEC GetMySmtp @UserId = '{itemDto.UserId}', @SMTPCredentialId = {itemDto.SMTPCredentialId}")
.ToListAsync();
//foreach (var item in allItems)
//{
// item.Password = DecryptString(item.Password);
//}
return allItems ?? new List<SMTPCredential>();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
public async Task<SMTPCredential> GetMySmtpById(SMTPCredentialDto itemDto)
{
try
{
var sMTP = await _dbContext.SMTPCredentials
.FromSqlRaw($"EXEC GetMySmtp @UserId = '{itemDto.UserId}', @SMTPCredentialId = {itemDto.SMTPCredentialId}")
.ToListAsync();
if (sMTP.Count == 0)
{
return null; // No item found
}
var item = sMTP.First();
item.Password = DecryptString(item.Password);
return item;
}
catch (SqlException ex)
{
var message = ex.ToString();
throw;
}
}
public async Task<SMTPCredential> PostPutSmtp(SMTPCredentialDto itemDto)
{
try
{
// Encrypt the password
string encryptedPassword = EncryptString(itemDto.Password);
await _dbContext.Database
.ExecuteSqlRawAsync("EXEC PostPutSmtp " +
"@SMTPCredentialId, @SMTPCredentialName, @UserId, @SenderEmail, @SenderUserName," +
" @SenderDisplayName, @Password, @Server, @OutgoingPort, @IncomingPort ,@IsActive",
new SqlParameter("@SMTPCredentialId", itemDto.SMTPCredentialId != null ? itemDto.SMTPCredentialId : 0L),
//new SqlParameter("@SMTPTypeId", itemDto.SMTPTypeId),
new SqlParameter("@SMTPCredentialName", itemDto.SMTPCredentialName ?? "N/A"),
new SqlParameter("@UserId", itemDto.UserId),
new SqlParameter("@SenderEmail", itemDto.SenderEmail ?? "N/A"),
new SqlParameter("@SenderUserName", itemDto.SenderUserName ?? "N/A"),
new SqlParameter("@SenderDisplayName", itemDto.SenderDisplayName ?? "N/A"),
new SqlParameter("@Password", encryptedPassword),
new SqlParameter("@Server", itemDto.Server ?? "N/A"),
new SqlParameter("@OutgoingPort", itemDto.OutgoingPort),
new SqlParameter("@IncomingPort", itemDto.IncomingPort),
new SqlParameter("@IsActive", itemDto.IsActive));
return new SMTPCredential();
}
catch (SqlException ex)
{
ex.ToString();
throw;
}
}
private static byte[] GetPaddedKey(string key, int length)
{
var keyBytes = Encoding.UTF8.GetBytes(key);
if (keyBytes.Length >= length)
{
return keyBytes.Take(length).ToArray();
}
var paddedKey = new byte[length];
Buffer.BlockCopy(keyBytes, 0, paddedKey, 0, keyBytes.Length);
return paddedKey;
}
// Encrypt string
private string EncryptString(string plainText)
{
using (Aes aesAlg = Aes.Create())
{
aesAlg.Key = Key;
aesAlg.GenerateIV();
byte[] iv = aesAlg.IV;
using (ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, iv))
using (MemoryStream msEncrypt = new MemoryStream())
{
// Prepend the IV to the encrypted content
msEncrypt.Write(iv, 0, iv.Length);
using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
using (StreamWriter swEncrypt = new StreamWriter(csEncrypt))
{
swEncrypt.Write(plainText);
}
return Convert.ToBase64String(msEncrypt.ToArray());
}
}
}
}
}

View File

@ -0,0 +1,30 @@
using CPRNIMS.Infrastructure.Models.Account;
using CPRNIMS.Infrastructure.ViewModel.Account;
using CPRNIMS.Infrastructure.ViewModel.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIContracts.Account
{
public interface IAccount
{
Task<RegisterVM> CreateUserAsync(RegisterVM registerModel, User user);
Task<UserRoleVM> CreateUpdateRole(UserRoleVM UserRoleVM, User user);
Task<UpdateUserVM> UpdateUserProfile(UpdateUserVM viewModel, User user);
Task<RegisterVM> DisableUserAsync(RegisterVM registerModel);
Task<List<RegisterVM>> GetAllUserAsync(User user);
Task<List<UserRoleVM>> GetAllRoleAsync(User user);//
Task<List<ControllerAccessVM>> GetLandingPageByUserId(User user);
Task<List<string>> GetRoles(User user);
Task<List<RegisterVM>> GetUserProfileById(User user);
Task<EmailMessageDetailsVM> GetUserByEmail(string email, EmailMessageDetailsVM forgotPassword);
Task<EmailMessageDetailsVM> ValidateOTP(EmailMessageDetailsVM forgotPassword);
Task<EmailMessageDetailsVM> ChangePassword(EmailMessageDetailsVM viewModel);
Task<List<UserRightsVM>> GetUserRights(User user, UserRightsVM viewModels);
Task<List<UserRightsVM>> GetDepartment(User user, UserRightsVM viewModels);
Task<UserRightsVM> PutPostUserAccess(User user, UserRightsVM viewModel);
}
}

View File

@ -0,0 +1,20 @@
using CPRNIMS.Infrastructure.Dto.Attachement;
using CPRNIMS.Infrastructure.Models.Account;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIContracts.Attachment
{
public interface IAttachment
{
Task<Infrastructure.Entities.Account.Attachment> CreateUpdateAttachment
(Infrastructure.Entities.Account.Attachment attachment);
Task<string> GetAttachmentById(User user);
Task<string> GetAllAttachment(User user);
Task<List<AttachResponseDto>> GetAttachmentByType(User user, int fileType);
Task DeleteSignatureAsync(int id);
}
}

View File

@ -0,0 +1,46 @@
using CPRNIMS.Infrastructure.Models.Account;
using CPRNIMS.Infrastructure.ViewModel.Canvass;
using CPRNIMS.Infrastructure.ViewModel.PR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIContracts.Canvass
{
public interface ICanvass
{
Task<List<CanvassVM>> GetSupplierBid(User user, CanvassVM viewModel);
Task<List<CanvassVM>> GetSupplierBidByItem(User user, CanvassVM viewModel);
Task<List<CanvassVM>> GetSupplierBidById(User user, CanvassVM viewModel);
Task<List<CanvassVM>> GetCanvassPerSupplier(User user, CanvassVM viewModel);
Task<List<CanvassVM>> GetCanvassPerSupplierEmail(User user, CanvassVM viewModel);
Task<List<CanvassVM>> GetItemSupplierWOEmail(User user, CanvassVM viewModel);
Task<List<CanvassVM>> GetSupplierItemWOEmail(User user, CanvassVM viewModel);
Task<List<CanvassVM>> GetPRItemList(User user, CanvassVM viewModel);
Task<List<CanvassVM>> GetPRItem(User user, CanvassVM viewModel);
Task<List<CanvassVM>> GetCanvassWOResponse(User user, CanvassVM viewModel);
Task<List<CanvassVM>> GetWOResponseBySuppId(User user, CanvassVM viewModel);
Task<List<CanvassVM>> GetSupplierById(User user, CanvassVM viewModel);
Task<List<CanvassVM>> GetCanvassById(User user, CanvassVM viewModel);
Task<List<CanvassVM>> GetCanvassByPRNo(User user, CanvassVM viewModel);
Task<List<CanvassVM>> GetForCanvassPerItem(User user, CanvassVM viewModels);
Task<List<CanvassVM>?> GetPRListByPRNo(User user, CanvassVM viewModel);
Task<List<CanvassVM>?> GetMySuppliers(User user, CanvassVM viewModel);
Task<List<CanvassVM>?> GetMyPRWOCanvass(User user, CanvassVM viewModel);
Task<List<CanvassVM>?> GetCanvassPerSupplierId(User user, CanvassVM viewModel);
Task<List<CanvassVM>?> GetCanvassGroupByPRNo(User user, CanvassVM viewModel);
Task<List<CanvassVM>?> GetAlternativeOfferByPRDetailId(User user, CanvassVM viewModels);
Task<CanvassVM> PostCanvass(User user, CanvassVM viewModel);
Task<CanvassVM> PostPutSupplier(User user, CanvassVM viewModel);
Task<CanvassVM> PostTaggingSupplier(User user, CanvassVM viewModel);
Task<CanvassVM> PostApprovedSupp(User user, CanvassVM viewModel);
Task<CanvassVM> PostSuggestedSupp(User user, CanvassVM viewModel);
Task<CanvassVM> PutSuppUnitPrice(User user, CanvassVM viewModel);
Task<CanvassVM> PutSuppBidDetails(User user, CanvassVM viewModel);
Task<CanvassVM> PostPutMySupplier(User user, CanvassVM viewModel);
Task<CanvassVM> PostPutItemTagging(User user, CanvassVM viewModel);
Task<CanvassVM> UnlockFormLink(User user, CanvassVM viewModel);
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIContracts.CaptCha
{
public interface ICaptchaService
{
(string code, byte[] image) GenerateCaptcha();
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIContracts.Common
{
public interface IApiConfigurationService
{
string BaseUrl { get; }
Dictionary<string, string> DefaultHeaders { get; }
HttpClient CreateHttpClientWithDefaultHeaders(string token);
}
}

View File

@ -0,0 +1,17 @@
using CPRNIMS.Infrastructure.Models.Account;
using CPRNIMS.Infrastructure.ViewModel.Finance;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIContracts.Finance
{
public interface IRR
{
Task<List<RRVM>> GetAllClosedPO(User user, RRVM viewModel);
Task<List<RRVM>> GetRRDetailByPO(User user, RRVM viewModel);
Task<RRVM> PostPutPayment(User user, RRVM viewModel);
}
}

View File

@ -0,0 +1,25 @@
using CPRNIMS.Infrastructure.Dto.Inventory;
using CPRNIMS.Infrastructure.Models.Account;
using CPRNIMS.Infrastructure.ViewModel.Inventory;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIContracts.Inventory
{
public interface IInventory
{
Task<List<InventoryVM>> GetInventoryByUserId(User user, InventoryVM viewModel);
Task<List<InventoryVM>> GetRequestedItemByUserId(User user, InventoryVM viewModel);
Task<List<InventoryVM>> GetInventoryById(User user, InventoryVM viewModel);
Task<List<InventoryVM>> GetLotNo(User user, InventoryVM viewModel);
Task<List<InventoryVM>> GetLotQtyByItem(User user, InventoryVM viewModel);
Task<List<InventoryVM>> GetLotNoById(User user, InventoryVM viewModel);
Task<InventoryVM> PostPutLotNo(User user, InventoryVM viewModel);
Task<InventoryVM> PostPutLotBin(User user, InventoryVM viewModel);
Task<InventoryVM> PostPutReqApproval(User user, InventoryVM viewModel);
Task<InventoryVM> PostPutReqItems(User user, InventoryVM viewModel);
}
}

View File

@ -0,0 +1,29 @@
using CPRNIMS.Infrastructure.Dto.Items;
using CPRNIMS.Infrastructure.Entities.Items;
using CPRNIMS.Infrastructure.Models.Account;
using CPRNIMS.Infrastructure.ViewModel.Items;
using System;
using System.Collections.Generic;
using System.Diagnostics.Metrics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIContracts.Items
{
public interface IItem
{
Task<List<ItemVM>> GetItemList(User user, ItemVM viewModel);
Task<List<ItemVM>> GetItemDetail(User user, ItemVM viewModel);
Task<List<ItemVM>> GetItemCateg(User user, ItemVM viewModel);
Task<List<ItemVM>> GetItemLocalization(User userd, ItemVM viewModel);
Task<List<ItemVM>> GetItemColor(User user, ItemVM viewModel);
Task<List<ItemVM>> GetItemUOM(User user, ItemVM viewModel);
Task<List<ItemVM>> GetDepartment(User user, ItemVM viewModel);
Task<List<ItemVM>> GetItemCart(User user, ItemVM viewModel);
Task<ItemVM> PostPurchRequest(User user, ItemVM viewModel);
Task<ItemVM> PostPutItem(User user, ItemVM viewModel);
Task<ItemVM> PutItemDetail(User user, ItemVM viewModel);
Task<ItemVM> PostPutItemCart(User user, ItemVM viewModel);
}
}

View File

@ -0,0 +1,62 @@
using CPRNIMS.Infrastructure.Models.Account;
using CPRNIMS.Infrastructure.ViewModel.PO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIContracts.PO
{
public interface IPurchaseOrder
{
#region Get
Task<List<POVM>> GetSupplierBidById(User user, POVM viewModel);
Task<List<POVM>> GetSupplierBidByItem(User user, POVM viewModel);
Task<List<POVM>> GetSupplierBid(User user, POVM viewModel);
Task<List<POVM>> GetForPOApprovalByPRNo(User user, POVM viewModel);
Task<List<POVM>> GetForPO(User user, POVM viewModel);
Task<List<POVM>> GetForPOPerSuppEmail(User user, POVM viewModel);
Task<List<POVM>> GetApprovedPO(User user, POVM viewModel);
Task<List<POVM>> GetApprovedPOPerEmail(User user, POVM viewModel);
Task<List<POVM>> GetForBiddingApproval(User user, POVM viewModel);
Task<List<POVM>> GetForPOApproval(User user, POVM viewModel);
Task<List<POVM>?> GetPaymentTerms(User user, POVM viewModels);
Task<List<POVM>?> GetLatestPO(User user, POVM viewModels);
Task<List<POVM>?> GetLatestPO2(User user, POVM viewModels);
Task<List<POVM>?> GetDocRequired(User user, POVM viewModels);
Task<List<POVM>?> GetOtherCharges(User user, POVM viewModels);
Task<List<POVM>?> GetSuppliers(User user, POVM viewModels);
Task<List<POVM>?> GetPRWOCanvass(User user, POVM viewModels);
Task<List<POVM>?> GetCreatedPO(User user, POVM viewModels);
Task<List<POVM>?> GetMyCreatedPO(User user, POVM viewModels);
Task<List<POVM>?> GetCreatedPOPerSupId(User user, POVM viewModels);
Task<List<POVM>?> GetPRItemDetail(User user, POVM viewModels);
Task<List<POVM>?> GetPODetailBySuppierId(User user, POVM viewModels);
Task<List<POVM>?> GetPOItemDetail(User user, POVM viewModels);
Task<List<POVM>?> GetIncoterms(User user, POVM viewModels);
Task<List<POVM>?> GetPRPOSummaryReport(User user, POVM viewModels);
Task<List<POVM>?> GetPRPOSummaryItem(User user, POVM viewModels);
Task<List<POVM>?> GetIndexCard(User user, POVM viewModel);
Task<List<POVM>?> GetPortOfDischarge(User user, POVM viewModels);
Task<List<POVM>?> GetIncomingShipment(User user, POVM viewModels);
#endregion
#region Post Put
Task<POVM> PostApprovedSupplier(User user, POVM viewModel);
Task<POVM> PostApprovedSuggested(User user, POVM viewModel);
Task<POVM> PostApprovedPO(User user, POVM viewModel);
Task<POVM> PostPutPO(User user, POVM viewModel);
Task<POVM> PostPOToSupplier(User user, POVM viewModel);
Task<POVM> PostPutCustomPO(User user, POVM viewModel);
Task<POVM> PutPRItemDetails(User user, POVM viewModel);
Task<POVM> PutMyPONo(User user, POVM viewModel);
Task<POVM> PutPOItemDetail(User user, POVM viewModel);
Task<POVM> ApprovedSelectedPO(User user, POVM viewModel);
Task<POVM> PostPutDocRequired(User user, POVM viewModel);
Task<POVM> PutPOCancel(User user, POVM viewModel);
Task<POVM> PostPutOtherCharges(User user, POVM viewModel);
Task<POVM> PostPutIncoterms(User user, POVM viewModel);
Task<POVM> DeleteIncShip(User user, POVM viewModel);
#endregion
}
}

View File

@ -0,0 +1,40 @@
using CPRNIMS.Infrastructure.Dto.Items;
using CPRNIMS.Infrastructure.Models.Account;
using CPRNIMS.Infrastructure.ViewModel.Items;
using CPRNIMS.Infrastructure.ViewModel.PR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIContracts.PR
{
public interface IPRequest
{
Task<List<PRVM>?> GetApproverName(User user, PRVM viewModels);
Task<List<PRVM>> GetForReceiving(User user, PRVM viewModel);
Task<List<PRVM>> GetItemDetailForReceiving(User user, PRVM viewModel);
Task<List<PRVM>> GetDashBoard(User user, PRVM viewModel);
Task<List<PRVM>> GetPRByRRId(User user, PRVM viewModel);
Task<List<PRVM>> GetRRDetailByPO(User user, PRVM viewModel);
Task<List<PRVM>> GetPRStatusById(User user, PRVM viewModel);
Task<List<PRVM>> GetAllPR(User user, PRVM viewModel);
Task<List<PRVM>> GetPRArchived(User user, PRVM viewModel);
Task<List<PRVM>> GetMyPR(User user, PRVM viewModel);
Task<List<PRVM>> GetPRDetailByPRNo(User user, PRVM viewModel);
Task<List<PRVM>?> GetPRListByPRNo(User user, PRVM viewModels);
Task<List<PRVM>?> GetDetailedPRTracking(User user, PRVM viewModel);
Task<List<PRVM>?> GetSupplierAlternativeOffer(User user, PRVM viewModel);
Task<List<PRVM>?> GetSupplierAlterOfferDetails(User user, PRVM viewModel);
Task<PRVM> PostPRApproveReject(User user, PRVM viewModel);
Task<PRVM> PostPutItemReceiving(User user, PRVM viewModel);
Task<PRVM> PutItemDetail(User user, PRVM viewModel);
Task<PRVM> PostPutReceiving(User user, PRVM viewModel);
Task<PRVM> PutPOClose(User user, PRVM viewModel);
Task<PRVM> PostPutDeniedItem(User user, PRVM viewModel);
Task<PRVM> PutAlternativeOffer(User user, PRVM viewModel);
Task<PRVM> PutSupplierAlterOffer(User user, PRVM viewModel);
Task<PRVM> PRItemRemoval(User user, PRVM viewModel);
}
}

View File

@ -0,0 +1,29 @@
using CPRNIMS.Infrastructure.Models.Account;
using CPRNIMS.Infrastructure.ViewModel.Receiving;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIContracts.Receiving
{
public interface IReceiving
{
#region Get
Task<List<ReceivingVM>> GetForReceiving(User user, ReceivingVM viewModel);
Task<List<ReceivingVM>> GetPRDetailByPRNo(User user, ReceivingVM viewModel);
Task<List<ReceivingVM>> GetRRDetailByPO(User user, ReceivingVM viewModel);
Task<List<ReceivingVM>?> GetLatestRRNo(User user, ReceivingVM viewModel);
Task<List<ReceivingVM>?> GetRR(User user, ReceivingVM viewModel);
Task<List<ReceivingVM>?> GetRRDetail(User user, ReceivingVM viewModel);
Task<List<ReceivingVM>?> GetRRReport(User user, ReceivingVM viewModels);
#endregion
#region POST PUT
Task<ReceivingVM> PutRRNoSeries(User user, ReceivingVM viewModel);
Task<ReceivingVM> PostPutReceiving(User user, ReceivingVM viewModel);
Task<ReceivingVM> PutPOClose(User user, ReceivingVM viewModel);
Task<ReceivingVM> PostPutDeniedItem(User user, ReceivingVM viewModel);
#endregion
}
}

View File

@ -0,0 +1,18 @@
using CPRNIMS.Infrastructure.Models.Account;
using CPRNIMS.Infrastructure.ViewModel.PR;
using CPRNIMS.Infrastructure.ViewModel.SMTP;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIContracts.SMTP
{
public interface ISMTP
{
Task<List<SMTPCredentialVM>> GetAllSmtp(User user, SMTPCredentialVM viewModel);
Task<List<SMTPCredentialVM>> GetMySmtp(User user, SMTPCredentialVM viewModel);
Task<SMTPCredentialVM> PostPutSmtp(User user, SMTPCredentialVM viewModel);
}
}

View File

@ -0,0 +1,560 @@
using CPRNIMS.Domain.UIContracts.Account;
using CPRNIMS.Domain.UIContracts.Common;
using CPRNIMS.Infrastructure.Helper;
using CPRNIMS.Infrastructure.Models.Account;
using CPRNIMS.Infrastructure.Models.Common;
using CPRNIMS.Infrastructure.ViewModel.Account;
using CPRNIMS.Infrastructure.ViewModel.Common;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIServices.Account
{
public class Account : IAccount
{
private readonly IConfiguration _configuration;
private readonly TokenHelper _tokenHelper;
private readonly IApiConfigurationService _apiConfigurationService;
public string BaseUrl => _configuration["CommonEndpoints:ApiDefaultHeaders:BaseUrl"];
public Account(IConfiguration configuration, TokenHelper tokenHelper,
IApiConfigurationService apiConfigurationService)
{
_configuration = configuration;
_tokenHelper = tokenHelper;
_apiConfigurationService = apiConfigurationService;
}
#region SendRequest service
public async Task<UserRightsVM> SendPostApiRequest(User user,
UserRightsVM viewModel, string apiEndpoint)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
try
{
if (string.IsNullOrEmpty(token))
{
// Handle token retrieval failure
return null;
}
viewModel.UserId = viewModel.UserId;
viewModel.AdminUserId = user.UserId;
var jsonContent = JsonSerializer.Serialize(viewModel);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
HttpResponseMessage response;
response = await httpClient.PostAsync(apiEndpoint, content);
var responseObject = JsonSerializer.Deserialize<ResponseObject>(await response.Content.ReadAsStringAsync());
if (response.IsSuccessStatusCode)
{
viewModel.messCode = 1;
viewModel.StatusResponse = responseObject.statusResponse;
return viewModel;
}
else
{
viewModel.errMessage = responseObject.message;
viewModel.messCode = responseObject.messCode;
return viewModel;
}
}
}
catch (Exception ex)
{
ex.ToString();
throw;
}
}
public async Task<List<UserRightsVM>> SendGetApiRequest(User user,
UserRightsVM viewModel,
string apiEndpoint)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
try
{
if (string.IsNullOrEmpty(token))
{
// Handle token retrieval failure
return null;
}
viewModel.UserId = viewModel.UserId;
viewModel.AdminUserId = user.UserId;
var jsonContent = JsonSerializer.Serialize(viewModel);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
HttpResponseMessage response;
response = await httpClient.PostAsync(apiEndpoint, content);
if (response.IsSuccessStatusCode)
{
var jsonResponse = await response.Content.ReadAsStringAsync();
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var myArtWork = JsonSerializer.Deserialize<List<UserRightsVM>>(jsonResponse, options);
return myArtWork;
}
else
{
// Handle API request failure
return null;
}
}
}
catch (Exception ex)
{
throw;
}
}
public async Task<UserRightsVM> PutPostUserAccess(User user, UserRightsVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["Account:PutPostUserAccess"]);
}
public async Task<List<UserRightsVM>> GetDepartment(User user, UserRightsVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["Account:GetDepartment"]);
}
public async Task<List<UserRightsVM>> GetUserRights(User user, UserRightsVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["Account:GetUserRights"]);
}
#endregion
public async Task<EmailMessageDetailsVM> ChangePassword(EmailMessageDetailsVM viewModel)
{
try
{
viewModel.PasswordHash = viewModel.NewPassword;
var jsonContent = JsonSerializer.Serialize(viewModel);
var httpClient = new HttpClient(new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true
})
{
BaseAddress = new Uri(BaseUrl)
};
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
var response = await httpClient.PutAsync(_configuration["Account:ChangePassword"], content);
var responseObject = JsonSerializer.Deserialize<ResponseObject>(await response.Content.ReadAsStringAsync());
if (response.IsSuccessStatusCode)
{
viewModel.messCode = 1;
viewModel.Message = responseObject.message;
viewModel.status = responseObject.statusResponse;
return viewModel;
}
else
{
viewModel.messCode = 0;
viewModel.Message = responseObject.message;
viewModel.status = responseObject.statusResponse;
return viewModel;
}
}
catch (Exception)
{
throw;
}
}
public async Task<EmailMessageDetailsVM> GetUserByEmail(string email, EmailMessageDetailsVM forgotPassword)
{
forgotPassword.Email = email;
var httpClient = new HttpClient(new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true
})
{
BaseAddress = new Uri(BaseUrl)
};
var jsonContent = JsonSerializer.Serialize(forgotPassword);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
var response = await httpClient.PostAsync(_configuration["Account:GetUserByEmail"], content);
var responseObject = JsonSerializer.Deserialize<ResponseObject>(await response.Content.ReadAsStringAsync());
if (response.IsSuccessStatusCode)
{
forgotPassword.messCode = 1;
forgotPassword.status = responseObject.statusResponse;
forgotPassword.Message = responseObject.message;
return forgotPassword;
}
else
{
forgotPassword.messCode = 0;
forgotPassword.status = responseObject.statusResponse;
forgotPassword.Message = responseObject.message;
return forgotPassword;
}
}
public async Task<List<RegisterVM>> GetUserProfileById(User user)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
if (!string.IsNullOrEmpty(token))
{
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
var response = await httpClient.GetAsync(_configuration["Account:GetUserById"] + user.UserId);
if (response.IsSuccessStatusCode)
{
var jsonResponse = await response.Content.ReadAsStringAsync();
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var register = JsonSerializer.Deserialize<List<RegisterVM>>(jsonResponse, options);
return register;
}
else
{
// Handle API request failure
}
}
}
// Handle token retrieval failure
return null;
}
async Task<RegisterVM> IAccount.CreateUserAsync(RegisterVM registerModel, User user)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
if (!string.IsNullOrEmpty(token))
{
registerModel.Id = registerModel.NewUserId;
registerModel.CreatedBy = user.UserName;
registerModel.UpdatedBy = user.UserName;
registerModel.ClaimType = registerModel.Company;
registerModel.ClaimValue = registerModel.Role;
registerModel.CreatedDate = DateTime.Now;
registerModel.UpdatedDate = DateTime.Now;
// Serialize the RegisterVM to JSON
var jsonContent = JsonSerializer.Serialize(registerModel);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
var response = await httpClient.PostAsync(_configuration["Account:RegisterUser"], content);
if (!response.IsSuccessStatusCode)
{
// Deserialize the JSON response
var responseObject = JsonSerializer.Deserialize<ResponseObject>(await response.Content.ReadAsStringAsync());
// Access the message property
registerModel.message = responseObject.message;
registerModel.statusResponse = responseObject.statusResponse;
return registerModel;
}
return registerModel;
}
}
return null;
}
Task<RegisterVM> IAccount.DisableUserAsync(RegisterVM registerModel)
{
throw new NotImplementedException();
}
async Task<List<RegisterVM>> IAccount.GetAllUserAsync(User user)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
if (!string.IsNullOrEmpty(token))
{
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
var response = await httpClient.GetAsync(_configuration["Account:GetAllUsers"]);
if (response.IsSuccessStatusCode)
{
var jsonResponse = await response.Content.ReadAsStringAsync();
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var users = JsonSerializer.Deserialize<List<RegisterVM>>(jsonResponse, options);
return users;
}
else
{
// Handle API request failure
}
}
}
// Handle token retrieval failure
return null;
}
public async Task<EmailMessageDetailsVM> ValidateOTP(EmailMessageDetailsVM forgotPassword)
{
try
{
var httpClient = new HttpClient(new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true
})
{
BaseAddress = new Uri(BaseUrl)
};
var jsonContent = JsonSerializer.Serialize(forgotPassword);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
var response = await httpClient.PostAsync(_configuration["Account:ValidateOTP"], content);
var responseObject = JsonSerializer.Deserialize<ResponseObject>(await response.Content.ReadAsStringAsync());
if (response.IsSuccessStatusCode)
{
forgotPassword.messCode = 1;
forgotPassword.status = responseObject.statusResponse;
forgotPassword.Message = responseObject.message;
return forgotPassword;
}
else
{
forgotPassword.messCode = 0;
forgotPassword.status = responseObject.statusResponse;
forgotPassword.Message = responseObject.message;
return forgotPassword;
}
}
catch (Exception ex)
{
ex.InnerException.ToString();
throw;
}
}
public async Task<List<string>> GetRoles(User user)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
if (!string.IsNullOrEmpty(token))
{
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
var response = await httpClient.GetAsync(_configuration["Account:GetRoles"]);
if (response.IsSuccessStatusCode)
{
var jsonResponse = await response.Content.ReadAsStringAsync();
Console.WriteLine($"Received JSON response: {jsonResponse}");
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var userRoles = JsonSerializer.Deserialize<List<string>>(jsonResponse, options);
return userRoles;
}
else
{
// Handle API request failure
}
}
}
// Handle token retrieval failure
return null;
}
public async Task<UserRoleVM> CreateUpdateRole(UserRoleVM UserRoleVM, User user)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
if (!string.IsNullOrEmpty(token))
{
// Serialize the RegisterVM to JSON
var jsonContent = JsonSerializer.Serialize(UserRoleVM);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
var response = await httpClient.PostAsync(_configuration["Account:CreateUpdateRole"], content);
if (!response.IsSuccessStatusCode)
{
// Deserialize the JSON response
var responseObject = JsonSerializer.Deserialize<ResponseObject>(await response.Content.ReadAsStringAsync());
// Access the message property
UserRoleVM.message = responseObject.message;
UserRoleVM.statusResponse = responseObject.statusResponse;
return UserRoleVM;
}
return UserRoleVM;
}
}
return null;
}
public async Task<List<UserRoleVM>> GetAllRoleAsync(User user)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
if (!string.IsNullOrEmpty(token))
{
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
var response = await httpClient.GetAsync(_configuration["Account:GetAllRoles"]);
if (response.IsSuccessStatusCode)
{
var jsonResponse = await response.Content.ReadAsStringAsync();
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var userRoles = JsonSerializer.Deserialize<List<UserRoleVM>>(jsonResponse, options);
return userRoles;
}
else
{
// Handle API request failure
}
}
}
// Handle token retrieval failure
return null;
}
public async Task<List<ControllerAccessVM>> GetLandingPageByUserId(User user)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
try
{
if (!string.IsNullOrEmpty(token))
{
var jsonContent = JsonSerializer.Serialize(user);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
var response = await httpClient.PostAsync(_configuration["Account:GetLandingPageByUserId"], content);
if (response.IsSuccessStatusCode)
{
var jsonResponse = await response.Content.ReadAsStringAsync();
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var myAccess = JsonSerializer.Deserialize<List<ControllerAccessVM>>(jsonResponse, options);
return myAccess;
}
else
{
// Handle API request failure
}
}
}
// Handle token retrieval failure
return null;
}
catch (Exception ex)
{
ex.ToString();
throw;
}
}
public async Task<List<DepartmentVM>> GetDepartment(User user)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
if (string.IsNullOrEmpty(token))
{
return null;
}
try
{
var jsonContent = JsonSerializer.Serialize(user);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
var response = await httpClient.GetAsync(_configuration["Account:GetDepartment"]);
if (response.IsSuccessStatusCode)
{
var jsonResponse = await response.Content.ReadAsStringAsync();
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var departments = JsonSerializer.Deserialize<List<DepartmentVM>>(jsonResponse, options);
return departments;
}
else
{
// Handle API request failure
return null;
}
}
}
catch (Exception ex)
{
// Log or handle the exception
return null;
}
}
public async Task<UpdateUserVM> UpdateUserProfile(UpdateUserVM viewModel, User user)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
if (!string.IsNullOrEmpty(token))
{
viewModel.UpdatedBy = user.UserName;
viewModel.Id = viewModel.UserId;
viewModel.Password = viewModel.PasswordHash;
var jsonContent = JsonSerializer.Serialize(viewModel);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
var response = await httpClient.PutAsync(_configuration["Account:UpdateUser"], content);
if (!response.IsSuccessStatusCode)
{
// Deserialize the JSON response
var responseObject = JsonSerializer.Deserialize<ResponseObject>(await response.Content.ReadAsStringAsync());
// Access the message property
viewModel.message = responseObject.message;
viewModel.statusResponse = responseObject.statusResponse;
return viewModel;
}
return viewModel;
}
}
return null;
}
}
}

View File

@ -0,0 +1,128 @@
using CPRNIMS.Domain.UIContracts.Attachment;
using CPRNIMS.Domain.UIContracts.Common;
using CPRNIMS.Infrastructure.Dto.Attachement;
using CPRNIMS.Infrastructure.Helper;
using CPRNIMS.Infrastructure.Models.Account;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIServices.Attachment
{
public class Attachment : IAttachment
{
private readonly IConfiguration _configuration;
private readonly TokenHelper _tokenHelper;
private readonly IApiConfigurationService _apiConfigurationService;
public Attachment(IConfiguration configuration, TokenHelper tokenHelper, IApiConfigurationService apiConfigurationService)
{
_configuration = configuration;
_tokenHelper = tokenHelper;
_apiConfigurationService = apiConfigurationService;
}
public async Task<List<AttachResponseDto>> GetAttachmentByType(User user, int fileType)
{
try
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
if (!string.IsNullOrEmpty(token))
{
var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token);
var response = await httpClient.GetAsync($"{_configuration["LLI:Artwork:GetAttachmentByType"]}/{user.UserId}?fileType={fileType}");
if (response.IsSuccessStatusCode)
{
var jsonResponse = await response.Content.ReadAsStringAsync();
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var attachmentDto = JsonSerializer.Deserialize<List<AttachResponseDto>>(jsonResponse, options);
return attachmentDto;
}
}
// Handle token retrieval failure or API call failure
return null;
}
catch (Exception ex)
{
ex.ToString();
throw;
}
}
public async Task<string> GetAllAttachment(User user)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
if (!string.IsNullOrEmpty(token))
{
var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token);
var response = await httpClient.GetAsync(_configuration["LLI:Artwork:GetAttachmentByType"] + user.UserId);
if (response.IsSuccessStatusCode)
{
var jsonResponse = await response.Content.ReadAsStringAsync();
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var attachmentDto = JsonSerializer.Deserialize<AttachResponseDto>(jsonResponse, options);
return attachmentDto.URL;
}
}
// Handle token retrieval failure or API call failure
return null;
}
public Task<Infrastructure.Entities.Account.Attachment> CreateUpdateAttachment(Infrastructure.Entities.Account.Attachment attachment)
{
throw new NotImplementedException();
}
public Task DeleteSignatureAsync(int id)
{
throw new NotImplementedException();
}
public async Task<string> GetAttachmentById(User user)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
if (!string.IsNullOrEmpty(token))
{
var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token);
var response = await httpClient.GetAsync($"api/Attachment/GetAttachmentById/{user.UserId}");
if (response.IsSuccessStatusCode)
{
var jsonResponse = await response.Content.ReadAsStringAsync();
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var attachmentDto = JsonSerializer.Deserialize<AttachResponseDto>(jsonResponse, options);
return attachmentDto.URL;
}
}
// Handle token retrieval failure or API call failure
return null;
}
}
}

View File

@ -0,0 +1,293 @@
using CPRNIMS.Domain.UIContracts.Canvass;
using CPRNIMS.Domain.UIContracts.Common;
using CPRNIMS.Infrastructure.Helper;
using CPRNIMS.Infrastructure.Models.Account;
using CPRNIMS.Infrastructure.Models.Common;
using CPRNIMS.Infrastructure.ViewModel.Canvass;
using CPRNIMS.Infrastructure.ViewModel.PR;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIServices.Canvass
{
public class Canvass : ICanvass
{
private readonly IConfiguration _configuration;
private readonly TokenHelper _tokenHelper;
private readonly IApiConfigurationService _apiConfigurationService;
public Canvass(IConfiguration configuration, TokenHelper tokenHelper,
IApiConfigurationService apiConfigurationService)
{
_configuration = configuration;
_tokenHelper = tokenHelper;
_apiConfigurationService = apiConfigurationService;
}
#region SendRequest service
public async Task<CanvassVM> SendPostApiRequest(User user,
CanvassVM viewModel, string apiEndpoint)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
try
{
if (string.IsNullOrEmpty(token))
{
return null;
}
viewModel.UserId = user.UserId;
viewModel.FullName = user.FullName;
var jsonContent = JsonSerializer.Serialize(viewModel);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
HttpResponseMessage response;
response = await httpClient.PostAsync(apiEndpoint, content);
var responseObject = JsonSerializer.Deserialize<ResponseObject>(await response.Content.ReadAsStringAsync());
if (response.IsSuccessStatusCode)
{
viewModel.messCode =1;
viewModel.StatusResponse = responseObject.statusResponse;
return viewModel;
}
else
{
viewModel.errMessage = responseObject.message;
viewModel.messCode = responseObject.messCode;
return viewModel;
}
}
}
catch (Exception ex)
{
ex.ToString();
throw;
}
}
public async Task<List<CanvassVM>> SendGetApiRequest(User user,
CanvassVM viewModel,
string apiEndpoint)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
try
{
if (string.IsNullOrEmpty(token))
{
// Handle token retrieval failure
return null;
}
viewModel.UserId = user.UserId;
var jsonContent = JsonSerializer.Serialize(viewModel);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
HttpResponseMessage response;
response = await httpClient.PostAsync(apiEndpoint, content);
if (response.IsSuccessStatusCode)
{
var jsonResponse = await response.Content.ReadAsStringAsync();
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var myArtWork = JsonSerializer.Deserialize<List<CanvassVM>>(jsonResponse, options);
if(myArtWork.Count > 0)
{
myArtWork[0].URL = _configuration["CommonEndpoints:ApiDefaultHeaders:ItemImages"];
}
return myArtWork;
}
else
{
// Handle API request failure
return null;
}
}
}
catch (Exception ex)
{
throw;
}
}
#endregion
#region Get
public async Task<List<CanvassVM>> GetSupplierBid(User user, CanvassVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:GetSupplierBid"]);
}
public async Task<List<CanvassVM>> GetSupplierBidByItem(User user, CanvassVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:GetSupplierBidByItem"]);
}
public async Task<List<CanvassVM>> GetCanvassPerSupplier(User user, CanvassVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:GetCanvassPerSupplier"]);
}
public async Task<List<CanvassVM>> GetCanvassPerSupplierEmail(User user, CanvassVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:GetCanvassPerSupplierEmail"]);
}
public async Task<List<CanvassVM>> GetCanvassById(User user, CanvassVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:GetCanvassById"]);
}
public async Task<List<CanvassVM>> GetPRItemList(User user, CanvassVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:GetPRItemList"]);
}
public async Task<List<CanvassVM>> GetPRItem(User user, CanvassVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:GetPRItem"]);
}
public async Task<List<CanvassVM>> GetCanvassWOResponse(User user, CanvassVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:GetCanvassWOResponse"]);
}
public async Task<List<CanvassVM>> GetCanvassByPRNo(User user, CanvassVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:GetCanvassByPRNo"]);
}
public async Task<List<CanvassVM>> GetItemSupplierWOEmail(User user, CanvassVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:GetItemSupplierWOEmail"]);
}
public async Task<List<CanvassVM>> GetSupplierItemWOEmail(User user, CanvassVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:GetSupplierItemWOEmail"]);
}
public async Task<List<CanvassVM>> GetSupplierById(User user, CanvassVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:GetSupplierById"]);
}
public async Task<List<CanvassVM>> GetSupplierBidById(User user, CanvassVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:GetSupplierBidById"]);
}
public async Task<List<CanvassVM>> GetWOResponseBySuppId(User user, CanvassVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:GetWOResponseBySuppId"]);
}
public async Task<List<CanvassVM>> GetForCanvassPerItem(User user, CanvassVM viewModels)
{
return await SendGetApiRequest(user, viewModels,
_configuration["LLI:NonInvent:CanvassMgmt:GetForCanvassPerItem"]);
}
public async Task<List<CanvassVM>?> GetPRListByPRNo(User user, CanvassVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:GetPRListByPRNo"]);
}
public async Task<List<CanvassVM>?> GetMySuppliers(User user, CanvassVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:GetMySuppliers"]);
}
public async Task<List<CanvassVM>?> GetMyPRWOCanvass(User user, CanvassVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:GetMyPRWOCanvass"]);
}
public async Task<List<CanvassVM>?> GetCanvassPerSupplierId(User user, CanvassVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:GetCanvassPerSupplierId"]);
}
public async Task<List<CanvassVM>?> GetCanvassGroupByPRNo(User user, CanvassVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:GetCanvassGroupByPRNo"]);
}
public async Task<List<CanvassVM>?> GetIndexCard(User user, CanvassVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:GetIndexCard"]);
}
public async Task<List<CanvassVM>?> GetAlternativeOfferByPRDetailId(User user, CanvassVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:GetAlternativeOfferByPRDetailId"]);
}
#endregion
#region Post Put
public async Task<CanvassVM> PostCanvass(User user, CanvassVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:PostCanvass"]);
}
public async Task<CanvassVM> PostPutSupplier(User user, CanvassVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:PostPutSupplier"]);
}
public async Task<CanvassVM> PostApprovedSupp(User user, CanvassVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:PostApprovedSupp"]);
}
public async Task<CanvassVM> PostSuggestedSupp(User user, CanvassVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:PostSuggestedSupp"]);
}
public async Task<CanvassVM> PostTaggingSupplier(User user, CanvassVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:PostTaggingSupplier"]);
}
public async Task<CanvassVM> PutSuppUnitPrice(User user, CanvassVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:PutSuppUnitPrice"]);
}
public async Task<CanvassVM> PutSuppBidDetails(User user, CanvassVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:PutSuppBidDetails"]);
}
public async Task<CanvassVM> PostPutMySupplier(User user, CanvassVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:PostPutMySupplier"]);
}
public async Task<CanvassVM> PostPutItemTagging(User user, CanvassVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:PostPutItemTagging"]);
}
public async Task<CanvassVM> UnlockFormLink(User user, CanvassVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:UnlockFormLink"]);
}
#endregion
}
}

View File

@ -0,0 +1,78 @@
using CPRNIMS.Domain.UIContracts.CaptCha;
using System;
using System.Collections.Generic;
using System.Drawing.Imaging;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIServices.CaptCha
{
public class CaptchaService : ICaptchaService
{
private readonly Random _random = new Random();
public (string code, byte[] image) GenerateCaptcha()
{
// Generate random code
string captchaCode = GenerateRandomCode();
// Create image from code
using (var bitmap = new Bitmap(150, 50))
using (var graphics = Graphics.FromImage(bitmap))
using (var memoryStream = new MemoryStream())
{
graphics.Clear(Color.White);
// Add noise and pattern
AddNoise(graphics, bitmap.Width, bitmap.Height);
// Draw the text
using (var font = new Font("Arial", 20, FontStyle.Bold))
{
graphics.DrawString(captchaCode, font, Brushes.Black, 10, 10);
}
// Add some random lines for more security
AddRandomLines(graphics, bitmap.Width, bitmap.Height);
// Save to memory stream as PNG
bitmap.Save(memoryStream, ImageFormat.Png);
return (captchaCode, memoryStream.ToArray());
}
}
private string GenerateRandomCode()
{
// Generate a code of 6 characters (letters and numbers)
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return new string(Enumerable.Repeat(chars, 6)
.Select(s => s[_random.Next(s.Length)]).ToArray());
}
private void AddNoise(Graphics graphics, int width, int height)
{
// Add random pixels
for (int i = 0; i < 50; i++)
{
int x = _random.Next(width);
int y = _random.Next(height);
graphics.DrawRectangle(Pens.LightGray, x, y, 1, 1);
}
}
private void AddRandomLines(Graphics graphics, int width, int height)
{
// Add random lines
for (int i = 0; i < 5; i++)
{
int x1 = _random.Next(width);
int y1 = _random.Next(height);
int x2 = _random.Next(width);
int y2 = _random.Next(height);
graphics.DrawLine(Pens.Gray, x1, y1, x2, y2);
}
}
}
}

View File

@ -0,0 +1,83 @@
using CPRNIMS.Domain.UIContracts.Common;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIServices.Common
{
public class ApiConfigurationService : IApiConfigurationService
{
private readonly IConfiguration _configuration;
public string BaseUrl => _configuration["CommonEndpoints:ApiDefaultHeaders:BaseUrl"];
public ApiConfigurationService(IConfiguration configuration)
{
_configuration = configuration;
}
public HttpClient CreateHttpClientWithDefaultHeaders(string token)
{
if (_configuration == null)
{
throw new InvalidOperationException("_apiConfigurationService is not configured.");
}
if (string.IsNullOrEmpty(BaseUrl))
{
throw new InvalidOperationException("BaseUrl is not configured.");
}
var httpClient = new HttpClient(new HttpClientHandler
{
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true
})
{
BaseAddress = new Uri(BaseUrl)
};
var defaultHeaders = DefaultHeaders;
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var customHeaders = CustomHeaders;
foreach (var header in customHeaders)
{
httpClient.DefaultRequestHeaders.Add(header.Key, header.Value);
}
return httpClient;
}
public Dictionary<string, string> DefaultHeaders
{
get
{
var headersSection = _configuration.GetSection("CommonEndpoints:ApiDefaultHeaders");
var headers = new Dictionary<string, string>();
foreach (var childSection in headersSection.GetChildren())
{
headers[childSection.Key] = childSection.Value;
}
return headers;
}
}
public Dictionary<string, string> CustomHeaders
{
get
{
var headersSection = _configuration.GetSection("CommonEndpoints:CustomApiHeaders");
var headers = new Dictionary<string, string>();
foreach (var childSection in headersSection.GetChildren())
{
headers[childSection.Key] = childSection.Value;
}
return headers;
}
}
}
}

View File

@ -0,0 +1,144 @@
using CPRNIMS.Domain.UIContracts.Common;
using CPRNIMS.Domain.UIContracts.Finance;
using CPRNIMS.Infrastructure.Helper;
using CPRNIMS.Infrastructure.Models.Account;
using CPRNIMS.Infrastructure.Models.Common;
using CPRNIMS.Infrastructure.ViewModel.Finance;
using CPRNIMS.Infrastructure.ViewModel.PR;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIServices.Finance
{
public class RR : IRR
{
private readonly IConfiguration _configuration;
private readonly TokenHelper _tokenHelper;
private readonly IApiConfigurationService _apiConfigurationService;
public RR(IConfiguration configuration, TokenHelper tokenHelper,
IApiConfigurationService apiConfigurationService)
{
_configuration = configuration;
_tokenHelper = tokenHelper;
_apiConfigurationService = apiConfigurationService;
}
#region SendRequest service
public async Task<RRVM> SendPostApiRequest(User user,
RRVM viewModel, string apiEndpoint)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
try
{
if (string.IsNullOrEmpty(token))
{
// Handle token retrieval failure
return null;
}
viewModel.UserId = user.UserId;
var jsonContent = JsonSerializer.Serialize(viewModel);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
HttpResponseMessage response;
response = await httpClient.PostAsync(apiEndpoint, content);
if (response.IsSuccessStatusCode)
{
var responseObject = JsonSerializer.Deserialize<ResponseObject>(await response.Content.ReadAsStringAsync());
viewModel.Message = responseObject.message;
viewModel.StatusResponse = responseObject.statusResponse;
return viewModel;
}
else
{
// Handle API request failure
return null;
}
}
}
catch (Exception ex)
{
ex.ToString();
throw;
}
}
public async Task<List<RRVM>> SendGetApiRequest(User user,
RRVM viewModel,
string apiEndpoint)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
try
{
if (string.IsNullOrEmpty(token))
{
// Handle token retrieval failure
return null;
}
viewModel.UserId = user.UserId;
var jsonContent = JsonSerializer.Serialize(viewModel);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
HttpResponseMessage response;
response = await httpClient.PostAsync(apiEndpoint, content);
if (response.IsSuccessStatusCode)
{
var jsonResponse = await response.Content.ReadAsStringAsync();
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var myArtWork = JsonSerializer.Deserialize<List<RRVM>>(jsonResponse, options);
return myArtWork;
}
else
{
// Handle API request failure
return null;
}
}
}
catch (Exception ex)
{
throw;
}
}
#endregion
#region Get
public async Task<List<RRVM>> GetAllClosedPO(User user, RRVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:RRMgmt:GetAllClosedPO"]);
}
public async Task<List<RRVM>> GetRRDetailByPO(User user, RRVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:RRMgmt:GetRRDetailByPO"]);
}
#endregion
#region Post Put
public async Task<RRVM> PostPutPayment(User user, RRVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:RRMgmt:PostPutPayment"]);
}
#endregion
}
}

View File

@ -0,0 +1,188 @@
using CPRNIMS.Domain.UIContracts.Common;
using CPRNIMS.Domain.UIContracts.Inventory;
using CPRNIMS.Infrastructure.Helper;
using CPRNIMS.Infrastructure.Models.Account;
using CPRNIMS.Infrastructure.Models.Common;
using CPRNIMS.Infrastructure.ViewModel.Finance;
using CPRNIMS.Infrastructure.ViewModel.Inventory;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIServices.Inventory
{
public class Inventory : IInventory
{
private readonly IConfiguration _configuration;
private readonly TokenHelper _tokenHelper;
private readonly IApiConfigurationService _apiConfigurationService;
public Inventory(IConfiguration configuration, TokenHelper tokenHelper,
IApiConfigurationService apiConfigurationService)
{
_configuration = configuration;
_tokenHelper = tokenHelper;
_apiConfigurationService = apiConfigurationService;
}
#region SendRequest service
public async Task<InventoryVM> SendPostApiRequest(User user,
InventoryVM viewModel, string apiEndpoint)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
try
{
if (string.IsNullOrEmpty(token))
{
// Handle token retrieval failure
return null;
}
viewModel.UserId = user.UserId;
var jsonContent = JsonSerializer.Serialize(viewModel);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
HttpResponseMessage response;
response = await httpClient.PostAsync(apiEndpoint, content);
if (response.IsSuccessStatusCode)
{
var responseObject = JsonSerializer.Deserialize<ResponseObject>(await response.Content.ReadAsStringAsync());
viewModel.Message = responseObject.message;
viewModel.StatusResponse = responseObject.statusResponse;
return viewModel;
}
else
{
// Handle API request failure
return null;
}
}
}
catch (Exception ex)
{
ex.ToString();
throw;
}
}
public async Task<List<InventoryVM>> SendGetApiRequest(User user,
InventoryVM viewModel,
string apiEndpoint)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
try
{
if (string.IsNullOrEmpty(token))
{
// Handle token retrieval failure
return null;
}
viewModel.UserId = user.UserId;
var jsonContent = JsonSerializer.Serialize(viewModel);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
HttpResponseMessage response;
response = await httpClient.PostAsync(apiEndpoint, content);
if (response.IsSuccessStatusCode)
{
var jsonResponse = await response.Content.ReadAsStringAsync();
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var myInventory = JsonSerializer.Deserialize<List<InventoryVM>>(jsonResponse, options);
if (myInventory.Count > 0)
{
myInventory[0].URL = _configuration["CommonEndpoints:ApiDefaultHeaders:ItemImages"];
}
return myInventory;
}
else
{
// Handle API request failure
return null;
}
}
}
catch (Exception ex)
{
throw;
}
}
#endregion
#region Get
public async Task<List<InventoryVM>> GetInventoryById(User user, InventoryVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:InventoryMgmt:GetInventoryById"]);
}
public async Task<List<InventoryVM>> GetLotNo(User user, InventoryVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:InventoryMgmt:GetLotNo"]);
}
public async Task<List<InventoryVM>> GetLotNoById(User user, InventoryVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:InventoryMgmt:GetLotNoById"]);
}
public async Task<List<InventoryVM>> GetInventoryByUserId(User user, InventoryVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:InventoryMgmt:GetInventoryByUserId"]);
}
public async Task<List<InventoryVM>> GetRequestedItemByUserId(User user, InventoryVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:InventoryMgmt:GetRequestedItemByUserId"]);
}
#endregion
#region Post Put
public async Task<InventoryVM> PostPutReqApproval(User user, InventoryVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:InventoryMgmt:PostPutReqApproval"]);
}
public async Task<InventoryVM> PostPutLotNo(User user, InventoryVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:InventoryMgmt:PostPutLotNo"]);
}
public async Task<InventoryVM> PostPutLotBin(User user, InventoryVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:InventoryMgmt:PostPutLotBin"]);
}
public async Task<InventoryVM> PostPutReqItems(User user, InventoryVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:InventoryMgmt:PostPutReqItems"]);
}
public async Task<List<InventoryVM>> GetLotQtyByItem(User user, InventoryVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:InventoryMgmt:GetLotQtyByItem"]);
}
#endregion
}
}

View File

@ -0,0 +1,207 @@
using CPRNIMS.Domain.UIContracts.Common;
using CPRNIMS.Domain.UIContracts.Items;
using CPRNIMS.Infrastructure.Helper;
using CPRNIMS.Infrastructure.Models.Account;
using CPRNIMS.Infrastructure.Models.Common;
using CPRNIMS.Infrastructure.ViewModel.Items;
using Google.Apis.Drive.v3.Data;
using Microsoft.AspNet.Identity;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using static Google.Apis.Requests.BatchRequest;
namespace CPRNIMS.Domain.UIServices.Items
{
public class Item : IItem
{
private readonly IConfiguration _configuration;
private readonly TokenHelper _tokenHelper;
private readonly IApiConfigurationService _apiConfigurationService;
public Item(IConfiguration configuration, TokenHelper tokenHelper,
IApiConfigurationService apiConfigurationService)
{
_configuration = configuration;
_tokenHelper = tokenHelper;
_apiConfigurationService = apiConfigurationService;
}
#region SendRequest service
public async Task<ItemVM> SendPostApiRequest(Infrastructure.Models.Account.User user,
ItemVM viewModel, string apiEndpoint)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
try
{
if (string.IsNullOrEmpty(token))
{
// Handle token retrieval failure
return null;
}
viewModel.UserId = user.UserId;
var jsonContent = JsonSerializer.Serialize(viewModel);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
HttpResponseMessage response;
response = await httpClient.PostAsync(apiEndpoint, content);
var responseObject = JsonSerializer.Deserialize<ResponseObject>(await response.Content.ReadAsStringAsync());
if (response.IsSuccessStatusCode)
{
viewModel.message = responseObject.message;
viewModel.messCode =1;
viewModel.ItemCodeId= responseObject.itemCode;
return viewModel;
}
else
{
viewModel.message = responseObject.message;
viewModel.messCode = 0;
return viewModel;
}
}
}
catch (Exception ex)
{
ex.ToString();
throw;
}
}
public async Task<List<ItemVM>> SendGetApiRequest(Infrastructure.Models.Account.User user,
ItemVM viewModel,
string apiEndpoint)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
try
{
if (string.IsNullOrEmpty(token))
{
// Handle token retrieval failure
return null;
}
viewModel.UserId = user.UserId;
var jsonContent = JsonSerializer.Serialize(viewModel);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
HttpResponseMessage response;
response = await httpClient.PostAsync(apiEndpoint, content);
var jsonResponse = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode)
{
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
viewModel.messCode = 1;
var myArtWork = JsonSerializer.Deserialize<List<ItemVM>>(jsonResponse, options);
return myArtWork;
}
else
{
var myArtWork = JsonSerializer.Deserialize<List<ItemVM>>(jsonResponse);
viewModel.messCode = 0;
viewModel.message = myArtWork[0].message;
return myArtWork;
}
}
}
catch (Exception ex)
{
throw;
}
}
#endregion
#region Get Method
public async Task<List<ItemVM>> GetItemDetail(Infrastructure.Models.Account.User user,
ItemVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:ItemMgmt:GetItemDetail"]);
}
public async Task<List<ItemVM>> GetItemCart(Infrastructure.Models.Account.User user, ItemVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:ItemMgmt:GetItemCart"]);
}
public async Task<List<ItemVM>> GetItemList(Infrastructure.Models.Account.User user,
ItemVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:ItemMgmt:GetItemList"]);
}
public async Task<List<ItemVM>> GetItemCateg(Infrastructure.Models.Account.User user, ItemVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:ItemMgmt:GetItemCateg"]);
}
public async Task<List<ItemVM>> GetItemColor(Infrastructure.Models.Account.User user, ItemVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:ItemMgmt:GetItemColor"]);
}
public async Task<List<ItemVM>> GetItemUOM(Infrastructure.Models.Account.User user, ItemVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:ItemMgmt:GetItemUOM"]);
}
public async Task<List<ItemVM>> GetItemLocalization(Infrastructure.Models.Account.User user, ItemVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:ItemMgmt:GetItemLocalization"]);
}
public async Task<List<ItemVM>> GetDepartment(Infrastructure.Models.Account.User user, ItemVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:ItemMgmt:GetDepartment"]);
}
#endregion
#region PostPut Method
public async Task<ItemVM> PostPutItem(Infrastructure.Models.Account.User user,
ItemVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:ItemMgmt:PostPutItem"]);
}
public async Task<ItemVM> PutItemDetail(Infrastructure.Models.Account.User user,
ItemVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:ItemMgmt:PutItemDetail"]);
}
public async Task<ItemVM> PostPutItemCart(Infrastructure.Models.Account.User user, ItemVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:ItemMgmt:PostPutItemCart"]);
}
public async Task<ItemVM> PostPurchRequest(Infrastructure.Models.Account.User user, ItemVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:ItemMgmt:PostPurchRequest"]);
}
#endregion
}
}

View File

@ -0,0 +1,356 @@
using CPRNIMS.Domain.UIContracts.Common;
using CPRNIMS.Domain.UIContracts.PO;
using CPRNIMS.Infrastructure.Helper;
using CPRNIMS.Infrastructure.Models.Account;
using CPRNIMS.Infrastructure.Models.Common;
using CPRNIMS.Infrastructure.ViewModel.PO;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIServices.PO
{
public class PurchaseOrder : IPurchaseOrder
{
private readonly IConfiguration _configuration;
private readonly TokenHelper _tokenHelper;
private readonly IApiConfigurationService _apiConfigurationService;
public PurchaseOrder(IConfiguration configuration, TokenHelper tokenHelper,
IApiConfigurationService apiConfigurationService)
{
_configuration = configuration;
_tokenHelper = tokenHelper;
_apiConfigurationService = apiConfigurationService;
}
#region SendRequest service
public async Task<POVM> SendPostApiRequest(User user,
POVM viewModel, string apiEndpoint)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
var responseObject = new ResponseObject();
try
{
if (string.IsNullOrEmpty(token))
{
return null;
}
viewModel.UserId = user.UserId;
var jsonContent = JsonSerializer.Serialize(viewModel);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
HttpResponseMessage response;
response = await httpClient.PostAsync(apiEndpoint, content);
responseObject = JsonSerializer.Deserialize<ResponseObject>(await response.Content.ReadAsStringAsync());
if (response.IsSuccessStatusCode)
{
viewModel.Message = responseObject.message;
viewModel.messCode = 1;
viewModel.Data = responseObject.data;
return viewModel;
}
else
{
viewModel.Message = responseObject.message;
viewModel.messCode = 0;
return viewModel;
}
}
}
catch (Exception ex)
{
viewModel.Message = responseObject.message;
viewModel.messCode = 0;
return viewModel;
}
}
public async Task<List<POVM>> SendGetApiRequest(User user,
POVM viewModel,
string apiEndpoint)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
try
{
if (string.IsNullOrEmpty(token))
{
// Handle token retrieval failure
return null;
}
viewModel.UserId = user.UserId;
var jsonContent = JsonSerializer.Serialize(viewModel);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
HttpResponseMessage response;
response = await httpClient.PostAsync(apiEndpoint, content);
if (response.IsSuccessStatusCode)
{
var jsonResponse = await response.Content.ReadAsStringAsync();
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var myPOs = JsonSerializer.Deserialize<List<POVM>>(jsonResponse, options);
if(myPOs.Count > 0) {
myPOs[0].URL = _configuration["CommonEndpoints:ApiDefaultHeaders:ESignaturePath"];
myPOs[0].URLImg = _configuration["CommonEndpoints:ApiDefaultHeaders:ItemImages"];
}
return myPOs;
}
else
{
// Handle API request failure
return null;
}
}
}
catch (Exception ex)
{
throw;
}
}
#endregion
#region Get
public async Task<List<POVM>?> GetIncomingShipment(User user, POVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:GetIncomingShipment"]);
}
public async Task<List<POVM>> GetSupplierBidById(User user, POVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:GetSupplierBidById"]);
}
public async Task<List<POVM>> GetForPO(User user, POVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:GetForPO"]);
}
public async Task<List<POVM>> GetForPOApproval(User user, POVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:GetForPOApproval"]);
}
public async Task<List<POVM>> GetForPOApprovalByPRNo(User user, POVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:GetForPOApprovalByPRNo"]);
}
public async Task<List<POVM>> GetSupplierBidByItem(User user, POVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:GetSupplierBidByItem"]);
}
public async Task<List<POVM>?> GetPOItemDetail(User user, POVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:GetPOItemDetail"]);
}
public async Task<List<POVM>> GetSupplierBid(User user, POVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:CanvassMgmt:GetSupplierBid"]);
}
public async Task<List<POVM>> GetForBiddingApproval(User user, POVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:GetForBiddingApproval"]);
}
public async Task<List<POVM>> GetForPOPerSuppEmail(User user, POVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:GetForPOPerSuppEmail"]);
}
public async Task<List<POVM>> GetApprovedPO(User user, POVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:GetApprovedPO"]);
}
public async Task<List<POVM>> GetApprovedPOPerEmail(User user, POVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:GetApprovedPOPerEmail"]);
}
public async Task<List<POVM>?> GetPaymentTerms(User user, POVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:GetPaymentTerms"]);
}
public async Task<List<POVM>?> GetLatestPO(User user, POVM viewModels)
{
return await SendGetApiRequest(user, viewModels,
_configuration["LLI:NonInvent:POMgmt:GetLatestPO"]);
}
public async Task<List<POVM>?> GetLatestPO2(User user, POVM viewModels)
{
return await SendGetApiRequest(user, viewModels,
_configuration["LLI:NonInvent:POMgmt:GetLatestPO2"]);
}
public async Task<List<POVM>?> GetDocRequired(User user, POVM viewModels)
{
return await SendGetApiRequest(user, viewModels,
_configuration["LLI:NonInvent:POMgmt:GetDocRequired"]);
}
public async Task<List<POVM>?> GetOtherCharges(User user, POVM viewModels)
{
return await SendGetApiRequest(user, viewModels,
_configuration["LLI:NonInvent:POMgmt:GetOtherCharges"]);
}
public async Task<List<POVM>?> GetSuppliers(User user, POVM viewModels)
{
return await SendGetApiRequest(user, viewModels,
_configuration["LLI:NonInvent:POMgmt:GetSuppliers"]);
}
public async Task<List<POVM>?> GetPRWOCanvass(User user, POVM viewModels)
{
return await SendGetApiRequest(user, viewModels,
_configuration["LLI:NonInvent:POMgmt:GetPRWOCanvass"]);
}
public async Task<List<POVM>?> GetCreatedPO(User user, POVM viewModels)
{
return await SendGetApiRequest(user, viewModels,
_configuration["LLI:NonInvent:POMgmt:GetCreatedPO"]);
}
public async Task<List<POVM>?> GetCreatedPOPerSupId(User user, POVM viewModels)
{
return await SendGetApiRequest(user, viewModels,
_configuration["LLI:NonInvent:POMgmt:GetCreatedPOPerSupId"]);
}
public async Task<List<POVM>?> GetPRItemDetail(User user, POVM viewModels)
{
return await SendGetApiRequest(user, viewModels,
_configuration["LLI:NonInvent:POMgmt:GetPRItemDetail"]);
}
public async Task<List<POVM>?> GetMyCreatedPO(User user, POVM viewModels)
{
return await SendGetApiRequest(user, viewModels,
_configuration["LLI:NonInvent:POMgmt:GetMyCreatedPO"]);
}
public async Task<List<POVM>?> GetPODetailBySuppierId(User user, POVM viewModels)
{
return await SendGetApiRequest(user, viewModels,
_configuration["LLI:NonInvent:POMgmt:GetPODetailBySuppierId"]);
}
public async Task<List<POVM>?> GetIncoterms(User user, POVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:GetIncoterms"]);
}
public async Task<List<POVM>?> GetPRPOSummaryReport(User user, POVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:GetPRPOSummaryReport"]);
}
public async Task<List<POVM>?> GetPRPOSummaryItem(User user, POVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:GetPRPOSummaryItem"]);
}
public async Task<List<POVM>?> GetIndexCard(User user, POVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:GetIndexCard"]);
}
public async Task<List<POVM>?> GetPortOfDischarge(User user, POVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:GetPortOfDischarge"]);
}
#endregion
#region Post Put
public async Task<POVM> PostApprovedSupplier(User user, POVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:PostApprovedSupplier"]);
}
public async Task<POVM> PostApprovedPO(User user, POVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:PostApprovedPO"]);
}
public async Task<POVM> PostApprovedSuggested(User user, POVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:PostApprovedSuggested"]);
}
public async Task<POVM> PostPutPO(User user, POVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:PostPutPO"]);
}
public async Task<POVM> PostPOToSupplier(User user, POVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:PostPOToSupplier"]);
}
public async Task<POVM> PostPutCustomPO(User user, POVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:PostPutCustomPO"]);
}
public async Task<POVM> PutPRItemDetails(User user, POVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:PutPRItemDetails"]);
}
public async Task<POVM> PutMyPONo(User user, POVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:PutMyPONo"]);
}
public async Task<POVM> PutPOItemDetail(User user, POVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:PutPOItemDetail"]);
}
public async Task<POVM> ApprovedSelectedPO(User user, POVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:ApprovedSelectedPO"]);
}
public async Task<POVM> PostPutDocRequired(User user, POVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:PostPutDocRequired"]);
}
public async Task<POVM> PutPOCancel(User user, POVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:PutPOCancel"]);
}
public async Task<POVM> PostPutOtherCharges(User user, POVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:PostPutOtherCharges"]);
}
public async Task<POVM> PostPutIncoterms(User user, POVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:PostPutIncoterms"]);
}
public async Task<POVM> DeleteIncShip(User user, POVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:POMgmt:DeleteIncShip"]);
}
#endregion
}
}

View File

@ -0,0 +1,263 @@
using CPRNIMS.Domain.UIContracts.Common;
using CPRNIMS.Domain.UIContracts.PR;
using CPRNIMS.Infrastructure.Helper;
using CPRNIMS.Infrastructure.Models.Account;
using CPRNIMS.Infrastructure.Models.Common;
using CPRNIMS.Infrastructure.ViewModel.Items;
using CPRNIMS.Infrastructure.ViewModel.PR;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIServices.PR
{
public class PRequest : IPRequest
{
private readonly IConfiguration _configuration;
private readonly TokenHelper _tokenHelper;
private readonly IApiConfigurationService _apiConfigurationService;
public PRequest(IConfiguration configuration, TokenHelper tokenHelper,
IApiConfigurationService apiConfigurationService)
{
_configuration = configuration;
_tokenHelper = tokenHelper;
_apiConfigurationService = apiConfigurationService;
}
#region SendRequest service
public async Task<PRVM> SendPostApiRequest(User user,
PRVM viewModel, string apiEndpoint)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
try
{
if (string.IsNullOrEmpty(token))
{
return null;
}
viewModel.UserId = user.UserId;
var jsonContent = JsonSerializer.Serialize(viewModel);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
HttpResponseMessage response;
response = await httpClient.PostAsync(apiEndpoint, content);
var responseObject = JsonSerializer.Deserialize<ResponseObject>(await response.Content.ReadAsStringAsync());
if (response.IsSuccessStatusCode)
{
viewModel.messCode = responseObject.messCode;
viewModel.Message = responseObject.message;
viewModel.StatusResponse = responseObject.statusResponse;
return viewModel;
}
else
{
viewModel.messCode = 0;
viewModel.Message = responseObject.message;
viewModel.StatusResponse = responseObject.statusResponse;
return viewModel;
}
}
}
catch (Exception ex)
{
ex.ToString();
throw;
}
}
public async Task<List<PRVM>> SendGetApiRequest(User user,
PRVM viewModel,
string apiEndpoint)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
try
{
if (string.IsNullOrEmpty(token))
{
return null;
}
viewModel.UserId = user.UserId;
var jsonContent = JsonSerializer.Serialize(viewModel);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
HttpResponseMessage response;
response = await httpClient.PostAsync(apiEndpoint, content);
if (response.IsSuccessStatusCode)
{
var jsonResponse = await response.Content.ReadAsStringAsync();
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var myPR = JsonSerializer.Deserialize<List<PRVM>>(jsonResponse, options);
if (myPR.Count > 0)
{
myPR[0].URL = _configuration["CommonEndpoints:ApiDefaultHeaders:ItemImages"];
}
return myPR;
}
else
{
// Handle API request failure
return null;
}
}
}
catch (Exception ex)
{
throw;
}
}
#endregion
#region Get
public async Task<List<PRVM>?> GetApproverName(User user, PRVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:GetApproverName"]);
}
public async Task<List<PRVM>> GetAllPR(User user, PRVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:GetAllPR"]);
}
public async Task<List<PRVM>> GetMyPR(User user, PRVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:GetMyPR"]);
}
public async Task<List<PRVM>> GetForReceiving(User user, PRVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:GetForReceiving"]);
}
public async Task<List<PRVM>> GetItemDetailForReceiving(User user, PRVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:GetItemDetailForReceiving"]);
}
public async Task<List<PRVM>> GetPRDetailByPRNo(User user, PRVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:GetPRDetailByPRNo"]);
}
public async Task<List<PRVM>> GetPRByRRId(User user, PRVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:GetPRByRRId"]);
}
public async Task<List<PRVM>> GetRRDetailByPO(User user, PRVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:GetRRDetailByPO"]);
}
public async Task<List<PRVM>> GetPRStatusById(User user, PRVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:GetPRStatusById"]);
}
public async Task<List<PRVM>> GetDashBoard(User user, PRVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:GetDashBoard"]);
}
public async Task<List<PRVM>> GetPRArchived(User user, PRVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:GetPRArchived"]);
}
public async Task<List<PRVM>?> GetPRListByPRNo(User user, PRVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:GetPRListByPRNo"]);
}
public async Task<List<PRVM>?> GetDetailedPRTracking(User user, PRVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:GetDetailedPRTracking"]);
}
public async Task<List<PRVM>?> GetSupplierAlternativeOffer(User user, PRVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:GetSupplierAlternativeOffer"]);
}
public async Task<List<PRVM>?> GetSupplierAlterOfferDetails(User user, PRVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:GetSupplierAlterOfferDetails"]);
}
#endregion
#region POST PUT
public async Task<PRVM> PostPRApproveReject(User user, PRVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:PostPRApproveReject"]);
}
public async Task<PRVM> PostPutItemReceiving(User user, PRVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:PostPutItemReceiving"]);
}
public async Task<PRVM> PutItemDetail(User user, PRVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:PutItemDetail"]);
}
public async Task<PRVM> PostPutReceiving(User user, PRVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:PostPutReceiving"]);
}
public async Task<PRVM> PutPOClose(User user, PRVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:PutPOClose"]);
}
public async Task<PRVM> PostPutDeniedItem(User user, PRVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:PostPutDeniedItem"]);
}
public async Task<PRVM> PutAlternativeOffer(User user, PRVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:PutAlternativeOffer"]);
}
public async Task<PRVM> PutSupplierAlterOffer(User user, PRVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:PutSupplierAlterOffer"]);
}
public async Task<PRVM> PostPutPRItem(User user, PRVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:PutSupplierAlterOffer"]);
}
public async Task<PRVM> PRItemRemoval(User user, PRVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:PRMgmt:PRItemRemoval"]);
}
#endregion
}
}

View File

@ -0,0 +1,190 @@
using CPRNIMS.Domain.UIContracts.Common;
using CPRNIMS.Domain.UIContracts.Receiving;
using CPRNIMS.Infrastructure.Helper;
using CPRNIMS.Infrastructure.Models.Account;
using CPRNIMS.Infrastructure.Models.Common;
using CPRNIMS.Infrastructure.ViewModel.Receiving;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIServices.Receiving
{
public class Receiving : IReceiving
{
private readonly IConfiguration _configuration;
private readonly TokenHelper _tokenHelper;
private readonly IApiConfigurationService _apiConfigurationService;
public Receiving(IConfiguration configuration, TokenHelper tokenHelper,
IApiConfigurationService apiConfigurationService)
{
_configuration = configuration;
_tokenHelper = tokenHelper;
_apiConfigurationService = apiConfigurationService;
}
#region SendRequest service
public async Task<ReceivingVM> SendPostApiRequest(User user,
ReceivingVM viewModel, string apiEndpoint)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
try
{
if (string.IsNullOrEmpty(token))
{
// Handle token retrieval failure
return null;
}
viewModel.UserId = user.UserId;
var jsonContent = JsonSerializer.Serialize(viewModel);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
HttpResponseMessage response;
response = await httpClient.PostAsync(apiEndpoint, content);
var responseObject = JsonSerializer.Deserialize<ResponseObject>(await response.Content.ReadAsStringAsync());
if (response.IsSuccessStatusCode)
{
viewModel.ErrCode = 1;
viewModel.ErrMessage = responseObject.message;
viewModel.StatusResponse = responseObject.statusResponse;
return viewModel;
}
else
{
viewModel.ErrCode = 0;
viewModel.Message = responseObject.message;
viewModel.StatusResponse = responseObject.statusResponse;
return viewModel;
}
}
}
catch (Exception ex)
{
ex.ToString();
throw;
}
}
public async Task<List<ReceivingVM>> SendGetApiRequest(User user,
ReceivingVM viewModel,
string apiEndpoint)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
try
{
if (string.IsNullOrEmpty(token))
{
return null;
}
viewModel.UserId = user.UserId;
var jsonContent = JsonSerializer.Serialize(viewModel);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
HttpResponseMessage response;
response = await httpClient.PostAsync(apiEndpoint, content);
if (response.IsSuccessStatusCode)
{
var jsonResponse = await response.Content.ReadAsStringAsync();
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var myPR = JsonSerializer.Deserialize<List<ReceivingVM>>(jsonResponse, options);
if (myPR.Count > 0)
{
myPR[0].URL = _configuration["CommonEndpoints:ApiDefaultHeaders:ItemImages"];
}
return myPR;
}
else
{
// Handle API request failure
return null;
}
}
}
catch (Exception ex)
{
throw;
}
}
#endregion
#region Get
public async Task<List<ReceivingVM>?> GetRRReport(User user, ReceivingVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:Receiving:GetRRReport"]);
}
public async Task<List<ReceivingVM>> GetForReceiving(User user, ReceivingVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:Receiving:GetForReceiving"]);
}
public async Task<List<ReceivingVM>> GetPRDetailByPRNo(User user, ReceivingVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:Receiving:GetPRDetailByPRNo"]);
}
public async Task<List<ReceivingVM>> GetRRDetailByPO(User user, ReceivingVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:Receiving:GetRRDetailByPO"]);
}
public async Task<List<ReceivingVM>?> GetLatestRRNo(User user, ReceivingVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:Receiving:GetLatestRRNo"]);
}
public async Task<List<ReceivingVM>?> GetRR(User user, ReceivingVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:Receiving:GetRR"]);
}
public async Task<List<ReceivingVM>?> GetRRDetail(User user, ReceivingVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:Receiving:GetRRDetail"]);
}
#endregion
#region POST PUT
public async Task<ReceivingVM> PutRRNoSeries(User user, ReceivingVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:Receiving:PutRRNoSeries"]);
}
public async Task<ReceivingVM> PostPutReceiving(User user, ReceivingVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:Receiving:PostPutReceiving"]);
}
public async Task<ReceivingVM> PutPOClose(User user, ReceivingVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:Receiving:PutPOClose"]);
}
public async Task<ReceivingVM> PostPutDeniedItem(User user, ReceivingVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:Receiving:PostPutDeniedItem"]);
}
#endregion
}
}

View File

@ -0,0 +1,141 @@
using CPRNIMS.Domain.UIContracts.Common;
using CPRNIMS.Domain.UIContracts.SMTP;
using CPRNIMS.Infrastructure.Helper;
using CPRNIMS.Infrastructure.Models.Account;
using CPRNIMS.Infrastructure.Models.Common;
using CPRNIMS.Infrastructure.ViewModel.PR;
using CPRNIMS.Infrastructure.ViewModel.SMTP;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIServices.SMTP
{
public class SMTP : ISMTP
{
private readonly IConfiguration _configuration;
private readonly TokenHelper _tokenHelper;
private readonly IApiConfigurationService _apiConfigurationService;
public SMTP(IConfiguration configuration, TokenHelper tokenHelper,
IApiConfigurationService apiConfigurationService)
{
_configuration = configuration;
_tokenHelper = tokenHelper;
_apiConfigurationService = apiConfigurationService;
}
#region SendRequest service
public async Task<SMTPCredentialVM> SendPostApiRequest(User user,
SMTPCredentialVM viewModel, string apiEndpoint)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
try
{
if (string.IsNullOrEmpty(token))
{
// Handle token retrieval failure
return null;
}
viewModel.UserId = user.UserId;
var jsonContent = JsonSerializer.Serialize(viewModel);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
HttpResponseMessage response;
response = await httpClient.PostAsync(apiEndpoint, content);
if (response.IsSuccessStatusCode)
{
var responseObject = JsonSerializer.Deserialize<ResponseObject>(await response.Content.ReadAsStringAsync());
viewModel.Message = responseObject.message;
viewModel.StatusResponse = responseObject.statusResponse;
return viewModel;
}
else
{
// Handle API request failure
return null;
}
}
}
catch (Exception ex)
{
ex.ToString();
throw;
}
}
public async Task<List<SMTPCredentialVM>> SendGetApiRequest(User user,
SMTPCredentialVM viewModel,
string apiEndpoint)
{
var token = await _tokenHelper.GetJwtTokenAsync(user);
try
{
if (string.IsNullOrEmpty(token))
{
// Handle token retrieval failure
return null;
}
viewModel.UserId = user.UserId;
var jsonContent = JsonSerializer.Serialize(viewModel);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
using (var httpClient = _apiConfigurationService.CreateHttpClientWithDefaultHeaders(token))
{
HttpResponseMessage response;
response = await httpClient.PostAsync(apiEndpoint, content);
if (response.IsSuccessStatusCode)
{
var jsonResponse = await response.Content.ReadAsStringAsync();
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var myArtWork = JsonSerializer.Deserialize<List<SMTPCredentialVM>>(jsonResponse, options);
return myArtWork;
}
else
{
// Handle API request failure
return null;
}
}
}
catch (Exception ex)
{
throw;
}
}
#endregion
public async Task<List<SMTPCredentialVM>> GetAllSmtp(User user, SMTPCredentialVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:SMTPMgmt:GetAllSmtp"]);
}
public async Task<List<SMTPCredentialVM>> GetMySmtp(User user, SMTPCredentialVM viewModel)
{
return await SendGetApiRequest(user, viewModel,
_configuration["LLI:NonInvent:SMTPMgmt:GetMySmtp"]);
}
public async Task<SMTPCredentialVM> PostPutSmtp(User user, SMTPCredentialVM viewModel)
{
return await SendPostApiRequest(user, viewModel,
_configuration["LLI:NonInvent:SMTPMgmt:PostPutSmtp"]);
}
}
}

View File

@ -0,0 +1,21 @@
using Microsoft.AspNetCore.SignalR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIServices.Updater
{
public class CartHub : Hub
{
public async Task UpdateCartCount(int count)
{
await Clients.All.SendAsync("ReceiveCartUpdate", count);
}
public async Task UpdateUserCartCount(string userId, int count)
{
await Clients.User(userId).SendAsync("ReceiveCartUpdate", count);
}
}
}

View File

@ -0,0 +1,46 @@
using Microsoft.AspNetCore.SignalR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace CPRNIMS.Domain.UIServices.Updater
{
public class NotificationHub : Hub
{
// This method can be called by clients
public async Task SendMessage(string user, string message)
{
// Broadcast the message to all connected clients
await Clients.All.SendAsync("ReceiveMessage", user, message);
}
// This method can be used to send updates to specific groups
public async Task JoinGroup(string groupName)
{
await Groups.AddToGroupAsync(Context.ConnectionId, groupName);
}
// Send message to a specific group
public async Task SendMessageToGroup(string groupName, string user, string message)
{
await Clients.Group(groupName).SendAsync("ReceiveMessage", user, message);
}
// Called when a new connection is established
public override async Task OnConnectedAsync()
{
await Clients.All.SendAsync("UserConnected", Context.ConnectionId);
await base.OnConnectedAsync();
}
// Called when a connection is terminated
public override async Task OnDisconnectedAsync(Exception exception)
{
await Clients.All.SendAsync("UserDisconnected", Context.ConnectionId);
await base.OnDisconnectedAsync(exception);
}
}
}

View File

@ -0,0 +1,24 @@
<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.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Features" Version="8.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Constant
{
public class CompanyName
{
public const string LLI = "LLI";
public const string MDLD = "MDLD";
public const string EUROPRINT = "EUROPRINT";
public const string Traders = "Traders";
}
}

View File

@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Constant
{
public class FileExtension
{
public const int Pdf = 1;
public const int Jpeg = 2;
public const int Png = 3;
public const int Csv = 4;
public const int Xlsx = 5;
public const int Docx = 6;
public const int Pptx = 7;
public const int AI = 6;
public const int Psd = 7;
}
public class FileExtensionPath
{
public const string Pdf = "Content/Documents/pdf";
public const string Csv = "Content/Documents/csv";
public const string Xlsx = "Content/Documents/xlsx";
public const string Docx = "Content/Documents/docx";
public const string Pptx = "Content/Documents/pptx";
public const string Png = "Content/Images/UserProfile/png";
public const string Jpg = "Content/Images/UserProfile/jpg";
public const string AI = "Content/Images/UserProfile/ai";
public const string Psd = "Content/Images/UserProfile/psd";
public static string GetExtensionPath(string imageFormat)
{
switch (imageFormat.ToLower())
{
case "pdf":
return Pdf;
case "csv":
return Csv;
case "xlsx":
return Xlsx;
case "pptx":
return Pptx;
case "docx":
return Docx;
case "jpeg":
return Jpg;
case "png":
return Png;
// Add other cases for different image formats if needed
default:
// Handle the default case or throw an exception
throw new InvalidOperationException("Unsupported image format");
}
}
public static string GetArtWorkExtensionPath(string imageFormat)
{
switch (imageFormat.ToLower())
{
case "ai":
return AI;
case "psd":
return Psd;
// Add other cases for different file types
default:
// Handle the default case or throw an exception
throw new InvalidOperationException("Unsupported file type format");
}
}
}
}

View File

@ -0,0 +1,26 @@
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.AspNetCore.Identity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CPRNIMS.Infrastructure.Entities.Account;
using Microsoft.EntityFrameworkCore;
namespace CPRNIMS.Infrastructure.Database
{
public class AuhorizationDbContext : IdentityDbContext<IdentityUser>
{
public AuhorizationDbContext(DbContextOptions<AuhorizationDbContext> options) : base(options) { }
public DbSet<AuthorizeRoles> AuthorizeRoles { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<IdentityRole>(entity =>
{
entity.ToTable("Roles"); // Specify the table name for roles
});
}
}
}

View File

@ -0,0 +1,220 @@
using CPRNIMS.Infrastructure.Entities.Account;
using CPRNIMS.Infrastructure.Entities.Canvass;
using CPRNIMS.Infrastructure.Entities.Common;
using CPRNIMS.Infrastructure.Entities.Finance;
using CPRNIMS.Infrastructure.Entities.Inventory;
using CPRNIMS.Infrastructure.Entities.Items;
using CPRNIMS.Infrastructure.Entities.PO;
using CPRNIMS.Infrastructure.Entities.Purchasing;
using CPRNIMS.Infrastructure.Entities.SMTP;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Database
{
public class NonInventoryDbContext : IdentityDbContext<ApplicationUser>
{
public NonInventoryDbContext(DbContextOptions<NonInventoryDbContext> options) : base(options) { }
public virtual DbSet<ItemCode> ItemCodes { get; set; }
public virtual DbSet<ItemList> ItemList { get; set; }
public virtual DbSet<Item> Items { get; set; }
public DbSet<Departments> Departments { get; set; }
public DbSet<IdentityRole> IdentityRoles { get; set; }
public DbSet<UserRights> UserRights { get; set; }
public DbSet<IdentityUserRole<string>> IdentityUserRoles { get; set; }
public DbSet<ForgotPassword> ForgotPasswords { get; set; }
public virtual DbSet<Otps> Otps { get; set; }
public DbSet<Attachment> Attachments { get; set; }
public virtual DbSet<AttachmentExtension> AttachmentExtensions { get; set; }
public virtual DbSet<AttachmentFileType> AttachmentFileTypes { get; set; }
public virtual DbSet<ItemAttachement> ItemAttachements { get; set; }
public virtual DbSet<ErrorMessage> ErrorMessages { get; set; }
public virtual DbSet<ControllerAccess> ControllerAccess { get; set; }
public virtual DbSet<ItemCategory> ItemCategories { get; set; }
public virtual DbSet<UnitOfMessure> UnitOfMessures { get; set; }
public virtual DbSet<ItemColor> ItemColors { get; set; }
public virtual DbSet<ItemLocalization> ItemLocalizations { get; set; }
public virtual DbSet<ItemCart> ItemCarts { get; set; }
public virtual DbSet<PR> PRs { get; set; }
public virtual DbSet<Approved> Approved { get; set; }
public virtual DbSet<SMTPCredential> SMTPCredentials { get; set; }
public virtual DbSet<PRDetails> PRDetails { get; set; }
public virtual DbSet<NotificationById> NotificationByIds { get; set; }
public virtual DbSet<AlternativeOffer> AlternativeOffers { get; set; }
public virtual DbSet<AlternativeOfferDetails> AlternativeOfferDetails { get; set; }
public virtual DbSet<MyPRWOCanvass> MyPRWOCanvass { get; set; }
public virtual DbSet<Entities.Purchasing.PRList> PRLists { get; set; }
public virtual DbSet<Entities.Canvass.PRList> PRItemList { get; set; }
public virtual DbSet<ItemApproval> ItemApprovals { get; set; }
public virtual DbSet<ForReceiving> ForReceivings { get; set; }
public virtual DbSet<Infrastructure.Entities.Receiving.RRReport> RRReports { get; set; }
public virtual DbSet<ReceivingDetail> ReceivingDetails { get; set; }
public virtual DbSet<RRDetail> RRDetails { get; set; }
public virtual DbSet<ForRR> ForRRs { get; set; }
public virtual DbSet<RR> RRs { get; set; }
public virtual DbSet<Canvass> Canvasses { get; set; }
public virtual DbSet<ForCanvassFollowUp> ForCanvassFollowUps { get; set; }
public virtual DbSet<WOResponse> WOResponses { get; set; }
public virtual DbSet<WOResponseById> WOResponseByIds { get; set; }
public virtual DbSet<ItemListWOEmail> ItemListWOEmails { get; set; }
public virtual DbSet<Suppliers> Suppliers { get; set; }
public virtual DbSet<RFQ> RFQs { get; set; }
public virtual DbSet<BiddingItem> BiddingItems { get; set; }
public virtual DbSet<SupplierBidById> SupplierBidByIds { get; set; }
public virtual DbSet<RFQPerSupplier> RFQPerSuppliers { get; set; }
public virtual DbSet<PerSupplier> PerSuppliers { get; set; }
public virtual DbSet<CanvassSupplier> CanvassSuppliers { get; set; }
public virtual DbSet<RFQReference> RFQReferences { get; set; }
public virtual DbSet<CanvassDetail> CanvassDetails { get; set; }
public virtual DbSet<CanvassGroupByPRNo> CanvassGroupByPRNos { get; set; }
public virtual DbSet<ForCanvass> ForCanvasses { get; set; }
public virtual DbSet<ForPO> ForPOs { get; set; }
public virtual DbSet<CreatedPO> CreatedPOs { get; set; }
public virtual DbSet<CustomPO> CustomPOs { get; set; }
public virtual DbSet<IndexCard> IndexCards { get; set; }
public virtual DbSet<ForPOApproval> ForPOApprovals { get; set; }
public virtual DbSet<ApprovedPO> ApprovedPOs { get; set; }
public virtual DbSet<PurchaseOrder> PurchaseOrders { get; set; }
public virtual DbSet<PO> POs { get; set; }
public virtual DbSet<PRPOSummaryCount> PRPOSummaryCounts { get; set; }
public virtual DbSet<PRPOSummaryItem> PRPOSummaryItems { get; set; }
public virtual DbSet<POItemDetail> POItemDetails { get; set; }
public virtual DbSet<OtherCharges> OtherCharges { get; set; }
public virtual DbSet<PortOfDischarges> PortOfDischarges { get; set; }
public virtual DbSet<DocRequired> DocRequireds { get; set; }
public virtual DbSet<BiddingApproval> BiddingApprovals { get; set; }
public virtual DbSet<Entities.Receiving.RRDetail> RRDetailss { get; set; }
public virtual DbSet<RRSeries> RRSeries { get; set; }
public virtual DbSet<PRWOCanvass> PRWOCanvasses { get; set; }
public virtual DbSet<ForPayment> ForPayments { get; set; }
public virtual DbSet<Inventory> Inventories { get; set; }
public virtual DbSet<Entities.Inventory.ItemDetail> ItemDetails { get; set; }
public virtual DbSet<Entities.PO.ItemDetail> PRItemDetails { get; set; }
public virtual DbSet<Lot> Lots { get; set; }
public virtual DbSet<LotQtyByItem> LotQtyByItems { get; set; }
public virtual DbSet<RequestItem> RequestItems { get; set; }
public virtual DbSet<RequestItemDetail> RequestItemDetails { get; set; }
public virtual DbSet<NotifUserKey> NotifUserKeys { get; set; }
public virtual DbSet<ItemListForPO> ItemListForPOs { get; set; }
public virtual DbSet<CreatedPOPerSupId> CreatedPOPerSupIds { get; set; }
public virtual DbSet<PRTracking> PRTrackings { get; set; }
public virtual DbSet<Dashboard> Dashboards { get; set; }
public virtual DbSet<PaymentTerm> PaymentTerms { get; set; }
public virtual DbSet<Incoterm> Incoterms { get; set; }
public virtual DbSet<CentralPONo> CentralPONos { get; set; }
public virtual DbSet<RRReport> DetailedPRTrackings { get; set; }
public DbSet<IncomingShipment> IncomingShipments { get; set; }
public virtual DbSet<IncomingShipmentDto> IncomingShipmentDtos { get; set; }
#region Automation Part
public virtual DbSet<AllForCanvass> AllForCanvasses { get; set; }
#endregion
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Incoterm>()
.Property(e => e.IncotermsId)
.ValueGeneratedOnAdd();
modelBuilder.Entity<CanvassSupplier>()
.Property(e => e.CanvassSupplierId)
.ValueGeneratedNever();
modelBuilder.Entity<RRReport>(b =>
{
b.ToTable("DetailsedPRTracking");
b.HasNoKey();
});
modelBuilder.Entity<PRPOSummaryCount>(b =>
{
b.ToTable("PRPOSummaryCount");
b.HasNoKey();
});
modelBuilder.Entity<PRPOSummaryItem>(b =>
{
b.ToTable("PRPOSummaryItem");
b.HasNoKey();
});
modelBuilder.Entity<ApplicationUser>(b =>
{
b.ToTable("Users");
b.Property(u => u.Address).HasMaxLength(255);
b.HasOne(u => u.Attachment)
.WithOne(a => a.ApplicationUser)
.HasForeignKey<Attachment>(a => a.AttachmentId)
.IsRequired(false); // Allow null if there is no attachment
});
modelBuilder.Entity<Attachment>(b =>
{
b.ToTable("Attachments");
b.HasOne(a => a.AttachmentExtention)
.WithOne()
.HasForeignKey<Attachment>(a => a.ExtensionId)
.IsRequired(false); // Allow null if there is no extension
});
modelBuilder.Entity<ApplicationUser>(b =>
{
b.HasOne(u => u.Department)
.WithMany()
.HasForeignKey(u => u.DepartmentId)
.IsRequired(false);
});
modelBuilder.Entity<ForPO>(entity =>
{
entity.ToTable("ForPO");
entity.HasNoKey();
});
modelBuilder.Entity<Departments>(b =>
{
b.ToTable("Departments");
});
modelBuilder.Entity<ControllerAccess>(b =>
{
b.ToTable("ControllerAccess");
});
modelBuilder.Entity<AttachmentExtension>(b =>
{
b.ToTable("AttachmentExtensions");
});
modelBuilder.Entity<IdentityUserClaim<string>>(b =>
{
b.ToTable("UserClaims");
});
modelBuilder.Entity<IdentityUserLogin<string>>(b =>
{
b.ToTable("UserLogins");
});
modelBuilder.Entity<IdentityRoleClaim<string>>(b =>
{
b.ToTable("RoleClaims");
});
modelBuilder.Entity<IdentityUserToken<string>>(b =>
{
b.ToTable("UserTokens");
});
modelBuilder.Entity<IdentityRole>(b =>
{
b.ToTable("Roles");
});
modelBuilder.Entity<IdentityUserRole<string>>(b =>
{
b.ToTable("UserRoles");
});
}
}
}

View File

@ -0,0 +1,27 @@
using CPRNIMS.Infrastructure.Entities.LocalDb.NonInvent;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Database
{
public class PurchLocalDbContext : IdentityDbContext
{
public PurchLocalDbContext(DbContextOptions<PurchLocalDbContext> options)
: base(options) { }
public virtual DbSet<SystemSettings> SystemSettings { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<SystemSettings>(entity =>
{
entity.ToTable("SystemSettings");
entity.HasNoKey();
});
}
}
}

View File

@ -0,0 +1,33 @@
using CPRNIMS.Infrastructure.Entities.Common;
using CPRNIMS.Infrastructure.ViewModel.Account;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Dto.Account
{
public class AccountDto : CommonProperties
{
public long UserAccessId { get; set; }
public string? UserId { get; set; }
public int ContAccId { get; set; }
public string? AccessType { get; set; }
public string? Action { get; set; }
public string? Controller { get; set; }
public string? AdminUserId { get; set; }
public bool IsNotExist { get; set; } = false;
public bool IsActive { get; set; }
public byte AccessTypeId { get; set; }
public int DepartmentId { get; set; }
public string? Department { get; set; }
public string? errMessage { get; set; }
public string? StatusResponse { get; set; }
public byte messCode { get; set; }
public string? FullName { get; set; }
public string? Email { get; set; }
public string? PageName { get; set; }
public UserRightsList? UserRightsList { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using CPRNIMS.Infrastructure.Entities.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Dto.Attachement
{
public class AttachResponseDto : CommonProperties
{
public int Id { get; set; }
public string? AttachmentId { get; set; }
public string? URL { get; set; }
public string? FileName { get; set; }
public int? ExtensionId { get; set; }
public int? AttachmentTypeId { get; set; }
}
}

View File

@ -0,0 +1,86 @@
using CPRNIMS.Infrastructure.Entities.Common;
using CPRNIMS.Infrastructure.ViewModel.Items;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Dto.Canvass
{
public class CanvassDto : CommonProperties
{
public byte PaymentTermsId { get; set; } = 0;
public bool IsArchived { get; set; } = false;
public long ItemCodeId { get; set; }
public long PRDetailsId { get; set; }
public byte POTypeId { get; set; }
public bool SuggestedSupplier { get; set; }
public long PODetailId { get; set; }
public byte RequestTypeId { get; set; }
public decimal QuantityReceived { get; set; }
public short ReceivingStatus { get; set; }
public int DepartmentId { get; set; }
public string? Department { get; set; }
public string? UserId { get; set; }
public string? ItemName { get; set; }
public int SupplierId { get; set; }=0;
public string? SupplierName { get; set; }
public string? EmailAddress { get; set; }
public string? ItemDescription { get; set; }
public decimal Price { get; set; }
public DateTime CommitmentDate { get; set; }
public string? Manufacturer { get; set; }
public string? Remarks { get; set; }
public string? Terms { get; set; }
public int UOMId { get; set; }
public int ItemColorId { get; set; }
public short Status { get; set; } = 0;
public string? StatusName { get; set; }
public bool IsActive { get; set; }
public bool IsCommon { get; set; }
public bool IsCompleted { get; set; } = false;
public long ItemNo { get; set; }
public string? Token { get; set; }
public decimal Qty { get; set; }
public string? UOMName { get; set; }
public long ItemAttachId { get; set; }
public string? ItemAttachPath { get; set; }
public DateTime DateNeeded { get; set; }
public long PRNo { get; set; } = 0;
public string? Address { get; set; }
public string? ContactNo { get; set; }
public string? ContactPerson { get; set; }
public bool IsTagging { get; set; } = false;
public long CanvassDetailId { get; set; }
public long CanvassId { get; set; }
public decimal QtyRequest { get; set; }
//public byte IsApproved { get; set; }
public long RRDetailId { get; set; }
public long PRDetailId { get; set; }
public decimal Quantity { get; set; }
public decimal UnitPrice { get; set; }
public decimal GrossAmount { get; set; }
public string? CanvassCreatedDate { get; set; }
public string? CanvassSubmitedDate { get; set; }
public string? SuppBidDate { get; set; }
public string? CanvassApprovedDate { get; set; }
public string? PONumber { get; set; }
public string? ErrMessage { get; set; }
public bool IsHistory { get; set; }
public byte ErrCode { get; set; }
public int CanvassNo { get; set; }
public bool IsDenied { get; set; } = false;
public string? FullName { get; set; }
public string? Specification { get; set; }
public byte CurrencyId { get; set; } = 1;
public bool VatInc { get; set; }=false;
public string? TinNo { get; set; }
public string? LeadTime { get; set; }
public byte Query { get; set; } = 0;
public bool IsReset { get; set; }
public string? AggreItemNo { get; set; }
public long CanvassSupplierId { get; set; }
}
}

View File

@ -0,0 +1,108 @@
using CPRNIMS.Infrastructure.Entities.Common;
using CPRNIMS.Infrastructure.ViewModel.Items;
using CPRNIMS.Infrastructure.ViewModel.PR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Dto.Finance
{
public class RRDetailsDto : CommonProperties
{
public long ItemCodeId { get; set; }
public long PRDetailsId { get; set; }
public long RRId { get; set; }
public string? RequestedBy { get; set; }
public long RRNo { get; set; }
public long POId { get; set; }
public byte DocTypeId { get; set; }
public string? Department { get; set; }
public decimal TotalAmount { get; set; }
public string? ItemCategoryName { get; set; }
public string? UserId { get; set; }
public string? ItemName { get; set; }
public string? ItemDescription { get; set; }
public short Status { get; set; }
public short ReceivingStatus { get; set; }
public string? StatusName { get; set; }
public string? NewPRNo { get; set; }
public DateTime DateNeeded { get; set; }
public bool IsActive { get; set; }
public long ItemNo { get; set; }
public string? ItemLocalName { get; set; }
public byte PRTypeId { get; set; }
public decimal Qty { get; set; }
public decimal QuantityReceived { get; set; }
public string? ItemTypeName { get; set; }
public string? ItemClassName { get; set; }
public short ItemClassId { get; set; }
public string? UOMName { get; set; }
public string? ItemColorName { get; set; }
public string? ItemAttachPath { get; set; }
public long PRNo { get; set; }
public string? PONo { get; set; }
public string? Message { get; set; }
public string? StatusResponse { get; set; }
public string? Remarks { get; set; }
public bool Reject { get; set; }
public bool Upload { get; set; }
public bool Encoded { get; set; }
public bool Edit { get; set; }
public bool Queue { get; set; }
public string? URL { get; set; }
public string? AggrePRNo { get; set; }
public string? AggreItemNo { get; set; }
public string? AggreItemName { get; set; }
public string? EmailAddress { get; set; }
public string? SupplierName { get; set; }
public string? POTypeName { get; set; }
public byte POTypeId { get; set; }
public long canvassDetailId { get; set; }
public long RRDetailId { get; set; }
public long PRDetailId { get; set; }
public int Quantity { get; set; }
public decimal UnitPrice { get; set; }
public decimal GrossAmount { get; set; }
public string? ReceivedBy { get; set; }
public string? AcknowledgeBy { get; set; }
public string? AcknowledgeDate { get; set; }
public string? DRNo { get; set; }
public string? CurrencyName { get; set; }
public decimal RemainingQty { get; set; }
public string? PaymentTerms { get; set; }
public bool IsCompleted { get; set; }
public string? PRCreatedDate { get; set; }
public string? PRApprover1 { get; set; }
public string? PRApprover2 { get; set; }
public string? CanvassCreatedDate { get; set; }
public string? CanvassSubmitedDate { get; set; }
public string? SuppBidDate { get; set; }
public string? CanvassApprovedDate { get; set; }
public string? POPreparationDate { get; set; }
public string? PoCreatedDate { get; set; }
public string? PoApprovedDate { get; set; }
public string? POForwardedDate { get; set; }
public string? ItemArrivedDate { get; set; }
public string? ReceivedDate { get; set; }
public string? PONumber { get; set; }
public byte DashboardId { get; set; }
public int ForCanvassItem { get; set; }
public int WOSupResponseCount { get; set; }
public int PRNoCount { get; set; }
public int ForApprover1 { get; set; }
public int ForApprover2 { get; set; }
public int ForPOApproval { get; set; }
public int ForPO { get; set; }
public int ForPayment { get; set; }
public int ForDelivery { get; set; }
public int PartialReceived { get; set; }
public int SuppBidApproval { get; set; }
public int ApprovedPO { get; set; }
public int SupplierBid { get; set; }
public int DeniedItem { get; set; }
public bool IsDenied { get; set; }
public ItemReceivingList? ItemList { get; set; }
}
}

View File

@ -0,0 +1,73 @@
using CPRNIMS.Infrastructure.Entities.Common;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Dto.Inventory
{
public class InventoryDto : CommonProperties
{
public long PRDetailsId { get; set; }
public long RRDetailId { get; set; }
public long PONo { get; set; }
public byte IsApproved { get; set; }
public long PODetailId { get; set; }
public decimal QuantityReceived { get; set; }
public short ReceivingStatus { get; set; }
public int DepartmentId { get; set; }
public string? Department { get; set; }
public string? CreatedDateStr { get; set; }
public string? ItemCategoryName { get; set; }
public string? UserId { get; set; }
public string? ItemName { get; set; }
public int SupplierId { get; set; }
public string? SupplierName { get; set; }
public string? EmailAddress { get; set; }
public string? ItemDescription { get; set; }
public decimal Price { get; set; }
public DateTime CommitmentDate { get; set; }
public string? Manufacturer { get; set; }
public string? Remarks { get; set; }
public int UOMId { get; set; }
public int ItemColorId { get; set; }
public short Status { get; set; }
public string? StatusName { get; set; }
public bool IsActive { get; set; }
public bool IsCommon { get; set; }
public long ItemNo { get; set; }
public short ItemLocalId { get; set; }
public string? ItemLocalName { get; set; }
public short ItemTypeId { get; set; }
public byte PRTypeId { get; set; }
public decimal Qty { get; set; }
public byte PackagingTypeId { get; set; }
public string? ItemTypeName { get; set; }
public short ItemClassId { get; set; }
public string? ItemClassName { get; set; }
public string? UOMName { get; set; }
public string? ItemColorName { get; set; }
public long ItemAttachId { get; set; }
public string? ItemAttachPath { get; set; }
public DateTime DateNeeded { get; set; }
public long PRNo { get; set; }
public string? Address { get; set; }
public string? ContactNo { get; set; }
public string? ContactPerson { get; set; }
public long CanvassDetailId { get; set; }
public long CanvassId { get; set; }
public int InventoryId { get; set; }
public int LotId { get; set; }
public byte LotTypeId { get; set; }
public string? LotName { get; set; }
public bool IsSorting { get; set; } = false;
public decimal QtyReceived { get; set; }
public decimal QtyRequest { get; set; }
public long RequestItemId { get; set; }
public DateTime DateFrom { get; set; }
public DateTime DateTo { get; set; }
public bool WithoutStocks { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Dto.Items
{
public class ItemCartDto
{
public List<long>? ItemCartIds { get; set; }
public List<int>? Qty { get; set; }
}
}

View File

@ -0,0 +1,26 @@
using CPRNIMS.Infrastructure.Entities.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Dto.Items
{
public class ItemCodeDto : CommonProperties
{
public long ItemCodeId { get; set; }
public int DepartmentId { get; set; }
public string? Department { get; set; }
public string? ItemCategoryName { get; set; }
public byte RequestTypeId { get; set; }
public short ItemCategoryId { get; set; }
public string? ItemName { get; set; }
public string? ItemDescription { get; set; }
public string? UserId { get; set; }
public short Status { get; set; }
public bool IsActive { get; set; }
}
}

View File

@ -0,0 +1,119 @@
using CPRNIMS.Infrastructure.Entities.Common;
using CPRNIMS.Infrastructure.ViewModel.Items;
using CPRNIMS.Infrastructure.ViewModel.PR;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Dto.Items
{
public class ItemDto : CommonProperties
{
public bool IsArchived { get; set; }=false;
public long ItemCodeId { get; set; }
public long PRDetailsId { get; set; } = 0;
public string? PONo { get; set; }
public byte POTypeId { get; set; }
public bool SuggestedSupplier { get; set; }
public long PODetailId { get; set; }
public byte RequestTypeId { get; set; }
public decimal QuantityReceived { get; set; }
public short ReceivingStatus { get; set; }
public long ItemCartId { get; set; }
public int DepartmentId { get; set; }
public int ItemCount { get; set; }
public string? Department { get; set; }
public string? ItemCategoryName { get; set; }
public string? UserId { get; set; }
public string? ItemName { get; set; }
public int CartItemCount { get; set; }
public int SupplierId { get; set; }
public string? SupplierName { get; set; }
public string? EmailAddress { get; set; }
public string? ItemDescription { get; set; }
public decimal Price { get; set; }
public DateTime CommitmentDate { get; set; }
public string? Manufacturer { get; set; }
public string? Remarks { get; set; }
public int UOMId { get; set; }
public int ItemColorId { get; set; }
public short Status { get; set; } = 0;
public string? StatusName { get; set; }
public bool IsActive { get; set; }
public bool IsCommon { get; set; }
public bool IsCompleted { get; set; } = false;
public long ItemNo { get; set; }
public string? Token { get; set; }
public short ItemLocalId { get; set; }
public string? ItemLocalName { get; set; }
public short ItemTypeId { get; set; }
public byte PRTypeId { get; set; }
public decimal Qty { get; set; }
public byte PackagingTypeId { get; set; }
public string? ItemTypeName { get; set; }
public short ItemClassId { get; set; }
public string? ItemClassName { get; set; }
public string? UOMName { get; set; }
public string? ItemColorName { get; set; }
public long ItemAttachId { get; set; }
public string? ItemAttachPath { get; set; }
public ItemCartVM? ItemCartDto { get; set; }
public DateTime DateNeeded { get; set; }
public long PRNo { get; set; } = 0;
public string? NewPRNo { get; set; }
public string? Address { get; set; }
public string? ContactNo { get; set; }
public string? ContactPerson { get; set; }
public bool IsTagging { get; set; }=false;
public long CanvassDetailId { get; set; }
public long CanvassId { get; set; }
public decimal QtyRequest { get; set; }
public byte IsApproved { get; set; }
public int RequestItemId { get; set; }
public decimal QtyReceived { get; set; }
public int LotId { get; set; }
public string? Role { get; set; }
public short ItemCategoryId { get; set; }
public int ChargeTo { get; set; } = 0;
public long RRDetailId { get; set; }
public long PRDetailId { get; set; }
public decimal Quantity { get; set; }
public decimal UnitPrice { get; set; }
public decimal GrossAmount { get; set; }
public string? ReceivedBy { get; set; }
public string? AcknowledgeBy { get; set; }
public string? AcknowledgeDate { get; set; }
public string? DRNo { get; set; }
public long RRId { get; set; }
public byte DocTypeId { get; set; }
public long RRNo { get; set; }
public string? PRCreatedDate { get; set; }
public string? PRApprover1 { get; set; }
public string? PRApprover2 { get; set; }
public string? CanvassCreatedDate { get; set; }
public string? CanvassSubmitedDate { get; set; }
public string? SuppBidDate { get; set; }
public string? CanvassApprovedDate { get; set; }
public string? POPreparationDate { get; set; }
public string? PoCreatedDate { get; set; }
public string? PoApprovedDate { get; set; }
public string? POForwardedDate { get; set; }
public string? ItemArrivedDate { get; set; }
public string? ReceivedDate { get; set; }
public string? PONumber { get; set; }
public string? POTypeName { get; set; }
public string? ErrMessage { get; set; }
public byte ErrCode { get; set; }
public int CanvassNo { get; set; }
public bool IsDenied { get; set; }=false;
public bool IsMDLD { get; set; } = false;
public bool IsCount { get; set; } = false;
public DateTime DateFrom { get; set; }
public DateTime DateTo { get; set; }
public bool IsSorting { get; set; }=false;
}
}

View File

@ -0,0 +1,118 @@
using CPRNIMS.Infrastructure.Entities.Common;
using CPRNIMS.Infrastructure.ViewModel.PO;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Dto.PO
{
public class PODto : CommonProperties
{
public long ItemCodeId { get; set; }
public long PRDetailsId { get; set; }
public long CanvassSupplierId { get; set; }
public string? StringPRNo { get; set; }
public string? PONo { get; set; }
public long PODetailId { get; set; }
public long CanvassId { get; set; }
public long ItemCartId { get; set; }
public int DepartmentId { get; set; }
public string? SupplierName { get; set; }
public string? Manufacturer { get; set; }
public int ItemCount { get; set; }
public short CurrencyId { get; set; }
public string? Department { get; set; }
public string? ItemCategoryName { get; set; }
public DateTime CommitmentDate { get; set; }
public string? Terms { get; set; }
public string? UserId { get; set; }
public string? ItemName { get; set; }
public int CartItemCount { get; set; }
public int SupplierId { get; set; }
public string? EmailAddress { get; set; }
public string? ItemSpecs { get; set; }
public string? ItemDescription { get; set; }
public int UOMId { get; set; }
public int ItemColorId { get; set; }
public short Status { get; set; }
public string? StatusName { get; set; }
public bool IsActive { get; set; }=false;
public bool Approver { get; set; }
public bool SuggestedSupplier { get; set; }
public long ItemNo { get; set; }
public short ItemLocalId { get; set; }
public string? ItemLocalName { get; set; }
public short ItemTypeId { get; set; }
public byte PRTypeId { get; set; }
public decimal Qty { get; set; }
public byte PackagingTypeId { get; set; }
public string? ItemTypeName { get; set; }
public short ItemClassId { get; set; }
public string? ItemClassName { get; set; }
public string? UOMName { get; set; }
public string? ItemColorName { get; set; }
public long ItemAttachId { get; set; }
public string? ItemAttachPath { get; set; }
public DateTime DateNeeded { get; set; }
public long PRNo { get; set; }
public long CanvassDetailId { get; set; }
public string? NewPRNo { get; set; }
public string? Remarks { get; set; }
public bool IsApproved { get; set; }
public bool IsPrepared { get; set; }
public string? Message { get; set; }
public string? StatusResponse { get; set; }
public string? ContactNo { get; set; }
public string? ContactPerson { get; set; }
public string? Address { get; set; }
public decimal Price { get; set; }
public decimal UnitPrice { get; set; }
public decimal TotalAmount { get; set; }
public string? AggrePRNo { get; set; }
public string? AggreItemNo { get; set; }
public string? AggreItemName { get; set; }
public string? SupplierAddress { get; set; }
public string? RequestedBy { get; set; }
public string? PurchaseBy { get; set; }
public string? Purposes { get; set; }
public byte POTypeId { get; set; }
public DateTime DeliveryDate { get; set; }
public DateTime CurrentDate { get; set; }
public string? URL { get; set; }
public string? PORemarks { get; set; }
public string? ProfInvoiceNo { get; set; }
public byte PODId { get; set; } = 0;
public byte? PaymentTermsId { get; set; }
public string? PaymentTerms { get; set; }
public byte? ShippingInstructionId { get; set; }
public byte IncoTermsId { get; set; }
public DateTime ProfInvoiceDate { get; set; }= DateTime.UtcNow;
public string? PortOfDischarge { get; set; }
public string? ShippingInstruction { get; set; }
public string? IncoTerms { get; set; }
public bool IsArchived { get; set; }
public string? DocName { get; set; }
public decimal Discount { get; set; }
public byte DocRequirementId { get; set; }
public DocRequirementList? DocRequiredList { get; set; }
public POChargesList? POChargesList { get; set; }
public PRItemList? PRItemList { get; set; }
public byte messCode { get; set; }
public bool IsHistory { get; set; }= false;
public int OtherChargesId { get; set; }
public long POId { get; set; }
public decimal Amount { get; set; }
public decimal Quantity { get; set; }
public string? DeliverTo { get; set; }
public bool IsManual { get; set; }
public string? Specification { get; set; }
public DateTime To { get; set; }
public DateTime From { get; set; }
public string? OtherChargesName { get; set; }
public string? IncotermsName { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Dto.PR
{
public class MessageResponse
{
public byte MessageCode { get; set; }
public string? Message { get; set; }
}
}

View File

@ -0,0 +1,129 @@
using CPRNIMS.Infrastructure.Entities.Common;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Dto.PR
{
public class PRDto : CommonProperties
{
public byte messCode;
public long ItemCodeId { get; set; }
public long PRDetailsId { get; set; }=0;
public string? PRBy { get; set; }
public DateTime PRDate { get; set; }
public string? AttestedBy { get; set; }
public string? ApprovedBy { get; set; }
public string? CanvassDate { get; set; }
public string? CanvassBy { get; set; }
public string? PONo { get; set; }
public string? PODate { get; set; }
public string? RRDate { get; set; }
public string? ReceivedDate { get; set; }
public string? ReceivedBy { get; set; }
public string? AcknowledgeBy { get; set; }
public string? AcknowledgeDate { get; set; }
public string? Specification { get; set; }
public bool IsArchived { get; set; }
public long RRId { get; set; }
public string? RequestedBy { get; set; }
public long RRNo { get; set; }
public long POId { get; set; }
public byte DocTypeId { get; set; }
public string? Department { get; set; }
public decimal TotalAmount { get; set; }
public string? ItemCategoryName { get; set; }
public string? UserId { get; set; }
public string? ItemName { get; set; }
public string? ItemDescription { get; set; }
public short Status { get; set; }
public short ReceivingStatus { get; set; }
public string? StatusName { get; set; }
public string? NewPRNo { get; set; }
public DateTime DateNeeded { get; set; }
public bool IsActive { get; set; }
public long ItemNo { get; set; }
public string? ItemLocalName { get; set; }
public byte PRTypeId { get; set; }
public decimal Qty { get; set; }
public decimal QuantityReceived { get; set; }
public string? ItemTypeName { get; set; }
public string? ItemClassName { get; set; }
public short ItemClassId { get; set; }
public string? UOMName { get; set; }
public string? ItemColorName { get; set; }
public string? ItemAttachPath { get; set; }
public long PRNo { get; set; }
public string? Message { get; set; }
public string? StatusResponse { get; set; }
public string? Remarks { get; set; }
public bool Reject { get; set; }
public bool Upload { get; set; }
public bool Encoded { get; set; }
public bool Edit { get; set; }
public bool Queue { get; set; }
public string? URL { get; set; }
public string? AggrePRNo { get; set; }
public string? AggreItemNo { get; set; }
public string? AggreItemName { get; set; }
public string? EmailAddress { get; set; }
public string? SupplierName { get; set; }
public string? POTypeName { get; set; }
public byte POTypeId { get; set; }
public long CanvassDetailId { get; set; }
public long RRDetailId { get; set; }
public long PRDetailId { get; set; }
public decimal Quantity { get; set; }
public decimal UnitPrice { get; set; }
public decimal GrossAmount { get; set; }
public string? DRNo { get; set; }
public string? CurrencyName { get; set; }
public decimal RemainingQty { get; set; }
public string? PaymentTerms { get; set; }
public bool IsCompleted { get; set; }
public string? PRCreatedDate { get; set; }
public string? PRApprover1 { get; set; }
public string? PRApprover2 { get; set; }
public string? CanvassCreatedDate { get; set; }
public string? CanvassSubmitedDate { get; set; }
public string? SuppBidDate { get; set; }
public string? CanvassApprovedDate { get; set; }
public string? POPreparationDate { get; set; }
public string? PoCreatedDate { get; set; }
public string? PoApprovedDate { get; set; }
public string? POForwardedDate { get; set; }
public string? ItemArrivedDate { get; set; }
public string? PONumber { get; set; }
public byte DashboardId { get; set; }
public int ForCanvassItem { get; set; }
public int WOSupResponseCount { get; set; }
public int PRNoCount { get; set; }
public int ForApprover1 { get; set; }
public int ForApprover2 { get; set; }
public int ForPOApproval { get; set; }
public int ForPO { get; set; }
public int ForPayment { get; set; }
public int ForDelivery { get; set; }
public int PartialReceived { get; set; }
public int SuppBidApproval { get; set; }
public int ApprovedPO { get; set; }
public int SupplierBid { get; set; }
public int DeniedItem { get; set; }
public int UOMId { get; set; }
public bool IsDenied { get; set; }
public decimal VatRate { get; set; }
public string? ErrMessage { get; set; }
public byte ErrCode { get; set; }
public bool DynamicBtn { get; set; }
public string? CanvassNo { get; set; }
public byte ItemLocalId { get; set; }
public byte ItemColorId { get; set; }
public byte ItemCategoryId { get; set; }
public bool IsApproved { get; set; }=false;
public int AlternativeOfferId { get; set; }
public byte AppsModuleId { get; set; }
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Dto.SMTP
{
public class SMTPCredentialDto
{
public int SMTPCredentialId { get; set; }
public byte SMTPTypeId { get; set; }
public string SMTPCredentialName { get; set; } = string.Empty;
public string SenderEmail { get; set; } = string.Empty;
public string SenderUserName { get; set; } = string.Empty;
public string SenderDisplayName { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public string Server { get; set; } = string.Empty;
public int OutgoingPort { get; set; }
public int IncomingPort { get; set; }
public bool IsActive { get; set; }
public string UserId { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,28 @@
using Microsoft.AspNetCore.Identity;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Entities.Account
{
public class ApplicationUser : IdentityUser
{
public string? FullName { get; set; }
public string? CreatedBy { get; set; }
public string? UpdatedBy { get; set; }
public string? Company { get; set; }
public int? DepartmentId { get; set; }
[ForeignKey("DepartmentId")]
public Departments? Department { get; set; }
public DateTime CreatedDate { get; set; }
public DateTime UpdatedDate { get; set; }
public string? ProfilePicture { get; set; }
public string? Address { get; set; }
public Attachment? Attachment { get; set; }
}
}

View File

@ -0,0 +1,24 @@
using CPRNIMS.Infrastructure.Entities.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Entities.Account
{
[Table("Attachments")]
public class Attachment : CommonProperties
{
public int Id { get; set; }
public string? AttachmentId { get; set; }
public string? URL { get; set; }
public string? FileName { get; set; }
public int? ExtensionId { get; set; }
public int? AttachmentTypeId { get; set; }
public AttachmentExtension? AttachmentExtention { get; set; }
public AttachmentFileType? AttachmentFileType { get; set; }
public ApplicationUser? ApplicationUser { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using CPRNIMS.Infrastructure.Entities.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Entities.Account
{
public class AttachmentExtension : CommonProperties
{
public int Id { get; set; }
public int ExtensionId { get; set; }
public string? ExtensionName { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using CPRNIMS.Infrastructure.Entities.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Entities.Account
{
public class AttachmentFileType : CommonProperties
{
public int Id { get; set; }
public int AttachmentTypeId { get; set; }
public string? AttachFileTypeName { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using CPRNIMS.Infrastructure.Entities.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Entities.Account
{
public class AuthorizeRoles : CommonProperties
{
[Key]
public int AuthorizeRoleId { get; set; }
public string? RoleId { get; set; }
public string? Name { get; set; }
public string? Controller { get; set; }
public bool IsActive { get; set; }
}
}

View File

@ -0,0 +1,28 @@
using CPRNIMS.Infrastructure.Entities.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Entities.Account
{
[Table("ControllerAccess")]
public class ControllerAccess : CommonProperties
{
[Key]
public int ContAccId { get; set; }
public int ControllerAccessId { get; set; }
public string UserId { get; set; } = string.Empty;
public int AccessTypeId { get; set; }
public string Action { get; set; } = string.Empty;
public string Controller { get; set; } = string.Empty;
public string AccessTypeName { get; set; } = string.Empty;
public string ElementMenuName { get; set; } = string.Empty;
public string ToolTipName { get; set; } = string.Empty;
public string IconClassName { get; set; } = string.Empty;
public string IconSpanName { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Entities.Account
{
[Table("Departments")]
public class Departments
{
[Key]
public int DepartmentId { get; set; }
public string? Department { get; set; }
public bool IsActive { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using CPRNIMS.Infrastructure.Entities.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Entities.Account
{
[Table("ForgotPassword")]
public class ForgotPassword : CommonProperties
{
public int Id { get; set; }
public string? ServerURIToken { get; set; }
public string? Token { get; set; }
public string? Email { get; set; }
public bool IsValid { get; set; }
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Entities.Account
{
[Table("UserRights")]
public class UserRights
{
[Key]
public int ContAccId { get; set; }
public long UserAccessId { get; set; }
public string? UserId { get; set; }
public int AccessTypeId { get; set; }
public string? AccessType { get; set; }
public string? Action { get; set; }
public string? Controller { get; set; }
public string? FullName { get; set; }
public string? Email { get; set; }
public string? PageName { get; set; }
public bool IsActive { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Entities.Canvass
{
public class AllForCanvass
{
[Key]
public long PRDetailsId { get; set; }
public long ItemNo { get; set; }
public long PRNo { get; set; }
public string? UserId { get; set; }
public string? FullName { get; set; }
public int SupplierId { get; set; }
}
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Entities.Canvass
{
public class BiddingItem
{
[Key]
public long PRDetailsId { get; set; }
public long ItemNo { get; set; }
public long PRNo { get; set; }
public long CanvassId { get; set; }
public bool IsActive { get; set; }
public bool SuggestedSupplier { get; set; }
public string? ItemSpecs { get; set; }
public string? ItemName { get; set; }
public string? ItemCategoryName { get; set; }
public decimal Qty { get; set; }
public long CanvassDetailId { get; set; }
public DateTime DateNeeded { get; set;}
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Entities.Canvass
{
[Table("Canvass")]
public class Canvass
{
[Key]
public long CanvassId { get; set; }
public int CanvassNo { get; set; }
public long PRNo { get; set; }
public bool IsActive { get; set; }
}
}

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Entities.Canvass
{
[Table("CanvassDetails")]
public class CanvassDetail
{
[Key]
public long CanvassDetailId { get; set; }
public long CanvassSupplierId { get; set; }
public long PRDetailsId { get; set; }
public decimal UnitPrice { get; set; }
public DateTime CommitmentDate { get; set; }
public string? Remarks { get; set; }
public string? Terms { get; set; }
public byte DFId { get; set; }
public bool SuggestedSupplier { get; set; }
public byte CurrencyId { get; set; }
public string? Manufacturer { get; set; }
public string? ItemNo { get; set; }
}
}

View File

@ -0,0 +1,38 @@
using CPRNIMS.Infrastructure.ViewModel.Canvass;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Linq;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Entities.Canvass
{
public class CanvassGroupByPRNo
{
[Key]
public long CanvassDetailId { get; set; }
public long PRDetailsId { get; set; }
public long PRNo { get; set; }
public string? EmailAddress { get; set; }
public string? SupplierName { get; set; }
public int SupplierId { get; set; }
public long ItemNo { get; set; }
public string? Manufacturer { get; set; }
public string? Terms { get; set; }
public string? Specification { get; set; }
public string? ItemName { get; set; }
public decimal UnitPrice { get; set; }
public decimal PreviousPrice { get; set; }
public bool VatInc { get; set; }
public decimal Qty { get; set; }
public long CanvassId { get; set; }
public long CanvassSupplierId { get; set; }
public bool SuggestedSupplier { get; set; }
public string? Remarks { get; set; }
public string? LeadTime { get; set; }
public string? PreviousPricePO { get; set; }
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Entities.Canvass
{
[Table("CanvassSuppliers")]
public class CanvassSupplier
{
[Key]
public long CanvassSupplierId { get; set; }
public long CanvassId { get; set; }
public byte FollowUpCount { get; set; }
public string? Token { get; set;}
public DateTime CreatedDate { get; set;}
public bool IsActive { get; set; }
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Entities.Canvass
{
public class ForCanvass
{
[Key]
public long ItemNo { get; set; }
public string? ItemName { get; set; }
public string? AggrePRNo { get; set; }
public string? AggreSupplierName { get; set; }
public string? AggreEmailAddress { get; set; }
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Entities.Canvass
{
public class ForCanvassFollowUp
{
[Key]
public long CanvassSupplierId { get; set; }
public string? Subject { get; set; }
public string? SenderEmail { get; set; }
public string? EmailAddress { get; set; }
public string? FormLink { get; set; }
public string? DisplayName { get; set; }
public string? CC { get; set; }
public string? Password { get; set; }
public string? Token { get; set; }
public string? Server { get; set; }
public string? UserName { get; set; }
public string? SupplierName { get; set; }
public string? Signature { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Entities.Canvass
{
public class ItemListWOEmail
{
[Key]
public long ItemNo { get; set; }
public long ItemCodeId { get; set; }
public long PRNo { get; set; }
public string? ItemCategoryName { get; set; }
public string? ItemDescription { get; set; }
public bool IsActive { get; set; }
}
}

View File

@ -0,0 +1,31 @@
using CPRNIMS.Infrastructure.Entities.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Entities.Canvass
{
public class MyPRWOCanvass : CommonProperties
{
[Key]
public long PRDetailsId { get; set; }
public string? Department { get; set; }
public string? ItemCategoryName { get; set; }
public string? ItemName { get; set; }
public string? Specification { get; set; }
public long ItemNo { get; set; }
public decimal Qty { get; set; }
public int UOMId { get; set; }
public string? NewPRNo { get; set; }
public string? UOMName { get; set; }
public string? ItemColorName { get; set; }
public string? ItemAttachPath { get; set; }
public long PRNo { get; set; }
public string? Remarks { get; set; }
public DateTime DateNeeded { get; set; }
public bool IsActive { get; set; }
}
}

View File

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CPRNIMS.Infrastructure.Entities.Canvass
{
public class PRList
{
[Key]
public long PRDetailsId { get; set; }
public string? Department { get; set; }
public string? ItemCategoryName { get; set; }
public string? ItemName { get; set; }
public string? ItemDescription { get; set; }
public long ItemNo { get; set; }
public decimal Qty { get; set; }
public string? NewPRNo { get; set; }
public string? UOMName { get; set; }
public string? ItemAttachPath { get; set; }
public long PRNo { get; set; }
public string? Remarks { get; set; }
public DateTime DateNeeded { get; set; }
public string? CreatedBy { get; set; }
public string? ApprovedBy { get; set; }
public string? AttestedBy { get; set; }
}
}

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