public ActionResult ConfirmVoucher(ConfirmVoucherViewModel confirmVoucher)
 {
     try
     {
         if (!string.IsNullOrEmpty(confirmVoucher.VoucherToken))
         {
             var voucherDetail = _voucherService.GetVoucher(confirmVoucher.VoucherToken).Result;
             var model         = new VoucherDetailViewModel
             {
                 VoucherToken       = voucherDetail.voucherToken,
                 VoucherDescription = voucherDetail.voucherDescription,
                 Name = voucherDetail.name,
                 VoucherPurchasedOn = voucherDetail.voucherPurchasedOn,
                 UsedOn             = voucherDetail.usedOn
             };
             _voucherDetailViewModel = model;
             return(RedirectToAction("DisplayVoucher"));
         }
         else
         {
             ModelState.AddModelError("", "there is a problem with this operation.");
             return(View());
         }
     }
     catch (Exception)
     {
         ModelState.AddModelError("", "This operation could not be completed, please try again.");
         return(View());
     }
 }
예제 #2
0
        public VoucherViewModel CopyNew(long vid)
        {
            Voucher voucher = GetMyVoucher(vid);

            VoucherViewModel vmVoucher = Mapper.Map <VoucherViewModel>(voucher);

            vmVoucher.VId = 0;
            foreach (VoucherDetail vd in voucher.VoucherDetails)
            {
                VoucherDetailViewModel vmDetail = Mapper.Map <VoucherDetailViewModel>(vd);
                vmDetail.VdId = 0;
                vmVoucher.VoucherDetails.Add(vmDetail);
            }

            return(vmVoucher);
        }
 public ActionResult RedeemVoucher(VoucherDetailViewModel voucherDetail)
 {
     try
     {
         if (voucherDetail != null)
         {
             _voucherService.RedeemVoucher(voucherDetail.VoucherToken);
             return(View());
         }
         else
         {
             ModelState.AddModelError("", "there is a problem with this operation.");
             return(View());
         }
     }
     catch (Exception)
     {
         ModelState.AddModelError("", "This operation could not be completed, please try again.");
         return(View());
     }
 }
        private void CreateAndPostOrder(IVoucherService voucherService)
        {
            var createVoucher = new CreateVoucherDTO
            {
                vouchertypeId  = Properties.Settings.Default.VoucherTypeId,
                maxRedemptions = 0,
                firstName      = _customerDetailViewModel.FirstName,
                lastName       = _customerDetailViewModel.SecondName,
                email          = _customerDetailViewModel.Email
            };

            foreach (var itemLine in _cart.Lines)
            {
                var attribute = new AttributeDTO
                {
                    attributeId = itemLine.Experience.Code,
                    value       = itemLine.Quantity.ToString(),
                };
                createVoucher.attributes.Add(attribute);
            }

            var voucherDetail = voucherService.CreateVoucher(createVoucher).Result;

            _cart.Clear();

            var model = new VoucherDetailViewModel
            {
                VoucherToken       = voucherDetail.voucherToken,
                VoucherDescription = voucherDetail.voucherDescription,
                Name = voucherDetail.name,
                VoucherPurchasedOn = voucherDetail.voucherPurchasedOn,
                UsedOn             = voucherDetail.usedOn
            };

            _voucherDetailViewModel = null;
            _voucherDetailViewModel = model;
        }