Saving the tenant enquire in before payment
This commit is contained in:
parent
d29b061799
commit
ac4da0c930
@ -143,7 +143,7 @@ namespace Marco.Pms.DataAccess.Data
|
|||||||
public DbSet<PaymentAdjustmentHead> PaymentAdjustmentHeads { get; set; }
|
public DbSet<PaymentAdjustmentHead> PaymentAdjustmentHeads { get; set; }
|
||||||
|
|
||||||
public DbSet<PaymentDetail> PaymentDetails { get; set; }
|
public DbSet<PaymentDetail> PaymentDetails { get; set; }
|
||||||
|
public DbSet<TenantEnquire> TenantEnquires { get; set; }
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
|
|||||||
6772
Marco.Pms.DataAccess/Migrations/20251027103648_Added_TenantEnquire_Table.Designer.cs
generated
Normal file
6772
Marco.Pms.DataAccess/Migrations/20251027103648_Added_TenantEnquire_Table.Designer.cs
generated
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,62 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Marco.Pms.DataAccess.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Added_TenantEnquire_Table : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "TenantEnquires",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||||
|
FirstName = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
LastName = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
OrganizationName = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Email = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
ContactNumber = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
BillingAddress = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
OrganizationSize = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
IndustryId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||||
|
Reference = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_TenantEnquires", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_TenantEnquires_Industries_IndustryId",
|
||||||
|
column: x => x.IndustryId,
|
||||||
|
principalTable: "Industries",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_TenantEnquires_IndustryId",
|
||||||
|
table: "TenantEnquires",
|
||||||
|
column: "IndustryId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "TenantEnquires");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4622,6 +4622,54 @@ namespace Marco.Pms.DataAccess.Migrations
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Marco.Pms.Model.TenantModels.TenantEnquire", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("char(36)");
|
||||||
|
|
||||||
|
b.Property<string>("BillingAddress")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("ContactNumber")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("FirstName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<Guid>("IndustryId")
|
||||||
|
.HasColumnType("char(36)");
|
||||||
|
|
||||||
|
b.Property<string>("LastName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("OrganizationName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("OrganizationSize")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("Reference")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("IndustryId");
|
||||||
|
|
||||||
|
b.ToTable("TenantEnquires");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Marco.Pms.Model.TenantModels.TenantSubscriptions", b =>
|
modelBuilder.Entity("Marco.Pms.Model.TenantModels.TenantSubscriptions", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
@ -6584,6 +6632,17 @@ namespace Marco.Pms.DataAccess.Migrations
|
|||||||
b.Navigation("TenantStatus");
|
b.Navigation("TenantStatus");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Marco.Pms.Model.TenantModels.TenantEnquire", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Marco.Pms.Model.Master.Industry", "Industry")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("IndustryId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Industry");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Marco.Pms.Model.TenantModels.TenantSubscriptions", b =>
|
modelBuilder.Entity("Marco.Pms.Model.TenantModels.TenantSubscriptions", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Marco.Pms.Model.Employees.Employee", "CreatedBy")
|
b.HasOne("Marco.Pms.Model.Employees.Employee", "CreatedBy")
|
||||||
|
|||||||
15
Marco.Pms.Model/Dtos/Tenant/TenantEnquireDto.cs
Normal file
15
Marco.Pms.Model/Dtos/Tenant/TenantEnquireDto.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
namespace Marco.Pms.Model.Dtos.Tenant
|
||||||
|
{
|
||||||
|
public class TenantEnquireDto
|
||||||
|
{
|
||||||
|
public required string FirstName { get; set; }
|
||||||
|
public required string LastName { get; set; }
|
||||||
|
public required string OrganizationName { get; set; }
|
||||||
|
public required string Email { get; set; }
|
||||||
|
public required string ContactNumber { get; set; }
|
||||||
|
public required string BillingAddress { get; set; }
|
||||||
|
public required string OrganizationSize { get; set; }
|
||||||
|
public required Guid IndustryId { get; set; }
|
||||||
|
public required string Reference { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
24
Marco.Pms.Model/TenantModels/TenantEnquire.cs
Normal file
24
Marco.Pms.Model/TenantModels/TenantEnquire.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using Marco.Pms.Model.Master;
|
||||||
|
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace Marco.Pms.Model.TenantModels
|
||||||
|
{
|
||||||
|
public class TenantEnquire
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public string FirstName { get; set; } = default!;
|
||||||
|
public string LastName { get; set; } = default!;
|
||||||
|
public string OrganizationName { get; set; } = default!;
|
||||||
|
public string Email { get; set; } = default!;
|
||||||
|
public string ContactNumber { get; set; } = default!;
|
||||||
|
public string BillingAddress { get; set; } = default!;
|
||||||
|
public string OrganizationSize { get; set; } = default!;
|
||||||
|
public Guid IndustryId { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey("IndustryId")]
|
||||||
|
[ValidateNever]
|
||||||
|
public Industry? Industry { get; set; }
|
||||||
|
public string Reference { get; set; } = default!;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -817,7 +817,6 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
return Ok(ApiResponse<object>.SuccessResponse(response, "Tenant updated successfully", 200));
|
return Ok(ApiResponse<object>.SuccessResponse(response, "Tenant updated successfully", 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// DELETE api/<TenantController>/5
|
// DELETE api/<TenantController>/5
|
||||||
[HttpDelete("delete/{id}")]
|
[HttpDelete("delete/{id}")]
|
||||||
public async Task<IActionResult> DeleteTenant(Guid id, [FromQuery] bool isActive = false)
|
public async Task<IActionResult> DeleteTenant(Guid id, [FromQuery] bool isActive = false)
|
||||||
@ -913,6 +912,43 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
return Ok(ApiResponse<object>.SuccessResponse(responseData, successMessage, 200));
|
return Ok(ApiResponse<object>.SuccessResponse(responseData, successMessage, 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AllowAnonymous]
|
||||||
|
[HttpPost("self/create")]
|
||||||
|
public async Task<IActionResult> SelfRegistrationTenant([FromBody] TenantEnquireDto model)
|
||||||
|
{
|
||||||
|
// Log the start of the registration attempt
|
||||||
|
_logger.LogInfo("Self-registration request received at {Timestamp}.", DateTime.UtcNow);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Create db context asynchronously for optimized resource use
|
||||||
|
await using var context = await _dbContextFactory.CreateDbContextAsync();
|
||||||
|
|
||||||
|
// Map DTO to domain model and assign new Guid
|
||||||
|
var tenantEnquire = _mapper.Map<TenantEnquire>(model);
|
||||||
|
tenantEnquire.Id = Guid.NewGuid();
|
||||||
|
|
||||||
|
// Add new tenant enquiry to the database
|
||||||
|
await context.TenantEnquires.AddAsync(tenantEnquire);
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
|
||||||
|
// Log successful registration
|
||||||
|
_logger.LogInfo("Tenant enquiry created successfully. ID: {TenantEnquireId}", tenantEnquire.Id);
|
||||||
|
|
||||||
|
// Return success response with proper status code and user information
|
||||||
|
return Ok(ApiResponse<object>.SuccessResponse(model, "Tenant enquiry added successfully.", 201));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// Log error with detailed exception information at Error level
|
||||||
|
_logger.LogError(ex, "Error occurred during self-registration: {Message}", ex.Message);
|
||||||
|
|
||||||
|
// Return standardized error response to the client
|
||||||
|
var errorResponse = ApiResponse<object>.ErrorResponse("Failed to add tenant enquiry, please try again later.", "Failed to add tenant enquiry, please try again later.", 500);
|
||||||
|
|
||||||
|
return StatusCode(500, errorResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@ -61,6 +61,7 @@ namespace Marco.Pms.Services.MappingProfiles
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ======================================================= Tenant =======================================================
|
#region ======================================================= Tenant =======================================================
|
||||||
|
CreateMap<TenantEnquireDto, TenantEnquire>();
|
||||||
CreateMap<Tenant, TenantVM>();
|
CreateMap<Tenant, TenantVM>();
|
||||||
CreateMap<Tenant, TenantListVM>();
|
CreateMap<Tenant, TenantListVM>();
|
||||||
CreateMap<Tenant, TenantDetailsVM>();
|
CreateMap<Tenant, TenantDetailsVM>();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user