コード例 #1
0
 public void EditExpenditure(ExpenditureEditModel model)
 {
     using (var httpClient = new HttpClientExtended())
     {
         var dto = AutoMapper.Mapper.Map <PersonalFinanceManager.DTOs.Expense.ExpenseDetails>(model);
         httpClient.Put($"/Expense/Edit/{model.Id}", dto);
     }
 }
コード例 #2
0
        public ExpenditureEditModel GetById(int id)
        {
            ExpenditureEditModel result = null;

            using (var httpClient = new HttpClientExtended())
            {
                var response = httpClient.GetSingle <PersonalFinanceManager.DTOs.Expense.ExpenseDetails>($"/Expense/Get/{id}");
                result = AutoMapper.Mapper.Map <ExpenditureEditModel>(response);
            }
            return(result);
        }
コード例 #3
0
        // GET: ExpenditureModels/Create
        public ActionResult Create(DateTime?dateLastExpenditure = null)
        {
            AccountBasicInfo();

            ExpenditureEditModel expenditureModel = new ExpenditureEditModel
            {
                DateExpenditure = dateLastExpenditure ?? DateTime.Today
            };

            PopulateDropDownLists(expenditureModel);

            return(View(expenditureModel));
        }
コード例 #4
0
        public ActionResult Edit(ExpenditureEditModel expenditureModel)
        {
            if (ModelState.IsValid)
            {
                var accountId = GetCurrentAccount();

                expenditureModel.AccountId = accountId;

                _expenditureService.EditExpenditure(expenditureModel);

                return(RedirectToAction("Index", new { accountId }));
            }
            return(View(expenditureModel));
        }
コード例 #5
0
 private void PopulateDropDownLists(ExpenditureEditModel expenditureModel)
 {
     expenditureModel.AvailableInternalAccounts = _bankAccountService.GetAccountsByUser(CurrentUser).Where(x => x.Id != GetCurrentAccount()).Select(x => new SelectListItem()
     {
         Value = x.Id.ToString(), Text = x.Name
     }).ToList();
     expenditureModel.AvailableExpenditureTypes = _expenditureTypeService.GetExpenditureTypes().Select(x => new SelectListItem()
     {
         Value = x.Id.ToString(), Text = x.Name
     }).OrderBy(x => x.Text).ToList();
     expenditureModel.AvailablePaymentMethods = _paymentMethodService.GetPaymentMethods().ToList();
     expenditureModel.AvailableAtmWithdraws   = _atmWithdrawService.GetAtmWithdrawsByAccountId(GetCurrentAccount()).Where(x => !x.IsClosed).OrderBy(x => x.DateExpenditure).Select(x => new SelectListItem()
     {
         Value = x.Id.ToString(), Text = x.Description
     }).ToList();
 }
コード例 #6
0
        public ActionResult Create(ExpenditureEditModel expenditureModel, bool stayHere)
        {
            if (ModelState.IsValid)
            {
                var accountId = GetCurrentAccount();

                expenditureModel.AccountId = accountId;
                _expenditureService.CreateExpenditure(expenditureModel);

                if (stayHere)
                {
                    return(RedirectToAction("Create", new { DateLastExpenditure = expenditureModel.DateExpenditure }));
                }

                return(RedirectToAction("Index", new { accountId }));
            }
            else
            {
                PopulateDropDownLists(expenditureModel);
            }

            return(View(expenditureModel));
        }