Added created by and created at in expenses model

This commit is contained in:
ashutosh.nehete 2025-07-19 15:00:21 +05:30
parent 0b1d2669ca
commit cc2e545442
4 changed files with 4281 additions and 0 deletions

View File

@ -0,0 +1,63 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Marco.Pms.DataAccess.Migrations
{
/// <inheritdoc />
public partial class Added_CreatedBy_And_CareatedAt_In_Expense : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "CreatedAt",
table: "Expenses",
type: "datetime(6)",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<Guid>(
name: "CreatedById",
table: "Expenses",
type: "char(36)",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
collation: "ascii_general_ci");
migrationBuilder.CreateIndex(
name: "IX_Expenses_CreatedById",
table: "Expenses",
column: "CreatedById");
migrationBuilder.AddForeignKey(
name: "FK_Expenses_Employees_CreatedById",
table: "Expenses",
column: "CreatedById",
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Expenses_Employees_CreatedById",
table: "Expenses");
migrationBuilder.DropIndex(
name: "IX_Expenses_CreatedById",
table: "Expenses");
migrationBuilder.DropColumn(
name: "CreatedAt",
table: "Expenses");
migrationBuilder.DropColumn(
name: "CreatedById",
table: "Expenses");
}
}
}

View File

@ -1297,6 +1297,12 @@ namespace Marco.Pms.DataAccess.Migrations
b.Property<double>("Amount") b.Property<double>("Amount")
.HasColumnType("double"); .HasColumnType("double");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)");
b.Property<Guid>("CreatedById")
.HasColumnType("char(36)");
b.Property<string>("Description") b.Property<string>("Description")
.IsRequired() .IsRequired()
.HasColumnType("longtext"); .HasColumnType("longtext");
@ -1346,6 +1352,8 @@ namespace Marco.Pms.DataAccess.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("CreatedById");
b.HasIndex("ExpensesTypeId"); b.HasIndex("ExpensesTypeId");
b.HasIndex("PaidById"); b.HasIndex("PaidById");
@ -3651,6 +3659,12 @@ namespace Marco.Pms.DataAccess.Migrations
modelBuilder.Entity("Marco.Pms.Model.Expenses.Expenses", b => modelBuilder.Entity("Marco.Pms.Model.Expenses.Expenses", b =>
{ {
b.HasOne("Marco.Pms.Model.Employees.Employee", "CreatedBy")
.WithMany()
.HasForeignKey("CreatedById")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Marco.Pms.Model.Master.ExpensesTypeMaster", "ExpensesType") b.HasOne("Marco.Pms.Model.Master.ExpensesTypeMaster", "ExpensesType")
.WithMany() .WithMany()
.HasForeignKey("ExpensesTypeId") .HasForeignKey("ExpensesTypeId")
@ -3687,6 +3701,8 @@ namespace Marco.Pms.DataAccess.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("CreatedBy");
b.Navigation("ExpensesType"); b.Navigation("ExpensesType");
b.Navigation("PaidBy"); b.Navigation("PaidBy");

View File

@ -30,7 +30,13 @@ namespace Marco.Pms.Model.Expenses
[ValidateNever] [ValidateNever]
[ForeignKey("PaidById")] [ForeignKey("PaidById")]
public Employee? PaidBy { get; set; } public Employee? PaidBy { get; set; }
public Guid CreatedById { get; set; }
[ValidateNever]
[ForeignKey("CreatedById")]
public Employee? CreatedBy { get; set; }
public DateTime TransactionDate { get; set; } public DateTime TransactionDate { get; set; }
public DateTime CreatedAt { get; set; }
public string? TransactionId { get; set; } public string? TransactionId { get; set; }
public string Description { get; set; } = string.Empty; public string Description { get; set; } = string.Empty;
public string? Location { get; set; } public string? Location { get; set; }