Esempio n. 1
0
 public ActionResult CouponConsume(CouponConsumeModel couponData)
 {
     ViewBag.SubmitButtonTest = "Consume";
     if (ModelState.IsValid) {
         //tCoupon coupon = _coupoRepository.FindByCustomNo(couponData.CouponNo);
         //if (coupon == null) {
         //    ModelState.AddModelError("Coupon", "Coupon Not Found!");
         //    return View(couponData);
         //}
         //int UserID = (int)MembershipHelper.GetCurrenUser().ProviderUserKey;
         //if (coupon.IDPartner != UserID) {
         //    ModelState.AddModelError("Coupon", "User is Wrong For this Coupon!");
         //    return View(couponData);
         //}
         //if (coupon.Code != couponData.CouponCode) {
         //    ModelState.AddModelError("Coupon", "Coupon Code Not Valid!");
         //    return View(couponData);
         //}
         tCoupon coupon = ValidateCoupon(couponData);
         if (!ModelState.IsValid)
             return View(couponData);
         coupon.ConsumeStatus = (int)Enums.enmCouponConsumeStatus.Consumed;
         coupon.tOrders.FirstOrDefault().RefundStatus = (int)Enums.enmRefundStatus.OrderSuccessful;
         _coupoRepository.InsertOrUpdate(coupon);
         _coupoRepository.Save();
         ViewBag.CurrentMessage = "Coupon Consumed Succesfully!";
     }
     return View(couponData);
 }
Esempio n. 2
0
 public ActionResult CouponConsume(CouponConsumeModel couponData)
 {
     ViewBag.SubmitButtonTest = "Consume";
     if (ModelState.IsValid)
     {
         //tCoupon coupon = _coupoRepository.FindByCustomNo(couponData.CouponNo);
         //if (coupon == null) {
         //    ModelState.AddModelError("Coupon", "Coupon Not Found!");
         //    return View(couponData);
         //}
         //int UserID = (int)MembershipHelper.GetCurrenUser().ProviderUserKey;
         //if (coupon.IDPartner != UserID) {
         //    ModelState.AddModelError("Coupon", "User is Wrong For this Coupon!");
         //    return View(couponData);
         //}
         //if (coupon.Code != couponData.CouponCode) {
         //    ModelState.AddModelError("Coupon", "Coupon Code Not Valid!");
         //    return View(couponData);
         //}
         tCoupon coupon = ValidateCoupon(couponData);
         if (!ModelState.IsValid)
         {
             return(View(couponData));
         }
         coupon.ConsumeStatus = (int)Enums.enmCouponConsumeStatus.Consumed;
         coupon.tOrders.FirstOrDefault().RefundStatus = (int)Enums.enmRefundStatus.OrderSuccessful;
         _coupoRepository.InsertOrUpdate(coupon);
         _coupoRepository.Save();
         ViewBag.CurrentMessage = "Coupon Consumed Succesfully!";
     }
     return(View(couponData));
 }
Esempio n. 3
0
 public ActionResult CouponVerify(CouponConsumeModel couponData)
 {
     ViewBag.SubmitButtonTest = "Verify";
     if (ModelState.IsValid)
     {
         ValidateCoupon(couponData);
         if (!ModelState.IsValid)
         {
             return(View(couponData));
         }
         ViewBag.CurrentMessage = "Coupon Data is OK !";
     }
     return(View(couponData));
 }
Esempio n. 4
0
        private tCoupon ValidateCoupon(CouponConsumeModel couponData)
        {
            tCoupon coupon = _coupoRepository.FindByCustomNo(couponData.CouponNo);

            if (coupon == null)
            {
                ModelState.AddModelError("Coupon", "Coupon Not Found!");
                return(coupon);
            }
            int UserID = (int)MembershipHelper.GetCurrenUser().ProviderUserKey;

            if (coupon.IDPartner != UserID)
            {
                ModelState.AddModelError("Coupon", "User is Wrong For this Coupon!");
                return(coupon);
            }
            if (coupon.Code != couponData.CouponCode)
            {
                ModelState.AddModelError("Coupon", "Coupon Code Not Valid!");
                return(coupon);
            }
            return(coupon);
        }
Esempio n. 5
0
 private tCoupon ValidateCoupon(CouponConsumeModel couponData)
 {
     tCoupon coupon = _coupoRepository.FindByCustomNo(couponData.CouponNo);
     if (coupon == null) {
         ModelState.AddModelError("Coupon", "Coupon Not Found!");
         return coupon;
     }
     int UserID = (int)MembershipHelper.GetCurrenUser().ProviderUserKey;
     if (coupon.IDPartner != UserID) {
         ModelState.AddModelError("Coupon", "User is Wrong For this Coupon!");
         return coupon;
     }
     if (coupon.Code != couponData.CouponCode) {
         ModelState.AddModelError("Coupon", "Coupon Code Not Valid!");
         return coupon;
     }
     return coupon;
 }
Esempio n. 6
0
 public ActionResult CouponVerify(CouponConsumeModel couponData)
 {
     ViewBag.SubmitButtonTest = "Verify";
     if (ModelState.IsValid) {
         ValidateCoupon(couponData);
         if (!ModelState.IsValid)
             return View(couponData);
         ViewBag.CurrentMessage = "Coupon Data is OK !";
     }
     return View(couponData);
 }