using CAPI.Custom.Entities; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CAPI.Custom.Data { public partial class QuotesContext { // Quote Events public event EventHandler QuoteAccepted; public event EventHandler QuoteCreated; public event EventHandler QuoteDeleted; public event EventHandler QuoteUpdated; public event EventHandler QuoteProcessed; // QuoteItem Events public event EventHandler QuoteItemRecalcuated; // QuoteFinalItems Events public event EventHandler QuoteFinalRefreshed; // Buyout Supplier Events public event EventHandler BuyoutSupplierCreated; public event EventHandler SupplierItemsExported; // Buyout Items Events public event EventHandler BuyoutItemRecalculated; public event EventHandler BuyoutItemsExported; public class QuoteEvent { public int QuoteId { get; set; } public int UserId { get; set; } public Quote Quote { get; set; } } public class BuyoutSupplierEvent { public int QuoteId { get; set; } public int BuyoutSupplierId { get; set; } } private void RegisterEvents() { //QuoteAccepted += OnQuoteAccepted; //SupplierItemsExported += OnSupplierItemsExported; //BuyoutItemRecalculated += OnBuyoutItemRecalculated; //BuyoutItemsExported += OnBuyoutItemsExported; } private void UnregisterEvents() { //QuoteAccepted -= OnQuoteAccepted; //SupplierItemsExported -= OnSupplierItemsExported; //BuyoutItemRecalculated -= OnBuyoutItemRecalculated; //BuyoutItemsExported -= OnBuyoutItemsExported; } //protected void OnQuoteAccepted(object sender, QuoteEvent args) //{ // //var quote = args.Quote ?? GetQuote(args.QuoteId); // //if (quote.IsNull()) return; // //// Update Delivery Address with Customer Physical Address // //var address = quote.QuoteCustomerDetails_QuoteCustomerDetails_CustomerPhysicalAddress?.Split(',') // // ?? new string[] { }; // //if (address.Length > 0) quote.Delivery_Street = address[0]; // //if (address.Length > 1) quote.Delivery_Suburb = address[1]; // //if (address.Length > 2) quote.Delivery_City = address[2]; // //if (address.Length > 3) quote.Delivery_State = address[3]; // //if (address.Length > 4) quote.Delivery_Country = address[4]; // //if (address.Length > 5) quote.Delivery_PostalCode = address[5]; // //// Estimate Delivery Date // //var maxLeadTime = QuoteItemsFinal // // .Where(p => // // p.isActive.Value // // && p.Status // // && p.ParentSurfaceItemId == quote.itemID // // ) // // .Select(p => p.QuoteItemsFinal_QuoteItemsFinal_QuoteItemsFinalLeadTime) // // .Distinct() // // // Only parameterless constructors and initializers are supported in LINQ to Entities // // .ToList() // // .Select(p => new LeadTime(p)) // // .Max(); // //quote.Delivery_EstimatedDate = quote.AcceptedDate.Value.Add(maxLeadTime.ToTimeSpan()); //} //protected void OnSupplierItemsExported(object sender, QuoteEvent args) //{ // Quotes_CalcualteQuoteItemTotals(args.QuoteId); //} //protected void OnBuyoutItemRecalculated(object sender, BuyoutSupplierEvent args) //{ // QuoteBuyoutItems_ExportToQuoteItems(args.BuyoutSupplierId); //} //protected void OnBuyoutItemsExported(object sender, BuyoutSupplierEvent args) //{ // Quotes_CalcualteQuoteItemTotals(args.QuoteId); //} } }