public IndexViewModel CreateIndexViewModel(string userId) { var availableCoupons = _couponService.GetAvailableCouponsById(userId); var savedCoupons = _couponService.GetSavedCouponsById(userId); var model = new IndexViewModel { SavedCoupons = Mapper.Map <List <SavedCouponViewModel> >(savedCoupons) }; foreach (var savedCoupon in model.SavedCoupons) { savedCoupon.AmountAvailable = availableCoupons.Count(x => x.CouponText == savedCoupon.CouponText && x.Status == AvailableCouponStatus.Available); savedCoupon.AmountRedeemed = availableCoupons.Count(x => x.CouponText == savedCoupon.CouponText && x.Status == AvailableCouponStatus.Assigned); } return(model); }