Ejemplo n.º 1
0
        public async Task <ActionResult> Create([Bind(Include = "idOtherExpenses,nameExpenses,amount,dateExpenses,expenseCategoryId")] OtherExpensesView otherExpensesView)
        {
            if (ModelState.IsValid)
            {
                OtherExpensesBll otherExpenses = Mapper.Map <OtherExpensesView, OtherExpensesBll>(otherExpensesView);
                await _otherExpenses.Insert(otherExpenses);

                return(RedirectToAction("Index"));
            }

            ViewBag.Category = new SelectList(await _expenseCategory.GetTableAll(), "idExpenseCategory", "name");
            return(View(otherExpensesView));
        }
        public async Task SaveExpenses(AllExpensesBll allExpenses)
        {
            if (allExpenses.expenseCategoryId == 2 || allExpenses.expenseCategoryId == 3)
            {
                CostsCarWashAndDeteylingBll costsCarWash = new CostsCarWashAndDeteylingBll();

                costsCarWash.nameExpenses      = allExpenses.nameExpenses;
                costsCarWash.expenseCategoryId = allExpenses.expenseCategoryId;
                costsCarWash.dateExpenses      = allExpenses.dateExpenses;
                costsCarWash.amount            = allExpenses.amount;
                costsCarWash.typeServicesId    = allExpenses.typeServicesId;

                await _costsCarWashAndDeteyling.Insert(costsCarWash);
            }
            else if (allExpenses.expenseCategoryId == 5)
            {
                UtilityCostsBll utilityCosts = new UtilityCostsBll();

                utilityCosts.indicationCounter      = allExpenses.indicationCounter;
                utilityCosts.amount                 = allExpenses.amount;
                utilityCosts.dateExpenses           = allExpenses.dateExpenses;
                utilityCosts.expenseCategoryId      = allExpenses.expenseCategoryId;
                utilityCosts.utilityCostsCategoryId = allExpenses.utilityCostsCategoryId;

                await _utilityCosts.Insert(utilityCosts);
            }
            else if (allExpenses.expenseCategoryId == 6)
            {
                OtherExpensesBll otherExpenses = new OtherExpensesBll();

                otherExpenses.nameExpenses      = allExpenses.nameExpenses;
                otherExpenses.amount            = allExpenses.amount;
                otherExpenses.dateExpenses      = allExpenses.dateExpenses;
                otherExpenses.expenseCategoryId = allExpenses.expenseCategoryId;

                await _otherExpenses.Insert(otherExpenses);
            }
        }