public ActionResult Voucher(string id) { string pTerms = string.Format("{0}{1}", DateTime.Now.Year, DateTime.Now.Month - 1); if (!string.IsNullOrEmpty(id)) { Voucher v = _voucher.GetMyVoucher(Convert.ToInt64(id)); pTerms = v.PaymentTerms; } List <VoucherViewModel> vvm = Mapper.Map <List <VoucherViewModel> >(_voucher.GetMyCurrentMonthVouchers(pTerms)); int vIndex = -1; if (!string.IsNullOrEmpty(id)) { foreach (VoucherViewModel vv in vvm) { vIndex++; if (vv.VId == Convert.ToInt64(id)) { break; } } } VoucherActionViewModel model = new VoucherActionViewModel(); model.CertWord = _certWord.GetDefault(); model.VouchersJson = JsonConvert.SerializeObject(vvm); model.AbstractsJson = JsonConvert.SerializeObject(Mapper.Map <List <AbstractViewModel> >(_voucher.GetMyAbstracts())); model.AccountsJson = JsonConvert.SerializeObject(_account.GetAccountTree().children); model.NextVoucherDate = _voucher.GetNextVoucherDate(); model.VoucherIndex = vIndex; model.CurrentUserName = _identity.Claims.Where(c => c.Type == "name").FirstOrDefault().Value; return(View(model)); }
public IHttpActionResult GetMyVoucher(long vid) { VoucherViewModel voucher = Mapper.Map <VoucherViewModel>(_voucher.GetMyVoucher(vid)); return(Ok(voucher)); }