public async Task <Balance> Add(Balance newBalance) { try { if (newBalance != null) { newBalance.Month = await GetMonth(newBalance.MonthId); newBalance.TotalIncomes = 0; newBalance.TotalSpendings = 0; newBalance.BalanceResult = 0; _context.Add(newBalance); await _context.SaveChangesAsync(); return(newBalance); } return(null); } catch (Exception) { return(null); } }
public async Task <IActionResult> Create([Bind("Id,CategoryName")] EIncomeType eIncomeType) { if (ModelState.IsValid) { _context.Add(eIncomeType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(eIncomeType)); }
public async Task <AnualBalance> Add(AnualBalance entity) { try { if (entity != null) { entity.AnualBalanceResult = 0; _context.Add(entity); await _context.SaveChangesAsync(); return(entity); } return(null); } catch (Exception) { return(null); } }
public async Task <Spending> Add(Spending entity) { try { if (entity != null) { _context.Add(entity); await _context.SaveChangesAsync(); if (await _balanceRepo.CalculateAndSave(await GetParentBalance(entity.Id)) != null) { return(entity); } return(null); } return(null); } catch (Exception) { throw null; } }
public async Task <Income> Add(Income income) { try { if (income != null) { _context.Add(income); await _context.SaveChangesAsync(); if (await _balanceRepo.CalculateAndSave(await GetParentBalance(income.Id)) != null) { return(income); } return(null); } return(null); } catch (Exception) { throw null; } }