Ejemplo n.º 1
0
 public static MonthFinance ToModelToEntity(this MonthFinanceModel model)
 {
     if(model == null)
         return null;
         
     var monthFinance = new MonthFinance(
        model.Name,
        model.Expense.ToModelToEntity(),
        model.Saving
     );
     
     monthFinance.MonthEarning.ListItemsEarning = model.Earning.ToModelToEntity().ListItemsEarning;
     monthFinance.Total = monthFinance.SubTotalEarning + monthFinance.SubTotalExpense; 
     
     return monthFinance;
 }
        public static MonthFinance ToModelToEntity(this MonthFinanceModel model)
        {
            if (model == null)
            {
                return(null);
            }

            var monthFinance = new MonthFinance(
                model.Name,
                model.Expense.ToModelToEntity(),
                model.Saving
                );

            monthFinance.MonthEarning.ListItemsEarning = model.Earning.ToModelToEntity().ListItemsEarning;
            monthFinance.Total = monthFinance.SubTotalEarning + monthFinance.SubTotalExpense;

            return(monthFinance);
        }
        public async Task<bool> SaveNewMonthFinance([FromQuery] string name)
        {
            if(name != null)
            {
                var entity = new MonthFinance{
                    Name = name 
                };
                var documents = (await monthFinanceConfPer.Get()).Last();

                if(documents != null)
                {
                    entity.MonthEarning = documents.MonthEarning;
                    entity.MonthExpense = documents.MonthExpense;
                    entity.MonthInvestment = documents.MonthInvestment;
                }
                
                await monthFinanceConfPer.Persist(entity);

                return true;
            }
            return false;
        }