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.")); }
public void TestCity() { using (var db = new CouponContext()) { city = new City(); city.name = "Tel Aviv"; db.s_Cities.Add(city); db.SaveChanges(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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); } }
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; }
private string ProductTypes(CouponContext context) => (string)context.State.ContentTypes;
public LocalizedString DisplayTrueLabel(CouponContext ctx) { return(T("Cart line is a product of type {0}", ProductTypes(ctx))); }
public LocalizedString DisplayFalseLabel(CouponContext ctx) { return(T("Cart contains products of type {0}", ProductTypes(ctx))); }