public static Expense ToModelToEntity(this ExpensesModel model) { var expense = new Expense{ ListItemsExpense = model.ListItemsExpenseModel.Select(x=>x.ModelToEntity()).ToList() }; return expense; }
public async Task<MonthFinanceModel> SaveMonthFinance([FromBody] MonthFinanceModel monthFinances) { var documents = (await monthFinanceConfPer.Get()).ToArray(); var entity = documents.Where(x=> x.Name == monthFinances.Name).FirstOrDefault(); if(entity.Name != null) { var entityExpense = new Expense { ListItemsExpense = monthFinances.Expense.ListItemsExpenseModel.Select(x=>x.ModelToEntity()) }; var entityEarning = new Earning { ListItemsEarning = monthFinances.Earning.ListItemsEarningModel.Select(x=>x.ModelToEntity()) }; var entityInvestment = new Investment { ListItemsInvestment = monthFinances.Investment.ListItemsInvestmentModel.Select(x=>x.ModelToEntity()) }; entity.MonthEarning = entityEarning; entity.MonthExpense = entityExpense; entity.MonthInvestment = entityInvestment; await monthFinanceConfPer.Persist(entity); } return entity.ToMonthFinanceModel(); }
public MonthFinance(string name, Expense monthExpensiveLast, double saving) { this.Name = name; this.MonthExpense = monthExpensiveLast; this.Saving = saving; }