public void MerketingSystem_BuyXOffShipment_10PercentOff() { // three Promotion #1 - 10 MinQuantity, 5$ reward; // #2 - 20 MinQuantity, 10$ Reward; // #3 - 30 MinQuantity 15$ Reward. PromotionEntriesSet sourceSet = new PromotionEntriesSet(); PromotionEntry entry = new PromotionEntry("", "", "Plasma-EDTV", 100); entry.Quantity = 20; sourceSet.Entries.Add(entry); MarketingContext ctx = MarketingContext.Current; Assert.IsNotNull(ctx); Assert.IsNotNull(ctx.MarketingProfileContext); //IDictionary<string, object> ctx = new Dictionary<string, object>(); PromotionContext context = new PromotionContext(ctx.MarketingProfileContext, sourceSet, sourceSet); PromotionFilter filter = new PromotionFilter(); filter.IgnoreConditions = false; MarketingContext.Current.EvaluatePromotions(true, context, filter); foreach (PromotionItemRecord record in context.PromotionResult.PromotionRecords) { decimal amountOff = record.PromotionReward.AmountOff; // Validate promotion Assert.IsTrue(amountOff == 10); } }
public dynamic Get(int id) { using var db = new MarketingContext(); var item = db.ProductsDetails .SingleOrDefault(o => o.Id == id); return(item); }
private async Task WaitForSqlAvailabilityAsync(MarketingContext ctx, ILoggerFactory loggerFactory, IApplicationBuilder app, int retries = 0) { var logger = loggerFactory.CreateLogger(nameof(Startup)); var policy = CreatePolicy(retries, logger, nameof(WaitForSqlAvailabilityAsync)); await policy.ExecuteAsync(async() => { await MarketingContextSeed.SeedAsync(app, loggerFactory); }); }
public IEnumerable <int> Get() { using var db = new MarketingContext(); var all = db.ProductsDetails .Select(p => p.Id) .ToArray(); return(all); }
public CampaignsController(MarketingContext context, IOptionsSnapshot <MarketingSettings> settings ) { _context = context; _settings = settings.Value; }
public IEnumerable <dynamic> Get(string ids) { using var db = new MarketingContext(); var productIds = ids.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Select(s => int.Parse(s)).ToArray(); var items = db.ProductsDetails .Where(status => productIds.Any(id => id == status.Id)) .ToArray(); return(items); }
public CampaignsController(MarketingContext context, IMarketingDataRepository marketingDataRepository, IOptionsSnapshot <MarketingSettings> settings, IIdentityService identityService) { _context = context; _marketingDataRepository = marketingDataRepository; _settings = settings.Value; _identityService = identityService; }
public IEnumerable <int> Get() { using (var db = MarketingContext.Create()) { var all = db.ProductsDetails .Select(p => p.Id) .ToArray(); return(all); } }
public Task <IEnumerable <Models.ProductDescription> > GetByStockItem(int[] stockItemIds) { using (var db = new MarketingContext()) { var query = from pd in db.ProductDescriptions where stockItemIds.Contains(pd.StockItemId) select pd; return(Task.FromResult <IEnumerable <Models.ProductDescription> >(query.ToList())); } }
public dynamic Get(int id) { using (var db = new MarketingContext()) { var item = db.ProductsDetails .Where(o => o.ProductId == id) .SingleOrDefault(); return(item); } }
private PromotionContext PrepareMarketingContext(PromotionEntriesSet sourceSet, PromotionEntriesSet targetSet) { PromotionContext retVal = null; MarketingContext ctx = MarketingContext.Current; Assert.IsNotNull(ctx); Assert.IsNotNull(ctx.MarketingProfileContext); //IDictionary<string, object> ctx = new Dictionary<string, object>(); retVal = new PromotionContext(ctx.MarketingProfileContext, sourceSet, targetSet); return(retVal); }
public BrandQuery(MarketingContext _marketingContext) { Name = "Brand_Query"; Field <ListGraphType <BrandType> >("Brands", //TODO: Endpoint Name resolve: ctx => _marketingContext.GetBrands()); Field <ListGraphType <BrandType> >("BrandByBrandId", arguments: new QueryArguments { new QueryArgument <IntGraphType> { //TODO: Endpoint Paramater Name = "Id", Description = "Brand Id" } }, resolve: ctx => _marketingContext.GetByBrandId(ctx.GetArgument <int>("Id"))); }
public MarketingQuery(MarketingContext _marketingContext) { Name = "Marketing_Query"; Field <ListGraphType <MaterialType> >("Materials", //Endpoint -> Example Request: {"query": "query{ materials{id,name} }" } resolve: ctx => _marketingContext.GetMaterials()); Field <ListGraphType <MaterialType> >("MeterialByBrandId", //Endpoint -> Example Request: {"query": "query{ meterialByBrandId(id:1){id,name} }" } arguments: new QueryArguments { new QueryArgument <IntGraphType> { Name = "Id", Description = "Brand Id" } }, resolve: ctx => _marketingContext.GetMaterialsByBrandId(ctx.GetArgument <int>("Id"))); Field <ListGraphType <BrandType> >("Brands", resolve: ctx => _marketingContext.GetBrands()); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, MarketingContext db) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseMvc(); db.EnsureSeedData(); app.UseGraphiQl("/graphql"); }
public MarketingQuery(MarketingContext _marketingContext) { Name = "Marketing_Query"; //TODO: Graphql endpointlerini belirliyoruz. Field <ListGraphType <MaterialType> >("Materials", resolve: ctx => _marketingContext.GetMaterials()); Field <ListGraphType <MaterialType> >("MeterialByBrandId", arguments: new QueryArguments { new QueryArgument <IntGraphType> { Name = "Id", Description = "Brand Id" } }, resolve: ctx => _marketingContext.GetMaterialsByBrandId(ctx.GetArgument <int>("Id"))); Field <ListGraphType <BrandType> >("Brands", resolve: ctx => _marketingContext.GetBrands()); }
public void MarketingSystem_BuyXGetXDiscount() { PromotionEntriesSet sourceSet = new PromotionEntriesSet(); sourceSet.Entries.Add(new PromotionEntry("", "", "42-Plasma-EDTV", 1)); MarketingContext ctx = MarketingContext.Current; Assert.IsNotNull(ctx); Assert.IsNotNull(ctx.MarketingProfileContext); //IDictionary<string, object> ctx = new Dictionary<string, object>(); PromotionContext context = new PromotionContext(ctx.MarketingProfileContext, sourceSet, sourceSet); PromotionFilter filter = new PromotionFilter(); filter.IgnoreConditions = false; MarketingContext.Current.EvaluatePromotions(true, context, filter); foreach (PromotionItemRecord record in context.PromotionResult.PromotionRecords) { // Validate promotion Assert.IsTrue(record.PromotionReward.AmountOff == 10); } }
public void MerketingSystem_OrderVolumePromotion_10PercentOff() { PromotionEntriesSet sourceSet = new PromotionEntriesSet(); //Add entry totalCost equals 2000 sourceSet.Entries.Add(new PromotionEntry("", "", "42-Plasma-EDTV", 2000)); MarketingContext ctx = MarketingContext.Current; Assert.IsNotNull(ctx); Assert.IsNotNull(ctx.MarketingProfileContext); //IDictionary<string, object> ctx = new Dictionary<string, object>(); PromotionContext context = new PromotionContext(ctx.MarketingProfileContext, sourceSet, sourceSet); PromotionFilter filter = new PromotionFilter(); filter.IgnoreConditions = false; MarketingContext.Current.EvaluatePromotions(true, context, filter); foreach (PromotionItemRecord record in context.PromotionResult.PromotionRecords) { decimal amountOff = record.PromotionReward.AmountOff; // Validate promotion Assert.IsTrue(amountOff == 10); } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load(object sender, EventArgs e) { try { int major = 0; int minor = 0; int patch = 0; DateTime installed = DateTime.MinValue; AppContext.GetApplicationSystemVersion(out major, out minor, out patch, out installed); ApplicationSystemVersionText.Text = GetVersionString(major, minor, patch, installed); AssetContext.GetAssetSystemVersion(out major, out minor, out patch, out installed); BusinessFoundationSystemVersionText.Text = GetVersionString(major, minor, patch, installed); CatalogContext.GetCatalogSystemVersion(out major, out minor, out patch, out installed); CatalogSystemVersionText.Text = GetVersionString(major, minor, patch, installed); CMSContext.GetContentSystemVersion(out major, out minor, out patch, out installed); ContentSystemVersionText.Text = GetVersionString(major, minor, patch, installed); MarketingContext.GetMarketingSystemVersion(out major, out minor, out patch, out installed); MarketingSystemVersionText.Text = GetVersionString(major, minor, patch, installed); OrderContext.GetOrderSystemVersion(out major, out minor, out patch, out installed); OrderSystemVersionText.Text = GetVersionString(major, minor, patch, installed); ProfileContext.GetProfileSystemVersion(out major, out minor, out patch, out installed); ProfileSystemVersionText.Text = GetVersionString(major, minor, patch, installed); } catch (Exception ex) { ErrorText.Visible = true; ErrorText.Text = String.Format("Error: {0}", ex.Message); } }
/* Create Example * * * */ public BrandMutation(MarketingContext _marketingContext) { Name = "Brand_Mutation"; Field <BrandType>("createUser", resolve: ctx => { var user = ctx.GetArgument <Brand>("user"); _marketingContext.AddBrand(user); return(user); }, arguments: new QueryArguments() { new QueryArgument <InputBrandType> { Name = "user" } }); /* Delete Example * * mutation { * deleteUser(id:5) { * name * id * } * } * */ Field <BrandType>("deleteUser", resolve: ctx => { var id = (int)ctx.Arguments["id"]; return(_marketingContext.RemoveBrand(id)); }, arguments: new QueryArguments() { new QueryArgument <IntGraphType> { Name = "id" } }); }
public BrandRepository(MarketingContext db) { _db = db; }
public When_calling_catalog_api() { MarketingContext.CreateSeedData(Guid.NewGuid().ToString()); }
void IDisposable.Dispose() { MarketingContext.DropDatabase(); }
private SignUp CreateSignupEvent(RegisterViewModel model) { var signupAddress = new AddressDetails { FirstName = model.User.FirstName, LastName = model.User.LastName, PhoneNumber = model.User.Phone, Street1 = model.Address.Address1, Street2 = model.Address.Address2, City = model.Address.City, State = model.Address.State, ZipCode = model.Address.ZipCode, Country = model.Address.CountryRegion }; var signupUser = new SignupUser { CreationDate = DateTimeOffset.Now, UpdateDate = DateTimeOffset.Now, FirstName = model.User.FirstName, LastName = model.User.LastName, Country = model.Address.CountryRegion, ZipCode = model.Address.ZipCode, TimeZone = new TimeSpan(0, 0, -model.DeviceFingerPrinting.ClientTimeZone, 0).ToString(), Language = "EN-US", PhoneNumber = model.User.Phone, Email = model.User.Email, ProfileType = UserProfileType.Consumer.ToString(), Address = signupAddress }; var deviceContext = new DeviceContext { DeviceContextId = _contextAccessor.GetSessionId(), IPAddress = _contextAccessor.HttpContext.Connection.RemoteIpAddress.ToString(), Provider = DeviceContextProvider.DFPFingerPrinting.ToString(), }; var marketingContext = new MarketingContext { Type = MarketingType.Direct.ToString(), IncentiveType = MarketingIncentiveType.None.ToString(), IncentiveOffer = "Integrate with Fraud Protection" }; var storefrontContext = new StoreFrontContext { StoreName = "Fraud Protection Sample Site", Type = StorefrontType.Web.ToString(), Market = "US" }; var signupEvent = new SignUp { SignUpId = Guid.NewGuid().ToString(), AssessmentType = AssessmentType.Protect.ToString(), User = signupUser, MerchantLocalDate = DateTimeOffset.Now, CustomerLocalDate = model.DeviceFingerPrinting.ClientDate, MarketingContext = marketingContext, StoreFrontContext = storefrontContext, DeviceContext = deviceContext, }; return(signupEvent); }
public LocationsController(MarketingContext context) { _context = context; }
public ProductPriceController(MarketingContext context) { _context = context; }
public CampaignsController(MarketingContext context) { _context = context; }
public static void Main(string[] args) { MarketingContext.CreateSeedData(); CreateHostBuilder(args).Build().Run(); }
public PurchaseHistoryRepository(MarketingContext db) { _db = db; }
public MaterialRepository(MarketingContext db) { _db = db; }