public IActionResult Update(int id) { var model = _billsService.GetById(id); BillUpdateView bill = new BillUpdateView() { BillDate = model.BillDate, BillOrderno = model.BillOrderno, BillSeriNo = model.BillSeriNo, Deliverer = model.Deliverer, Hour = model.Hour, Receiver = model.Receiver, VergiDairesi = model.VergiDairesi, }; return(View(bill)); }
public async Task <ActionResult> Edit(int id) { var bill = _billsService.GetById(id); if (bill == null) { return(NotFound()); } if (bill.Payed) { return(NotFound()); //已經支付, 應該去Details } var form = new BillEditForm() { Bill = bill.MapViewModel(_mapper) }; bool canPay = !bill.Expired; if (canPay) { var bills = await _billsService.FetchByUserAsync(new User { Id = CurrentUserId }, new Plan { Id = bill.PlanId }); if (bills.HasItems()) { //查看是否已經有同方案, 已支付的帳單 var payedBill = bills.Where(x => x.Payed).FirstOrDefault(); if (payedBill != null) { canPay = false; } } } if (canPay) { var payways = (await _paysService.FetchPayWaysAsync()).GetOrdered(); form.PayWays = payways.MapViewModelList(_mapper); } return(Ok(form)); }
public async Task <BillEditForm> GetEditBillFormAsync(int billId, string userId) { var bill = _billsService.GetById(billId); if (bill == null) { throw null; } if (bill.Payed) { return(null); //已經支付, 應該去Details } var form = new BillEditForm() { Bill = bill.MapViewModel(_mapper) }; bool canPay = !bill.Expired; if (canPay) { var bills = await _billsService.FetchByUserAsync(new User { Id = userId }, new Plan { Id = bill.PlanId }); if (bills.HasItems()) { //查看是否已經有同方案, 已支付的帳單 var payedBill = bills.Where(x => x.Payed).FirstOrDefault(); if (payedBill != null) { canPay = false; } } } if (canPay) { var payways = (await _paysService.FetchPayWaysAsync()).GetOrdered(); form.PayWays = payways.MapViewModelList(_mapper); } return(form); }
public void RemoveBill(int id) { var bill = _billsService.GetById(id); if (bill == null) { throw new EntityNotFoundException(new Bill { Id = id }); } if (bill.UserId != TestUser.Id) { throw new Exception(); } _billsService.Remove(bill); }