Esempio n. 1
0
        public ActionResult Create([Bind(Include = "BudgetId,BudgetUserId,BudgetName,BudgetStartDate,BudgetEndDate,IncomePrimaryAmount,IncomeAdditionalAmount,CarTaxAmount,CarInsuranceAmount,CarMaintenanceAmount,CarFuelAmount,CarNctAmount,CarTollChargesAmount,CarExpenseOtherAmount,HouseholdRentMortgageAmount,HouseholdGroceryAmount,HouseholdClothingAmount,HouseholdEducationFeesAmount,HouseholdSchoolSuppliesAmount,HouseholdMedicalExpensesAmount,HouseholdInsuranceAmount,HouseholdMaintenanceAmount,HouseholdExpenseOtherAmount,PersonalSocialAmount,PersonalGymMembershipAmount,PersonalSportsExpenseAmount,PersonalHolidayExpenseAmount,PersonalSavingsAmount,PersonalLoanRepaymentAmount,PersonalHealthInsuranceAmount,PersonalExpenseOtherAmount,TravelBusAmount,TravelLuasAmount,TravelTaxiAmount,TravelTrainAmount,TravelPlaneAmount,TravelExpenseOtherAmount,UtilityBillElectricityAmount,UtilityBillGasAmount,UtilityBillRefuseCollectionAmount,UtilityBillIrishWaterAmount,UtilityBillTVAmount,UtilityBillPhoneBillAmount,UtilityBillBroadbandAmount,UtilityBillOtherExpenseAmount")] Budget budget, int id)
        {
            budget.BudgetUserId = id;

            // Calculate TotalIncome
            budget.TotalIncome = (double)budget.IncomePrimaryAmount + (double)budget.IncomeAdditionalAmount;

            // Calculate TotalCarExpenses
            budget.TotalCarExpenses = (double)budget.CarTaxAmount + (double)budget.CarInsuranceAmount + (double)budget.CarMaintenanceAmount +
                                      (double)budget.CarFuelAmount + (double)budget.CarNctAmount + (double)budget.CarTollChargesAmount +
                                      (double)budget.CarExpenseOtherAmount;

            // Calculate TotalHouseholdExpenses
            budget.TotalHouseholdExpenses = (double)budget.HouseholdRentMortgageAmount + (double)budget.HouseholdGroceryAmount +
                                            (double)budget.HouseholdClothingAmount + (double)budget.HouseholdEducationFeesAmount +
                                            (double)budget.HouseholdSchoolSuppliesAmount + (double)budget.HouseholdMedicalExpensesAmount +
                                            (double)budget.HouseholdInsuranceAmount + (double)budget.HouseholdMaintenanceAmount +
                                            (double)budget.HouseholdExpenseOtherAmount;

            // Calculate TotalPersonalExpenses
            budget.TotalPersonalExpenses = (double)budget.PersonalSocialAmount + (double)budget.PersonalGymMembershipAmount +
                                           (double)budget.PersonalSportsExpenseAmount + (double)budget.PersonalHolidayExpenseAmount +
                                           (double)budget.PersonalSavingsAmount + (double)budget.PersonalLoanRepaymentAmount +
                                           (double)budget.PersonalHealthInsuranceAmount + (double)budget.PersonalExpenseOtherAmount;

            // Calculate TotalTravelExpenses
            budget.TotalTravelExpenses = (double)budget.TravelBusAmount + (double)budget.TravelLuasAmount +
                                         (double)budget.TravelTaxiAmount + (double)budget.PersonalHolidayExpenseAmount +
                                         (double)budget.TravelTrainAmount + (double)budget.TravelPlaneAmount +
                                         (double)budget.TravelExpenseOtherAmount;

            // Calculate TotalUtilityBillExpenses
            budget.TotalUtilityBillExpenses = (double)budget.UtilityBillElectricityAmount + (double)budget.UtilityBillGasAmount +
                                              (double)budget.UtilityBillRefuseCollectionAmount + (double)budget.UtilityBillIrishWaterAmount +
                                              (double)budget.UtilityBillTVAmount + (double)budget.UtilityBillPhoneBillAmount +
                                              (double)budget.UtilityBillBroadbandAmount + (double)budget.UtilityBillOtherExpenseAmount;

            // Calculate Subtotals
            budget.TotalExpenses = (double)budget.TotalCarExpenses + (double)budget.TotalHouseholdExpenses +
                                   (double)budget.TotalPersonalExpenses + (double)budget.TotalTravelExpenses +
                                   (double)budget.TotalUtilityBillExpenses;

            // Calculate Budget Balance
            budget.BudgetBalance = (double)budget.TotalIncome - (double)budget.TotalExpenses;

            if (ModelState.IsValid)
            {
                db.Budgets.Add(budget);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.BudgetUserId = new SelectList(db.BudgetUsers, "BudgetUserId", "LastName", budget.BudgetUserId);
            return(View(budget));
        }
        public ActionResult Create([Bind(Include = "BudgetUserId,LastName,FirstName,DateOfBirth,AddressLine1,AddressLine2,Town,Counties,Country,PostCode,ContactNo")] BudgetUser budgetUser)
        {
            if (ModelState.IsValid)
            {
                db.BudgetUsers.Add(budgetUser);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(budgetUser));
        }
Esempio n. 3
0
 public void Create(Client item)
 {
     _context.Clients.Add(item);
     _context.SaveChanges();
 }