using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace ODCWeb.Models { // Main BQ Template public class StandaloneBQTemplate { [Key] public int StandaloneBQTemplateId { get; set; } [Required] [Display(Name = "Template Name")] [StringLength(100)] public string TemplateName { get; set; } // e.g., "Apartment BQ", "Villa BQ" [Display(Name = "Description")] [StringLength(500)] public string? TemplateDescription { get; set; } [Display(Name = "Created Date")] public DateTime CreatedDate { get; set; } [Display(Name = "Created By")] [StringLength(100)] public string? CreatedBy { get; set; } [Display(Name = "Active")] public bool IsTemplateActive { get; set; } // Navigation Properties public virtual ICollection? StandaloneBQSections { get; set; } public virtual ICollection? StandaloneBQOutputs { get; set; } } // BQ Sections (e.g., "BILL No.1 - Preliminaries", "BILL No.2 - Ground Floor") public class StandaloneBQSection { [Key] public int StandaloneBQSectionId { get; set; } [Required] [ForeignKey("StandaloneBQTemplate")] public int StandaloneBQTemplateId { get; set; } [Required] [Display(Name = "Section Title")] [StringLength(200)] public string SectionTitle { get; set; } // e.g., "BILL No.1 - Preliminaries" [Display(Name = "Section Notes")] [StringLength(1000)] public string? SectionNotes { get; set; } [Display(Name = "Order")] public int SectionOrder { get; set; } // Navigation Properties public virtual StandaloneBQTemplate? StandaloneBQTemplate { get; set; } public virtual ICollection? StandaloneBQItems { get; set; } } // Individual BQ Items within sections public class StandaloneBQItem { [Key] public int StandaloneBQItemId { get; set; } [Required] [ForeignKey("StandaloneBQSection")] public int StandaloneBQSectionId { get; set; } [Required] [Display(Name = "Item Name")] [StringLength(200)] public string BQItemTitle { get; set; } // e.g., "Ground Floor Walling" [Display(Name = "Item Description")] [StringLength(1000)] public string? BQItemNotes { get; set; } [Display(Name = "Formula Expression")] [StringLength(2000)] public string? BQFormulaExpression { get; set; } // e.g., "I16:TA45I + I17:TA46I" [Display(Name = "Unit of Measure")] [StringLength(20)] public string? BQUnitMeasure { get; set; } // e.g., "m²", "m³", "nr" [Display(Name = "Rate")] [Column(TypeName = "decimal(18,2)")] public decimal? BQItemRate { get; set; } [Display(Name = "Order")] public int ItemOrder { get; set; } // Navigation Properties public virtual StandaloneBQSection? StandaloneBQSection { get; set; } } // For generated BQ output storage public class StandaloneBQOutput { [Key] public int StandaloneBQOutputId { get; set; } [Required] [ForeignKey("ODCProject")] public int ProjectId { get; set; } [Required] [ForeignKey("StandaloneBQTemplate")] public int StandaloneBQTemplateId { get; set; } [Required] [Display(Name = "BQ Generation Name")] [StringLength(200)] public string BQGenerationName { get; set; } [Display(Name = "Generated Date")] public DateTime GeneratedDate { get; set; } [Display(Name = "Generated By")] [StringLength(100)] public string? GeneratedBy { get; set; } [Display(Name = "BQ Output Data")] public string? BQOutputData { get; set; } // JSON serialized BQ data [Display(Name = "Total Amount")] [Column(TypeName = "decimal(18,2)")] public decimal? TotalAmount { get; set; } [Display(Name = "Status")] [StringLength(50)] public string? Status { get; set; } // Draft, Final, Approved, etc. // Navigation Properties public virtual ODCProject? ODCProject { get; set; } public virtual StandaloneBQTemplate? StandaloneBQTemplate { get; set; } } // DTO/ViewModel for BQ Generation Results public class BQGenerationResult { public string ItemType { get; set; } = ""; // "Section" or "Item" public string TaskName { get; set; } = ""; public string PropertyName { get; set; } = ""; public double? PropertyValue { get; set; } public decimal Rate { get; set; } public decimal Balance { get; set; } public string UnitType { get; set; } = ""; public string SectionName { get; set; } = ""; public int SortOrder { get; set; } } // DTO for Template Structure (for API responses) public class TemplateStructureDto { public int FloorId { get; set; } public string FloorName { get; set; } = ""; public List Actions { get; set; } = new(); } public class TemplateActionDto { public int ActionId { get; set; } public string ActionName { get; set; } = ""; public List Tasks { get; set; } = new(); } public class TemplateTaskDto { public int TaskId { get; set; } public string TaskName { get; set; } = ""; public List Properties { get; set; } = new(); } public class TemplatePropertyDto { public int PropertyId { get; set; } public string PropertyName { get; set; } = ""; } // ViewModel for BQ Template Overview public class BQTemplateOverviewViewModel { public StandaloneBQTemplate Template { get; set; } = new(); public List Sections { get; set; } = new(); public int TotalItems { get; set; } public DateTime LastModified { get; set; } } public class BQSectionOverview { public StandaloneBQSection Section { get; set; } = new(); public int ItemCount { get; set; } public List Items { get; set; } = new(); } // ViewModel for Formula Builder public class FormulaBuilderViewModel { public StandaloneBQItem BQItem { get; set; } = new(); public StandaloneBQSection Section { get; set; } = new(); public StandaloneBQTemplate Template { get; set; } = new(); public List TemplateStructure { get; set; } = new(); public string FormulaSyntaxHelp { get; set; } = ""; } // Enum for BQ Output Status public enum BQOutputStatus { Draft, InReview, Final, Approved, Rejected, Archived } // Enum for Unit Types public enum BQUnitType { [Display(Name = "m² (Square Meters)")] SquareMeters, [Display(Name = "m³ (Cubic Meters)")] CubicMeters, [Display(Name = "m (Linear Meters)")] LinearMeters, [Display(Name = "nr (Number/Items)")] Number, [Display(Name = "kg (Kilograms)")] Kilograms, [Display(Name = "sum (Lump Sum)")] LumpSum, [Display(Name = "hrs (Hours)")] Hours, [Display(Name = "days (Days)")] Days } }