public async Task <ActionResult> Details(long id) { var item = await _crudBusinessManager.GetInvoice(id); if (item == null) { return(NotFound()); } return(View(_mapper.Map <InvoiceViewModel>(item))); }
//[Obsolete] //// GET: Payment/BulkPayment //public async Task<ActionResult> BulkPayment(List<long> ids) { // var invoices = await _businessManager.GetInvoices(ids.ToArray()); // Random rd = new Random(); // var payments = invoices.Select(x => new PaymentViewModel() { // No = string.Format("PMNT_{0}", rd.NextLong(11111, 99999).ToString()), // Amount = x.Subtotal - x.Payments.TotalAmount(), // CustomerId = x.CustomerId, // Date = DateTime.Now, // InvoiceId = x.Id, // InvoiceNo = x.No, // InvoiceAmount = x.Subtotal * (1 + x.TaxRate / 100), // }).ToList(); // var model = new BulkPaymentViewModel() { // DateFrom = DateTime.Now.FirstDayOfMonth(), // DateTo = DateTime.Now.LastDayOfMonth(), // CompanyId = 0, // Payments = payments, // Invoices = ids // }; // return View("_PaymentsPartial", model); //} // GET: Payment/Edit/5 public async Task <ActionResult> Edit(long id) { var item = await _businessManager.GetPayment(id); if (item == null) { return(NotFound()); } var customers = await _businessManager.GetCustomers(); ViewBag.Customers = customers.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString() }).ToList(); var paidInvoice = await _businessManager.GetInvoice(item.InvoiceId ?? 0); var invoices = await _businessManager.GetUnpaidInvoices(item.CustomerId ?? 0); if (paidInvoice != null) { invoices.Add(paidInvoice); } ViewBag.Invoices = invoices.Select(x => new SelectListItem() { Text = $"{x.No} - {x.Subtotal}", Value = x.Id.ToString() }).ToList(); return(View(_mapper.Map <PaymentViewModel>(item))); }
// GET: Invoice/Details/5 public async Task <ActionResult> Details(long id) { var item = await _businessManager.GetInvoice(id); if (item == null) { return(NotFound()); } var payment = await _businessManager.GetPaymentByInvoiceId(item.Id); ViewBag.Company = _mapper.Map <CompanyViewModel>(item.Company); ViewBag.Customer = _mapper.Map <CustomerViewModel>(item.Customer); ViewBag.Payments = _mapper.Map <List <PaymentViewModel> >(payment); var model = _mapper.Map <InvoiceViewModel>(item); return(View(model)); }
public async Task <InvoiceViewModel> GetInvoice(long id) { var result = await _businessManager.GetInvoice(id); return(_mapper.Map <InvoiceViewModel>(result)); }