Пример #1
0
        public async Task <ActionResult> Create([Bind(Include = "idCostsCarWashAndDeteyling,nameExpenses,amount,dateExpenses,expenseCategoryId,typeServicesId")] CostsCarWashAndDeteylingView costsCarWashAndDeteylingView)
        {
            if (ModelState.IsValid)
            {
                CostsCarWashAndDeteylingBll costsCarWashAndDeteyling = Mapper.Map <CostsCarWashAndDeteylingView, CostsCarWashAndDeteylingBll>(costsCarWashAndDeteylingView);
                await _costsCarWashAndDeteyling.Insert(costsCarWashAndDeteyling);

                return(RedirectToAction("Index"));
            }

            ViewBag.Category = new SelectList(await _expenseCategory.GetTableAll(), "idExpenseCategory", "name");
            return(View(costsCarWashAndDeteylingView));
        }
        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);
            }
        }