public static ICollection<Report> ReadTotalReport() { var expensesReports = mongoDB.GetCollection<ExpensesReport>("ExpensesReports").FindAll().ToList(); var productReports = mongoDB.GetCollection<ProductReport>("ProductReports").FindAll().ToList(); var sqLiteDb = new SQLiteEntities(); var taxes = sqLiteDb.Taxes; IDictionary<string, Report> totalReports = new Dictionary<string, Report>(); foreach (var r in productReports) { if (!totalReports.Keys.Contains(r.vendorName)) { totalReports.Add(new KeyValuePair<string, Report>(r.vendorName, new Report())); totalReports[r.vendorName].VendorName = r.vendorName; } totalReports[r.vendorName].Incomes += r.totalIncomes; var tax = taxes.Where(x => x.Product_Name == r.productName).First().Tax1; totalReports[r.vendorName].Taxes += r.totalIncomes * (decimal)tax; } foreach (var r in expensesReports) { totalReports[r.vendorName].Expenses = r.expenses; } return totalReports.Values.ToList(); }
public static void WriteSQLiteTotalReport(ICollection<Mongo.Report> reports) { var sqLiteDb = new SQLiteEntities(); foreach (var product in reports) { SQLiteModel.ProductsReport sqlProduct = new ProductsReport(); sqlProduct.Vendor_Name = product.VendorName; sqlProduct.Incomes = product.Incomes; sqlProduct.Expenses = product.Expenses; sqlProduct.Taxes = product.Taxes; sqlProduct.Financial_Result = product.FinancialResult; sqLiteDb.ProductsReports.Add(sqlProduct); } sqLiteDb.SaveChanges(); }