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); } }
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); }
// GET: ExpenditureModels/Create public ActionResult Create(DateTime?dateLastExpenditure = null) { AccountBasicInfo(); ExpenditureEditModel expenditureModel = new ExpenditureEditModel { DateExpenditure = dateLastExpenditure ?? DateTime.Today }; PopulateDropDownLists(expenditureModel); return(View(expenditureModel)); }
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)); }
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(); }
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)); }