public ActionResult ShowTopVoucher() { var vouchers = db.Vouchers.OrderByDescending(v => v.StartDate).Take(1).FirstOrDefault(); if (vouchers != null) { var newVM = new VoucherViewModel() { ItemName = vouchers.VoucherName, ItemNameV = vouchers.VoucherNameV, ImageUrl = vouchers.ImageUrl, Price = vouchers.VoucherValue }; return PartialView(newVM); } return PartialView(); }
public ActionResult ShowVoucher() { var lst = new List<VoucherViewModel>(); var vouchers = db.Vouchers.ToList(); foreach (var voucher in vouchers) { var newVM = new VoucherViewModel() { ItemName = voucher.VoucherName, ItemNameV = voucher.VoucherNameV, ImageUrl = voucher.ImageUrl, Price = voucher.VoucherValue, Discount = (int)(voucher.Tour.TourPlans.First().Price / voucher.VoucherValue) }; lst.Add(newVM); } return PartialView(lst); }
public ActionResult ListVoucher() { var lst = new List<VoucherViewModel>(); var vouchers = db.Vouchers.ToList(); foreach (var voucher in vouchers) { var newVM = new VoucherViewModel() { ItemName = voucher.VoucherName, ItemNameV = voucher.VoucherNameV, ImageUrl = voucher.ImageUrl, Price = voucher.VoucherValue }; lst.Add(newVM); } return View(lst); }