public AutomateReturn AddTransaction(YodleeTransactionLevel transaction, string accId, List <CFType> types, ManualCashFlow manual, List <CFClassification> classifications, Account account) { AutomateReturn automateReturn = new AutomateReturn(); automateReturn.AutomatedCashFlow = new AutomatedCashFlow() { ID = Guid.NewGuid().ToString(), AccountId = accId, Amount = transaction.amount.amount, CFClassificationId = GetCFClassification(transaction, classifications), CFTypeId = types.Where(x => x.YodleeId == transaction.categoryId).Select(x => x.Id).FirstOrDefault(), DateBooked = transaction.transactionDate, DateCaptured = transaction.createdDate, SourceOfExpense = GetSource(transaction), YodleeId = transaction.id }; if (automateReturn.AutomatedCashFlow.DateBooked == DateTime.MinValue) { automateReturn.AutomatedCashFlow.DateBooked = automateReturn.AutomatedCashFlow.DateCaptured; } if (manual != null) { automateReturn.ManualCashFlow = manual; automateReturn.ManualCashFlow.AutomatedCashFlowId = automateReturn.AutomatedCashFlow.ID; automateReturn.AutomatedCashFlow.CFTypeId = manual.CFTypeId; automateReturn.AccountChange = new AccountChange() { AccountChangeId = "" }; automateReturn.AutomatedCashFlow.Validated = true; } else { AccountChange change = new AccountChange(); automateReturn.AccountChange = change.AddAccountChange(automateReturn.AutomatedCashFlow, account, GetCFClassificationSign(transaction, classifications)); automateReturn.ManualCashFlow = new ManualCashFlow() { Id = "" }; automateReturn.AutomatedCashFlow.Validated = false; } return(automateReturn); }
public ReturnModel Save() { ManualCashFlow flow = new ManualCashFlow(this); ReturnModel returnModel = new ReturnModel(); using (FinPlannerContext _context = new FinPlannerContext()) { _context.Add(flow); try { _context.SaveChanges(); AccountChange change = new AccountChange(); change.AddAccountChange(flow); returnModel.result = true; return(returnModel); } catch (Exception e) { returnModel.returnStr = e.Message; returnModel.result = false; return(returnModel); } } }