public void AddUnPaidPurchaseScaleExpenses(int scaleId) { // Search for all expenses that matches scaleId. ExpensesRequestLibrary lib = new ExpensesRequestLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); string refTableName = new Model.Scale().GetType().Name; IEnumerable <ExpensesRequest> expenses = lib.GetAllPurchasingExepneseByRefTableAndRefId(scaleId, refTableName, new[] { "Payment", "Paid_Party_To" }); ScaleLibrary scaleLib = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); foreach (var item in expenses) { // If scale expense already exists. if (TempEntityList.FirstOrDefault(m => m.ID == item.ID) == null) { // Get scale entity Scale scale = scaleLib.GetByID(item.Reference_ID.ToString(), new string[] { "Dispatch_Request_No" }); if (item.Paid_Party_To == null) { item.Paid_Party_To = new Party(); } // Add eexpense to TempList. TempEntityList.Add(item); // Add dispatcher expense. if (scale.Dispatch_Request_No != null && scale.Dispatch_Request_No.ID > 0) { AddUnPaidPurchaseDispatcherExpenses(scale.Dispatch_Request_No.ID); } } } }
//[HttpPost] //public void RemoveUnPaidSellingExpenses(string bookingId) { // // If TEmpEntityList has no Items. // if (TempEntityList != null) { // int intBookingId = Convert.ToInt32(bookingId); // if (intBookingId > 0) { // // Get all scale exepenses. // IEnumerable<ExpensesRequest> scaleExps = from exp in TempEntityList // where exp.Reference_Table == "Scale" && exp.Reference_ID == intBookingId // select exp; // if (scaleExps != null) { // IList<ExpensesRequest> removeExpenses = new List<ExpensesRequest>(); // ScaleLibrary scaleLib = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); // foreach (var item in scaleExps) { // // Get scale entity. // Scale scale = scaleLib.GetByID(item.Reference_ID.ToString(), new string[] { "Dispatch_Request_No" }); // if (scale != null && scale.Dispatch_Request_No != null && scale.Dispatch_Request_No.ID > 0) { // // Get dispatcher id. // int dispatcherId = scale.Dispatch_Request_No.ID; // // Get all dispatcher expenses. // IEnumerable<ExpensesRequest> dispatcherExps = from exp in TempEntityList // where exp.Reference_Table == "DispatcherRequest" && exp.Reference_ID == dispatcherId // select exp; // if (dispatcherExps != null) { // foreach (var dispExp in dispatcherExps) { // // Add dispatcher expense in removeExpense list. // removeExpenses.Add(dispExp); // } // } // } // // Add scale expense in removeExpense list. // removeExpenses.Add(item); // } // // Delete scale and dispatcher expense. // foreach (var removeExp in removeExpenses) { // TempEntityList.Remove(removeExp); // } // } // } // } //} public void AddNonInvoiceSellingScaleExpenses(int bookingId) { TempEntityList.Clear(); ScaleLibrary scaleLib = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); IEnumerable <Scale> scales = scaleLib.GetScalesByBookingId(bookingId); // Search for all expenses that matches scaleId. ExpensesRequestLibrary lib = new ExpensesRequestLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); string refTableName = new Model.Scale().GetType().Name; foreach (var scale in scales) { IEnumerable <ExpensesRequest> expenses = lib.GetAllSellingExepneseByRefTableAndRefId(scale.ID, refTableName, new[] { "Payment", "Paid_Party_To", "Invoice" }); foreach (var expense in expenses) { // If scale expense already exists. if (TempEntityList.FirstOrDefault(m => m.ID == expense.ID) == null) { if (expense.Paid_Party_To == null) { expense.Paid_Party_To = new Party(); } // Add eexpense to TempList. TempEntityList.Add(expense); // Add dispatcher expense. } } AddNonInvoiceSellingDispatcherExpenses(bookingId, scale.ContainerNo); } }
public override IEnumerable <double> TuneScale(Model.Scale scale) { throw new NotImplementedException(); }