Add IsActive to group

This commit is contained in:
MahanCh
2025-08-05 16:05:17 +03:30
parent c7f7b17866
commit 20f208ac0e
6 changed files with 10247 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using _0_Framework.Application;
using _0_Framework.Domain; using _0_Framework.Domain;
namespace Company.Domain.PaymentInstrumentAgg; namespace Company.Domain.PaymentInstrumentAgg;
@@ -8,13 +9,20 @@ public class PaymentInstrumentGroup:EntityBase
public PaymentInstrumentGroup(string name) public PaymentInstrumentGroup(string name)
{ {
Name = name; Name = name;
IsActive = IsActive.True;
} }
public string Name { get; private set; } public string Name { get; private set; }
public IsActive IsActive { get; private set; }
public List<PaymentInstrument> PaymentInstruments { get; set; } public List<PaymentInstrument> PaymentInstruments { get; set; }
public void Edit(string name) public void Edit(string name)
{ {
Name = name; Name = name;
} }
public void DeActive()
{
IsActive = IsActive.False;
}
} }

View File

@@ -164,7 +164,8 @@ public class PaymentInstrumentApplication:IPaymentInstrumentApplication
{ {
return op.Failed("عنوان مورد نظر یافت نشد"); return op.Failed("عنوان مورد نظر یافت نشد");
} }
_paymentInstrumentGroupRepository.Remove(paymentInstrumentGroup);
paymentInstrumentGroup.DeActive();
await _paymentInstrumentGroupRepository.SaveChangesAsync(); await _paymentInstrumentGroupRepository.SaveChangesAsync();
return op.Succcedded(); return op.Succcedded();
} }

View File

@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class AddPaymentInstrumentGroupIsActive : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "IsActive",
table: "PaymentInstrumentGroups",
type: "int",
nullable: false,
defaultValue: 0);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IsActive",
table: "PaymentInstrumentGroups");
}
}
}

View File

@@ -4343,6 +4343,9 @@ namespace CompanyManagment.EFCore.Migrations
b.Property<DateTime>("CreationDate") b.Property<DateTime>("CreationDate")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<int>("IsActive")
.HasColumnType("int");
b.Property<string>("Name") b.Property<string>("Name")
.IsRequired() .IsRequired()
.HasMaxLength(120) .HasMaxLength(120)

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.InfraStructure; using _0_Framework.InfraStructure;
using Company.Domain.PaymentInstrumentAgg; using Company.Domain.PaymentInstrumentAgg;
using CompanyManagment.App.Contracts.PaymentInstrument; using CompanyManagment.App.Contracts.PaymentInstrument;
@@ -20,7 +21,7 @@ public class PaymentInstrumentGroupRepository : RepositoryBase<long, PaymentInst
public async Task<List<PaymentInstrumentGroupsViewModel>> GetList() public async Task<List<PaymentInstrumentGroupsViewModel>> GetList()
{ {
return await _context.PaymentInstrumentGroups.AsNoTracking() return await _context.PaymentInstrumentGroups.Where(x=>x.IsActive == IsActive.True).AsNoTracking()
.Select(x => new PaymentInstrumentGroupsViewModel() .Select(x => new PaymentInstrumentGroupsViewModel()
{ {
Name = x.Name, Name = x.Name,