using System; using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity.ModelConfiguration; namespace CAPI.Custom.Entities { public class Quote : SurfacePublishedEntity { #region Quote public int? CreatedBy { get; set; } = 0; public string CreatedByDisplay { get; set; } = string.Empty; public DateTime? CreatedDate { get; set; } = DateTime.Now; public bool? IsLocked { get; set; } = false; public int? LastUpdatedBy { get; set; } = 0; public DateTime? LastUpdatedDate { get; set; } = DateTime.Now; public DateTime? Date { get; set; } public int? StatusId { get; set; } = CAPI.Custom.QuoteStatus.Draft; public string LastUpdatedByDisplay { get; set; } = string.Empty; public DateTime? Month { get; set; } = DateTime.Today; public string Number { get; set; } = string.Empty; #endregion #region Acceptance & Delivery Info public DateTime? AcceptedDate { get; set; } public string DeliveryCity { get; set; } = string.Empty; public string DeliveryCountry { get; set; } = string.Empty; public DateTime? DeliveryEstimatedDate { get; set; } public string DeliveryInstructions { get; set; } = string.Empty; public string DeliveryPONumber { get; set; } = string.Empty; public string DeliveryPostalCode { get; set; } = string.Empty; public string DeliveryState { get; set; } = string.Empty; public string DeliveryStreet { get; set; } = string.Empty; public string DeliverySuburb { get; set; } = string.Empty; #endregion private string _customerContactName = string.Empty; public string CustomerContactName { get { return _customerContactName.NullOrEmptyCoalesce(ContactName2, ContactNameCopy); } set { _customerContactName = ContactName2 = ContactNameCopy = value; } } private string _customerTradingName = string.Empty; public string CustomerTradingName { get { return _customerTradingName.NullOrEmptyCoalesce(CustomerTradingName2, CustomerTradingNameCopy); } set { _customerTradingName = CustomerTradingName2 = CustomerTradingNameCopy = value; } } #region Customer Details public string CustomerCode { get; set; } = string.Empty; public string CustomerCurrency { get; set; } = string.Empty; public string CustomerIsParent { get; set; } = string.Empty; public string CustomerLegalEntity { get; set; } = string.Empty; public string CustomerParentCompany { get; set; } = string.Empty; public string CustomerPhysicalAddress { get; set; } = string.Empty; public string CustomerPostalAddress { get; set; } = string.Empty; public string CustomerType { get; set; } = string.Empty; public string CustomerVATNumber { get; set; } = string.Empty; public string CustomerVATRate { get; set; } = string.Empty; public string CustomerContactEmail { get; set; } = string.Empty; public string CustomerDefaultDiscount { get; set; } = string.Empty; public string CustomerDefaultMargin { get; set; } = string.Empty; public string CustomerContactMobileNumber { get; set; } = string.Empty; public string CustomerContactTelephone { get; set; } = string.Empty; #endregion #region Quote Final public string FinalNotes { get; set; } = string.Empty; public decimal? FinalSubtotalexclVAT { get; set; } = 0; public decimal? FinalTotalinclVAT { get; set; } = 0; public decimal? FinalTotalWeightKG { get; set; } = 0; public decimal? FinalVAT { get; set; } = 0; #endregion #region Quote Items public string ItemsDefaultMargin { get; set; } = string.Empty; public decimal? ItemsGrossProfit { get; set; } = 0; public string ItemsNotes { get; set; } = string.Empty; public decimal? ItemsSubtotalexclVAT { get; set; } = 0; public string ItemsSupplyTypes { get; set; } = string.Empty; public decimal? ItemsTotalCost { get; set; } = 0; public decimal? ItemsTotalinclVAT { get; set; } = 0; public decimal? ItemsTotalMargin { get; set; } = 0; public decimal? ItemsTotalWeightKG { get; set; } = 0; public decimal? ItemsVAT { get; set; } = 0; #endregion #region public SurfaceLookup QuoteStatus { get; set; } #endregion #region Hidden protected protected string LastUpdated { get; set; } = string.Empty; protected string ContactName2 { get; set; } = string.Empty; protected string ContactNameCopy { get; set; } = string.Empty; protected string CustomerTradingName2 { get; set; } = string.Empty; protected string CustomerTradingNameCopy { get; set; } = string.Empty; protected string QuoteEnquiryItems_QuoteEnquiryItems_QuoteRequestItemsUploadList { get; set; } = string.Empty; protected string QuoteFinal_QuoteFinalItems_QuoteFinalItemsFinaliseQuote { get; set; } = string.Empty; protected string QuoteFinal_QuoteFinalItems_QuoteFinalItemsRefresh { get; set; } = string.Empty; protected string QuoteItems_QuoteItems_QuoteItemsDefaultMarginApplyToAll { get; set; } = string.Empty; protected string QuoteItems_QuoteItems_QuoteItemsHideZeroQuantities { get; set; } = string.Empty; #endregion public class Mapping : EntityTypeConfiguration { public Mapping() { ToTable("publ_Quotes"); HasKey(p => p.recId); Property(p => p.AcceptedDate).HasColumnName("AcceptedDate"); Property(p => p.CreatedBy).HasColumnName("CreatedBy"); Property(p => p.CreatedByDisplay).HasColumnName("CreatedByDisplay"); Property(p => p.CreatedDate).HasColumnName("CreatedDate"); Property(p => p.DeliveryCity).HasColumnName("Delivery_City"); Property(p => p.DeliveryCountry).HasColumnName("Delivery_Country"); Property(p => p.DeliveryEstimatedDate).HasColumnName("Delivery_EstimatedDate"); Property(p => p.DeliveryInstructions).HasColumnName("Delivery_Instructions"); Property(p => p.DeliveryPONumber).HasColumnName("Delivery_PONumber"); Property(p => p.DeliveryPostalCode).HasColumnName("Delivery_PostalCode"); Property(p => p.DeliveryState).HasColumnName("Delivery_State"); Property(p => p.DeliveryStreet).HasColumnName("Delivery_Street"); Property(p => p.DeliverySuburb).HasColumnName("Delivery_Suburb"); Property(p => p.isActive).HasColumnName("isActive"); Property(p => p.IsLocked).HasColumnName("IsLocked").HasDatabaseGeneratedOption(DatabaseGeneratedOption.Computed); Property(p => p.itemID).HasColumnName("itemID"); Property(p => p.LastUpdatedBy).HasColumnName("LastUpdatedBy"); Property(p => p.LastUpdatedDate).HasColumnName("LastUpdatedDate"); Property(p => p.CustomerContactName).HasColumnName("None_QuoteInformation_ContactName"); Property(p => p.CustomerTradingName).HasColumnName("None_QuoteInformation_CustomerTradingName"); Property(p => p.Date).HasColumnName("None_QuoteInformation_QuoteDate"); Property(p => p.LastUpdated).HasColumnName("None_QuoteInformation_QuoteLastUpdated"); Property(p => p.StatusId).HasColumnName("None_QuoteInformation_QuoteStatus"); Property(p => p.LastUpdatedByDisplay).HasColumnName("None_QuoteInformation_QuoteUpdatedBy"); Property(p => p.ContactNameCopy).HasColumnName("QuoteCustomerDetails_QuoteCustomerDetails_ContactNameCopy"); Property(p => p.CustomerCode).HasColumnName("QuoteCustomerDetails_QuoteCustomerDetails_CustomerCode"); Property(p => p.CustomerCurrency).HasColumnName("QuoteCustomerDetails_QuoteCustomerDetails_CustomerCurrency"); Property(p => p.CustomerIsParent).HasColumnName("QuoteCustomerDetails_QuoteCustomerDetails_CustomerIsParent"); Property(p => p.CustomerLegalEntity).HasColumnName("QuoteCustomerDetails_QuoteCustomerDetails_CustomerLegalEntity"); Property(p => p.CustomerParentCompany).HasColumnName("QuoteCustomerDetails_QuoteCustomerDetails_CustomerParentCompany"); Property(p => p.CustomerPhysicalAddress).HasColumnName("QuoteCustomerDetails_QuoteCustomerDetails_CustomerPhysicalAddress"); Property(p => p.CustomerPostalAddress).HasColumnName("QuoteCustomerDetails_QuoteCustomerDetails_CustomerPostalAddress"); Property(p => p.CustomerTradingNameCopy).HasColumnName("QuoteCustomerDetails_QuoteCustomerDetails_CustomerTradingNameCopy"); Property(p => p.CustomerType).HasColumnName("QuoteCustomerDetails_QuoteCustomerDetails_CustomerType"); Property(p => p.CustomerVATNumber).HasColumnName("QuoteCustomerDetails_QuoteCustomerDetails_CustomerVATNumber"); Property(p => p.CustomerVATRate).HasColumnName("QuoteCustomerDetails_QuoteCustomerDetails_CustomerVATRate"); Property(p => p.CustomerContactEmail).HasColumnName("QuoteCustomerDetails_QuoteCustomerDetails_QuoteContactEmail"); Property(p => p.CustomerDefaultDiscount).HasColumnName("QuoteCustomerDetails_QuoteCustomerDetails_QuoteCustomerDefaultDiscount"); Property(p => p.CustomerDefaultMargin).HasColumnName("QuoteCustomerDetails_QuoteCustomerDetails_QuoteCustomerDefaultMargin"); Property(p => p.CustomerContactMobileNumber).HasColumnName("QuoteCustomerDetails_QuoteCustomerDetails_QuoteMobileNumber"); Property(p => p.CustomerContactTelephone).HasColumnName("QuoteCustomerDetails_QuoteCustomerDetails_QuoteTelephoneNumber"); Property(p => p.QuoteEnquiryItems_QuoteEnquiryItems_QuoteRequestItemsUploadList).HasColumnName("QuoteEnquiryItems_QuoteEnquiryItems_QuoteRequestItemsUploadList"); Property(p => p.QuoteFinal_QuoteFinalItems_QuoteFinalItemsFinaliseQuote).HasColumnName("QuoteFinal_QuoteFinalItems_QuoteFinalItemsFinaliseQuote"); Property(p => p.FinalNotes).HasColumnName("QuoteFinal_QuoteFinalItems_QuoteFinalItemsNotes"); Property(p => p.QuoteFinal_QuoteFinalItems_QuoteFinalItemsRefresh).HasColumnName("QuoteFinal_QuoteFinalItems_QuoteFinalItemsRefresh"); Property(p => p.FinalSubtotalexclVAT).HasColumnName("QuoteFinal_QuoteFinalItems_QuoteFinalItemsSubtotalexclVAT"); Property(p => p.FinalTotalinclVAT).HasColumnName("QuoteFinal_QuoteFinalItems_QuoteFinalItemsTotalinclVAT"); Property(p => p.FinalTotalWeightKG).HasColumnName("QuoteFinal_QuoteFinalItems_QuoteFinalItemsTotalWeightKG"); Property(p => p.FinalVAT).HasColumnName("QuoteFinal_QuoteFinalItems_QuoteFinalItemsVAT"); Property(p => p.ContactName2).HasColumnName("QuoteInformation_ContactName"); Property(p => p.CustomerTradingName2).HasColumnName("QuoteInformation_CustomerTradingName"); Property(p => p.Month).HasColumnName("QuoteInformation_QuoteMonth"); Property(p => p.Number).HasColumnName("QuoteInformation_QuoteNumber"); Property(p => p.ItemsDefaultMargin).HasColumnName("QuoteItems_QuoteItems_QuoteItemsDefaultMargin"); Property(p => p.QuoteItems_QuoteItems_QuoteItemsDefaultMarginApplyToAll).HasColumnName("QuoteItems_QuoteItems_QuoteItemsDefaultMarginApplyToAll"); Property(p => p.ItemsGrossProfit).HasColumnName("QuoteItems_QuoteItems_QuoteItemsGrossProfit"); Property(p => p.QuoteItems_QuoteItems_QuoteItemsHideZeroQuantities).HasColumnName("QuoteItems_QuoteItems_QuoteItemsHideZeroQuantities"); Property(p => p.ItemsNotes).HasColumnName("QuoteItems_QuoteItems_QuoteItemsNotes"); Property(p => p.ItemsSubtotalexclVAT).HasColumnName("QuoteItems_QuoteItems_QuoteItemsSubtotalexclVAT"); Property(p => p.ItemsSupplyTypes).HasColumnName("QuoteItems_QuoteItems_QuoteItemsSupplyTypes"); Property(p => p.ItemsTotalCost).HasColumnName("QuoteItems_QuoteItems_QuoteItemsTotalCost"); Property(p => p.ItemsTotalinclVAT).HasColumnName("QuoteItems_QuoteItems_QuoteItemsTotalinclVAT"); Property(p => p.ItemsTotalMargin).HasColumnName("QuoteItems_QuoteItems_QuoteItemsTotalMargin"); Property(p => p.ItemsTotalWeightKG).HasColumnName("QuoteItems_QuoteItems_QuoteItemsTotalWeightKG"); Property(p => p.ItemsVAT).HasColumnName("QuoteItems_QuoteItems_QuoteItemsVAT"); Property(p => p.recId).HasColumnName("recId"); Property(p => p.surfaceId).HasColumnName("surfaceId"); HasRequired(p => p.QuoteStatus) .WithMany() .HasForeignKey(p => p.StatusId); } } } }