public Task <bool> createNewBudget(GetBudgetDTO data) => Task.Run(() => { try { Budget budget = new Budget { Ownerid = data.ownerId, Food = 0, Leisure = 0, Rent = 0, Loan = 0, Alcohol = 0, Tobacco = 0, Insurance = 0, Car = 0, Subscriptions = 0, Goal = 0, Other = 0, Clothes = 0 }; context.Budget.Add(budget); context.SaveChanges(); return(true); } catch (Exception ex) { return(false); } });
public async Task <IActionResult> GetValuesOfCategoryLimits(string ownerId) { GetBudgetDTO data = new GetBudgetDTO { ownerId = ownerId }; List <SingleBudgetDTO> limits = await _budgetProcessor.getBudget(data); return(Ok(limits)); }
public Task <List <SingleBudgetDTO> > getBudget(GetBudgetDTO data) => Task.Run(() => { Budget budget = context.Budget.First(a => a.Ownerid == data.ownerId); List <SingleBudgetDTO> listOfCategories = new List <SingleBudgetDTO>(); listOfCategories.Add(new SingleBudgetDTO { category = "Food", limit = budget.Food }); listOfCategories.Add(new SingleBudgetDTO { category = "Leisure", limit = budget.Leisure }); listOfCategories.Add(new SingleBudgetDTO { category = "Rent", limit = budget.Rent }); listOfCategories.Add(new SingleBudgetDTO { category = "Loan", limit = budget.Loan }); listOfCategories.Add(new SingleBudgetDTO { category = "Alcohol", limit = budget.Alcohol }); listOfCategories.Add(new SingleBudgetDTO { category = "Tobacco", limit = budget.Tobacco }); listOfCategories.Add(new SingleBudgetDTO { category = "Insurance", limit = budget.Insurance }); listOfCategories.Add(new SingleBudgetDTO { category = "Car", limit = budget.Car }); listOfCategories.Add(new SingleBudgetDTO { category = "Subscriptions", limit = budget.Subscriptions }); listOfCategories.Add(new SingleBudgetDTO { category = "Goal", limit = budget.Goal }); listOfCategories.Add(new SingleBudgetDTO { category = "Other", limit = budget.Other }); listOfCategories.Add(new SingleBudgetDTO { category = "Clothes", limit = budget.Clothes }); return(listOfCategories); });