Example #1
0
        private LocalizedString Display(CouponContext context)
        {
            var op = (DateTimeOperator)Enum.Parse(typeof(DateTimeOperator), Convert.ToString(context.State.Operator));

            string dateFrom = Convert.ToString(context.State.DateFrom);
            string timeFrom = Convert.ToString(context.State.TimeFrom);

            string dateTo = Convert.ToString(context.State.DateTo);
            string timeTo = Convert.ToString(context.State.TimeTo);

            switch (op)
            {
            case DateTimeOperator.LessThan:
                return(T("{0} is before {1} {2}", T("Current date").Text, dateTo, timeTo));

            case DateTimeOperator.GreaterThan:
                return(T("{0} is after {1} {2}", T("Current date").Text, dateFrom, timeFrom));

            case DateTimeOperator.Between:
                return(T("{0} is between {1} {2} and {3} {4}", T("Current date").Text, dateFrom, timeFrom, dateTo, timeTo));

            default:
                return(T("Invalid operator"));
            }
        }
 public LocalizedString DisplayTrueLabel(CouponContext ctx)
 {
     bool.TryParse(ctx.State.IncludeChildren?.Value, out bool includeChildren);
     if (includeChildren)
     {
         return(T("Cart line is a product of the given category or one of its children."));
     }
     return(T("Cart line is a product of the given category."));
 }
Example #3
0
        public void TestCity()
        {
            using (var db = new CouponContext())
            {
                city      = new City();
                city.name = "Tel Aviv";

                db.s_Cities.Add(city);
                db.SaveChanges();
            }
        }
Example #4
0
        public void TestDeal()
        {
            using (var db = new CouponContext())
            {
                deal          = new Deal();
                deal.dealCode = "123ewq";
                //deal.Customer_user_name = "eden";
                deal.expiration_date = DateTime.Today;
                deal.order_date      = DateTime.Today;

                db.s_Deals.Add(deal);
                db.SaveChanges();
            }
        }
Example #5
0
        public void TestStore()
        {
            using (var db = new CouponContext())
            {
                store             = new Store();
                store.name        = "safari";
                store.description = "the biggest zoo in meadle east";
                store.phone_num   = 4300;
                store.rank        = 7;
                //store.so.user_name = "zoomer";

                db.s_Stores.Add(store);
                db.SaveChanges();
            }
        }
Example #6
0
        public void TestCustomer()
        {
            using (var db = new CouponContext())
            {
                customer               = new Customer();
                customer.email         = "*****@*****.**";
                customer.user_name     = "eden101";
                customer.first_name    = "eden";
                customer.last_name     = "yaakobi";
                customer.password      = "******";
                customer.phone         = "0528757474";
                customer.date_of_birth = DateTime.Now;

                db.s_Customers.Add(customer);
                db.SaveChanges();
            }
        }
Example #7
0
        public void TestCoupon()
        {
            using (var db = new CouponContext())
            {
                coupon                   = new Coupon();
                coupon.cName             = "zoo";
                coupon.idCoupon          = 123;
                coupon.description       = "40% discount for safari";
                coupon.discount_price    = 60;
                coupon.original_price    = 100;
                coupon.period_for_use    = DateTime.Today;
                coupon.purchase_deadline = DateTime.Today;
                coupon.rank              = 5;

                db.s_Coupons.Add(coupon);
                db.SaveChanges();
            }
        }
Example #8
0
        public async Task SeedAsync(CouponContext context)
        {
            if (context.Coupons.EstimatedDocumentCount() == 0)
            {
                var coupons = new List <Coupon>
                {
                    new Coupon
                    {
                        Code     = "DISC-5",
                        Discount = 5
                    },
                    new Coupon
                    {
                        Code     = "DISC-10",
                        Discount = 10
                    },
                    new Coupon
                    {
                        Code     = "DISC-15",
                        Discount = 15
                    },
                    new Coupon
                    {
                        Code     = "DISC-20",
                        Discount = 20
                    },
                    new Coupon
                    {
                        Code     = "DISC-25",
                        Discount = 25
                    },
                    new Coupon
                    {
                        Code     = "DISC-30",
                        Discount = 30
                    }
                };

                await context.Coupons.InsertManyAsync(coupons);
            }
        }
Example #9
0
        public LocalizedString DisplayTrueLabel(CouponContext ctx)
        {
            bool.TryParse(ctx.State.IncludeChildren?.Value, out bool includeChildren);

            var opCart = (SelectTermsOperator)Enum.Parse(typeof(SelectTermsOperator), Convert.ToString(ctx.State.OperatorCart));

            switch (opCart)
            {
            case SelectTermsOperator.AllProducts:
                if (includeChildren)
                {
                    return(T("Each line is a product of the given category or one of its children."));
                }
                return(T("Each line is a product of the given category."));

            case SelectTermsOperator.OneProduct:
                if (includeChildren)
                {
                    return(T("At least one line is a product of the given category or one of its children."));
                }
                return(T("At least one line is a product of the given category."));

            case SelectTermsOperator.InsideCart:
                if (includeChildren)
                {
                    return(T("Among products, there must be the given category or one of its children."));
                }
                return(T("Among products, there must be the given category."));

            default:
                if (includeChildren)
                {
                    return(T("Cart lines are products of the given category or one of its children."));
                }
                return(T("Cart lines are products of the given category."));
            }
        }
 public CouponController(CouponContext context)
 {
     _context = context;
 }
Example #11
0
 private string ProductTypes(CouponContext context) =>
 (string)context.State.ContentTypes;
Example #12
0
 public LocalizedString DisplayTrueLabel(CouponContext ctx)
 {
     return(T("Cart line is a product of type {0}", ProductTypes(ctx)));
 }
Example #13
0
 public LocalizedString DisplayFalseLabel(CouponContext ctx)
 {
     return(T("Cart contains products of type {0}", ProductTypes(ctx)));
 }