Example #1
0
        public IActionResult Create(ExpenseDto expense)
        {
            if (ModelState.IsValid)
            {
                _service.Add(expense);
                return(RedirectToAction(nameof(Index)));
            }

            CreateSelectLists(expense.LabelId, expense.PaymentId);

            return(View(expense));
        }
        public ActionResult Save(ExpenseViewModel expense)
        {
            var expenseModel = expense.To <Expense>();

            if (ModelState.IsValid)
            {
                if (expenseModel.Id != default(Guid))
                {
                    _expenseApp.Update(expenseModel);
                }
                else
                {
                    _expenseApp.Add(expenseModel);
                }
            }

            return(Json(expenseModel, JsonRequestBehavior.AllowGet));
        }
Example #3
0
        private void Fill()
        {
            var labelsDto  = new List <LabelDto>();
            var paymentDto = new List <PaymentDto>();

            ILabelAppService labelAppService = GetAppService <ILabelAppService>();

            for (int i = 0; i < NUMBER_OBJ; i++)
            {
                labelsDto.Add(labelAppService.Add(new LabelDto {
                    Name = string.Format(Resource.LabelName, 1 + 1)
                }));
            }

            IPaymentAppService paymentAppService = GetAppService <IPaymentAppService>();

            for (int i = 0; i < NUMBER_OBJ; i++)
            {
                paymentDto.Add(paymentAppService.Add(new PaymentDto {
                    Name = string.Format(Resource.PaymentName, 1 + 1)
                }));
            }

            IExpenseAppService expenseAppService = GetAppService <IExpenseAppService>();

            for (int i = 0; i < NUMBER_OBJ; i++)
            {
                expenseAppService.Add(new ExpenseDto
                {
                    Name       = string.Format(Resource.ExpenseName, 1 + 1),
                    Data       = DateTime.Today,
                    Value      = i + 1,
                    Label      = labelsDto[i],
                    LabelId    = labelsDto[i].Id,
                    Payment    = paymentDto[i],
                    PaymentId  = paymentDto[i].Id,
                    IsIncoming = i % 2 == 0
                });
            }
        }