...
This commit is contained in:
69
Back/Controllers/Warehouse/ReceiptController.cs
Normal file
69
Back/Controllers/Warehouse/ReceiptController.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using Back.Data.Models;
|
||||
using Back.Services;
|
||||
using Back.Services.Warehouse;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Shared.DTOs.Warehouse;
|
||||
using Shared.Enums;
|
||||
using System.ComponentModel.Design;
|
||||
|
||||
namespace Back.Controllers.Warehouse
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
public class ReceiptController : ControllerBase
|
||||
{
|
||||
private readonly ReceiptService _receiptService;
|
||||
private readonly servUser _servUser;
|
||||
[HttpGet("{ItemID}")]
|
||||
public async Task<IActionResult> Get(int ItemID)
|
||||
{
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
var CompanyID = user.RolUsers.First().CompanyID;
|
||||
return Ok(await _receiptService.Get(ItemID, CompanyID));
|
||||
}
|
||||
[HttpGet("AllReceip")]
|
||||
public async Task<IActionResult> GetAll(TypeReceipt? Type = null, int CODID = 0)
|
||||
{
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
var CompanyID = user.RolUsers.First().CompanyID;
|
||||
return Ok(await _receiptService.GetAll(CompanyID, Type, CODID));
|
||||
}
|
||||
[HttpPost("ADD")]
|
||||
public async Task<IActionResult> AddReceipt(ReceiptDto item)
|
||||
{
|
||||
// validate ADD
|
||||
var newmodel = await _receiptService.ADD(item);
|
||||
if (newmodel != null) return Ok(newmodel);
|
||||
else return BadRequest(new List<string> { "خطا در صدور" });
|
||||
}
|
||||
|
||||
[HttpPut("Update")]
|
||||
public async Task<IActionResult> UpdateReceipt(ReceiptDto item)
|
||||
{
|
||||
// validate Update
|
||||
var Updatemodel = await _receiptService.Update(item);
|
||||
if (Updatemodel != null) return Ok(Updatemodel);
|
||||
else return BadRequest(new List<string> { "خطا در ویرایش" });
|
||||
}
|
||||
[HttpDelete("{ItemID}")]
|
||||
public async Task<IActionResult> DeleteReceipt(int ItemID)
|
||||
{
|
||||
// validate Delete
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
var CompanyID = user.RolUsers.First().CompanyID;
|
||||
|
||||
var Deletemodel = await _receiptService.Delete(ItemID, CompanyID);
|
||||
if (Deletemodel) return Ok();
|
||||
else return BadRequest(new List<string> { "خطا در حذف" });
|
||||
}
|
||||
}
|
||||
}
|
65
Back/Controllers/Warehouse/RemittanceController.cs
Normal file
65
Back/Controllers/Warehouse/RemittanceController.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using Back.Services.Warehouse;
|
||||
using Back.Services;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Shared.DTOs.Warehouse;
|
||||
using Shared.Enums;
|
||||
|
||||
namespace Back.Controllers.Warehouse
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class RemittanceController : ControllerBase
|
||||
{
|
||||
private readonly RemittanceService _treanceService;
|
||||
private readonly servUser _servUser;
|
||||
[HttpGet("{ItemID}")]
|
||||
public async Task<IActionResult> Get(int ItemID)
|
||||
{
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
var CompanyID = user.RolUsers.First().CompanyID;
|
||||
return Ok(await _treanceService.Get(ItemID, CompanyID));
|
||||
}
|
||||
[HttpGet("AllRemittance")]
|
||||
public async Task<IActionResult> GetAll(TypeRemittance? Type = null, int CODID = 0)
|
||||
{
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
var CompanyID = user.RolUsers.First().CompanyID;
|
||||
return Ok(await _treanceService.GetAll(CompanyID, Type, CODID));
|
||||
}
|
||||
[HttpPost("ADD")]
|
||||
public async Task<IActionResult> Add(RemittanceDto item)
|
||||
{
|
||||
// validate ADD
|
||||
var newmodel = await _treanceService.ADD(item);
|
||||
if (newmodel != null) return Ok(newmodel);
|
||||
else return BadRequest(new List<string> { "خطا در صدور" });
|
||||
}
|
||||
|
||||
[HttpPut("Update")]
|
||||
public async Task<IActionResult> Update(RemittanceDto item)
|
||||
{
|
||||
// validate Update
|
||||
var Updatemodel = await _treanceService.Update(item);
|
||||
if (Updatemodel != null) return Ok(Updatemodel);
|
||||
else return BadRequest(new List<string> { "خطا در ویرایش" });
|
||||
}
|
||||
[HttpDelete("{ItemID}")]
|
||||
public async Task<IActionResult> Delete(int ItemID)
|
||||
{
|
||||
// validate Delete
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
var CompanyID = user.RolUsers.First().CompanyID;
|
||||
|
||||
var Deletemodel = await _treanceService.Delete(ItemID, CompanyID);
|
||||
if (Deletemodel) return Ok();
|
||||
else return BadRequest(new List<string> { "خطا در حذف" });
|
||||
}
|
||||
}
|
||||
}
|
24
Back/Controllers/Warehouse/WarehouseController.cs
Normal file
24
Back/Controllers/Warehouse/WarehouseController.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Back.Services;
|
||||
using Back.Services.Warehouse;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Back.Controllers.Warehouse
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class WarehouseController : ControllerBase
|
||||
{
|
||||
private readonly WarehouseService _warehouseService;
|
||||
private readonly servUser _servUser;
|
||||
public async Task<IActionResult> Circulation(string date = "", int CODID = 0, int PageIndex = 1, int PageSize = 5)
|
||||
{
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
var CompanyID = user.RolUsers.First().CompanyID;
|
||||
return Ok(await _warehouseService.Circulation(CompanyID,date,CODID));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
2074
Back/Migrations/20250111074837_warehousenew1.Designer.cs
generated
Normal file
2074
Back/Migrations/20250111074837_warehousenew1.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
87
Back/Migrations/20250111074837_warehousenew1.cs
Normal file
87
Back/Migrations/20250111074837_warehousenew1.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Back.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class warehousenew1 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Receipts",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
CODID = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false),
|
||||
Date = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
ForSale = table.Column<bool>(type: "bit", nullable: false),
|
||||
Type = table.Column<int>(type: "int", nullable: false),
|
||||
info = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Receipts", x => x.ID);
|
||||
table.ForeignKey(
|
||||
name: "FK_Receipts_CODItems_CODID",
|
||||
column: x => x.CODID,
|
||||
principalTable: "CODItems",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Remittances",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
CODID = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false),
|
||||
Date = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Type = table.Column<int>(type: "int", nullable: false),
|
||||
info = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Remittances", x => x.ID);
|
||||
table.ForeignKey(
|
||||
name: "FK_Remittances_CODItems_CODID",
|
||||
column: x => x.CODID,
|
||||
principalTable: "CODItems",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Receipts_CODID",
|
||||
table: "Receipts",
|
||||
column: "CODID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Remittances_CODID",
|
||||
table: "Remittances",
|
||||
column: "CODID");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Receipts");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Remittances");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,7 @@ using Back.Data.Contracts;
|
||||
using Back.Data.Infrastructure.Repository;
|
||||
using Back.Features;
|
||||
using Back.Services;
|
||||
using Back.Services.Warehouse;
|
||||
using Back.Validations;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
@@ -83,6 +84,9 @@ builder.Services.AddScoped<ServOrders>();
|
||||
builder.Services.AddScoped<ServPricing>();
|
||||
builder.Services.AddScoped<ServWalt>();
|
||||
builder.Services.AddScoped<AUInvoicePayValidation>();
|
||||
builder.Services.AddScoped<ReceiptService>();
|
||||
builder.Services.AddScoped<RemittanceService>();
|
||||
builder.Services.AddScoped<WarehouseService>();
|
||||
builder.Services.AddScoped<servReport>();
|
||||
builder.Services.AddScoped(c => new mpNuget.RestClient("09119660045", "C54S2"));
|
||||
|
||||
|
@@ -1,7 +1,9 @@
|
||||
using Back.Data.Contracts;
|
||||
using Back.Common;
|
||||
using Back.Data.Contracts;
|
||||
using Back.Data.Models.Warehouse;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.OpenApi.Extensions;
|
||||
using Shared.DTOs;
|
||||
using Shared.DTOs.Warehouse;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -21,7 +23,7 @@ namespace Back.Services.Warehouse
|
||||
_RemittanceRepo = remittanceRepo;
|
||||
_ReceiptRepo = receiptRepo;
|
||||
}
|
||||
public async Task<List<CirculationDto>> Circulation(int CompanyID,string date="",int CODID=0)
|
||||
public async Task<PagingDto<CirculationDto>> Circulation(int CompanyID,string date="",int CODID=0,int PageIndex=1,int PageSize=5)
|
||||
{
|
||||
var RequestRemittance = _RemittanceRepo.Get(w => w.cODItem.CompanyID == CompanyID)
|
||||
.Select(s=>new CirculationDto
|
||||
@@ -57,9 +59,14 @@ namespace Back.Services.Warehouse
|
||||
if (CODID != 0)
|
||||
RequestReceipt = RequestReceipt.Where(w => w.CODID == CODID);
|
||||
|
||||
var list = await RequestReceipt.ToListAsync();
|
||||
list.AddRange(await RequestRemittance.ToListAsync());
|
||||
return list.OrderByDescending(o=>o.Date).ToList();
|
||||
return await RequestReceipt.Union(RequestRemittance).OrderByDescending(o => o.Date).Paging(PageIndex, PageSize);
|
||||
//var list = await RequestReceipt.ToListAsync();
|
||||
//list.AddRange(await RequestRemittance.ToListAsync());
|
||||
//return await list.OrderByDescending(o=>o.Date).AsQueryable().Paging(PageIndex, PageSize);
|
||||
}
|
||||
public async Task Inventory(int CompanyID,int CODID)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user