Beispiel #1
0
        public static string checkCouponG25(int customerID)
        {
            // check customer
            var customer = CustomerController.GetByID(customerID);

            if (customer == null)
            {
                return("customerNotFound");
            }

            // check coupon
            var coupon = CouponController.getByName("G25");

            if (coupon == null)
            {
                return("couponNotFound");
            }
            else
            {
                if (coupon.Active == false)
                {
                    return("couponNotActived");
                }
            }

            // check user app
            var userPhone  = UserController.getByPhone(customer.CustomerPhone);
            var userPhone2 = UserController.getByPhone(customer.CustomerPhone2);

            if (userPhone == null && userPhone2 == null)
            {
                return("userNotFound");
            }

            // kiểm tra đã tạo mã cho khách này chưa
            var customerCoupon = CouponController.getCouponByCustomer(coupon.ID, customer.ID, customer.CustomerPhone);

            if (customerCoupon.Count == 0)
            {
                return("noCouponGeneratedYet");
            }

            // kiểm tra mã đã tạo còn cái nào actice không
            int activeCoupon = customerCoupon.Where(x => x.Active == true).Count();

            if (activeCoupon > 0)
            {
                return("activeCouponExists");
            }

            // kiểm tra khách đã sử dụng bao nhiêu mã
            int inactiveCoupon = customerCoupon.Where(x => x.Active == false).Count();

            if (inactiveCoupon == 1)
            {
                return("couponUsageLimitExceeded");
            }

            return("false");
        }
Beispiel #2
0
        public static string generateCouponG25(int customerID)
        {
            var coupon = CouponController.getByName("G25");

            if (coupon != null)
            {
                //generate coupon for customer
                var customerCoupon = CouponController.insertCustomerCoupon(customerID, coupon.ID);
                if (customerCoupon != null)
                {
                    return("true");
                }
            }

            return("false");
        }
Beispiel #3
0
        public static string generateCouponG15(int customerID, bool checkUser = false)
        {
            // check customer
            var customer = CustomerController.GetByID(customerID);

            if (customer == null)
            {
                return("customerNotFound");
            }

            // check coupon
            var coupon = CouponController.getByName("G15");

            if (coupon == null)
            {
                return("couponNotFound");
            }
            else
            {
                if (coupon.Active == false)
                {
                    return("couponNotActived");
                }
            }

            // check user app
            if (checkUser == true)
            {
                var userPhone  = UserController.getByPhone(customer.CustomerPhone);
                var userPhone2 = UserController.getByPhone(customer.CustomerPhone2);
                if (userPhone == null && userPhone2 == null)
                {
                    return("userNotFound");
                }
            }

            //generate coupon for customer
            var customerCoupon = CouponController.insertCustomerCoupon(customerID, coupon.ID);

            if (customerCoupon != null)
            {
                return("true");
            }

            return("false");
        }