public void SetTemplate(ProductTemplate tpl) { _IOSTemplate = tpl; _template = new UM_InAppProductTemplate(); _template.id = tpl.id; _template.title = tpl.title; _template.description = tpl.description; _template.price = tpl.price; }
public IActionResult Create([FromBody] ProductTemplateFrom model) { if (!ModelState.IsValid) { return new BadRequestObjectResult(ModelState); } var productTemplate = new ProductTemplate { Name = model.Name }; foreach (var attributeVm in model.Attributes) { productTemplate.AddAttribute(attributeVm.Id); } productTemplateRepository.Add(productTemplate); productAttributeRepository.SaveChange(); return Ok(); }
public ActionResult ProductTemplateAdd([Bind(Exclude = "Id")] ProductTemplateModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance)) { return(AccessDeniedView()); } if (!ModelState.IsValid) { return(Json(new DataSourceResult() { Errors = ModelState.SerializeErrors() })); } var template = new ProductTemplate(); template = model.ToEntity(template); _productTemplateService.InsertProductTemplate(template); return(new NullJsonResult()); }
public IActionResult Post([FromBody] ProductTemplateFrom model) { if (!ModelState.IsValid) { return(new BadRequestObjectResult(ModelState)); } var productTemplate = new ProductTemplate { Name = model.Name }; foreach (var attributeVm in model.Attributes) { productTemplate.AddAttribute(attributeVm.Id); } _productTemplateRepository.Add(productTemplate); _productAttributeRepository.SaveChange(); return(Ok()); }
public ActionResult <ProductTemplateDTO> AddProductTemplate([FromBody] ProductTemplateDTO dto, long schoolId) { try { School s = _schools.GetById(schoolId); ProductTemplate pt = new ProductTemplate(dto, true); // boolean (addedByGO) dependant on logged in user pt.School = s; pt.CategoryTemplate = _productTemplateRepo.getCategoryById(dto.CategoryTemplateId); foreach (var el in dto.ProductVariationTemplates) { pt.AddVariation(el); } s.AddProductTemplate(pt); _schools.SaveChanges(); return(new ProductTemplateDTO(pt)); } catch (ArgumentNullException) { return(NotFound(new CustomErrorDTO("School niet gevonden"))); } }
public void SaveButton_Click(object sender, EventArgs e) { // UPDATE TEMPLATE AND COLLECT ANY VALUES if (_Product.ProductTemplates.Count > 0) { // DELETE THE OLD PRODUCT TEMPLATE ASSOCIATION FROM DATABASE int[] selectedTemplates = AlwaysConvert.ToIntArray(Request.Form[HiddenSelectedTemplates.UniqueID]); ClearInvalidTemplateFields(_Product, selectedTemplates); if (selectedTemplates != null && selectedTemplates.Length > 0) { for (int i = _Product.ProductTemplates.Count - 1; i > -1; i--) { // check if this template is in the list of selected templates ProductTemplate template = _Product.ProductTemplates[i]; if (Array.IndexOf(selectedTemplates, template.Id) < 0) { _Product.ProductTemplates.DeleteAt(i); } } } // GATHER NEW VALUES FOR PRODUCT CUSTOM FIELDS AbleCommerce.Code.ProductHelper.CollectProductTemplateInput(_Product, phCustomFields); _Product.TemplateFields.Save(); } else { // NO TEMPLATES SHOULD BE ASSOCIATED TO THE PRODUCT _Product.ProductTemplates.DeleteAll(); _Product.TemplateFields.DeleteAll(); } // DISPLAY CONFIRMATION SavedMessage.Visible = true; SavedMessage.Text = string.Format(SavedMessage.Text, LocaleHelper.LocalNow); }
private void InitializeTemplateList() { if (Page.IsPostBack) { _Product.ProductTemplates.Clear(); int[] selectedTemplates = AlwaysConvert.ToIntArray(Request.Form[HiddenSelectedTemplates.UniqueID]); if (selectedTemplates != null && selectedTemplates.Length > 0) { foreach (int ptid in selectedTemplates) { ProductTemplate template = ProductTemplateDataSource.Load(ptid); if (template != null) { _Product.ProductTemplates.Add(template); } } } } else { HiddenSelectedTemplates.Value = GetTemplateIdList(); } TemplateList.Text = GetTemplateList(); }
public async Task InitializeData() { _dbContext.Database.EnsureDeleted(); if (_dbContext.Database.EnsureCreated()) { //seeding AppUser leraar = new AppUser { UserName = "******", Email = "*****@*****.**" }; await CreateUser(leraar, "P@ssword1"); // category template CategoryTemplate ct1 = new CategoryTemplate { CategoryName = "default categorytemplate", AddedByGO = true, CategoryDescr = "default categorytemplate descr" }; //application domain ApplicationDomain energie = new ApplicationDomain { ApplicationDomainName = "Energie", ApplicationDomainDescr = "Alles over energie" }; ApplicationDomain informatie = new ApplicationDomain { ApplicationDomainName = "Informatie & communicactie", ApplicationDomainDescr = "Alles over informatie & communicactie" }; ApplicationDomain constructie = new ApplicationDomain { ApplicationDomainName = "Constructie", ApplicationDomainDescr = "Alles over constructie" }; ApplicationDomain transport = new ApplicationDomain { ApplicationDomainName = "Transport", ApplicationDomainDescr = "Alles over transport" }; ApplicationDomain biochemie = new ApplicationDomain { ApplicationDomainName = "Biochemie", ApplicationDomainDescr = "Alles over biochemie" }; //school School schoolGO = new School { Name = "Go school", Email = "*****@*****.**", TelNum = "049746382", Adres = new Adres { Straat = "straat", Postcode = "8490", Huisnummer = "5", Plaats = "Brugge" } }; _dbContext.Add(ct1); _dbContext.Add(schoolGO); _dbContext.Add(energie); _dbContext.Add(informatie); _dbContext.Add(constructie); _dbContext.Add(transport); _dbContext.Add(biochemie); _dbContext.SaveChanges(); //classroom ClassRoom cr = new ClassRoom { Name = "Klas 1", SchoolId = schoolGO.SchoolId }; ClassRoom cr2 = new ClassRoom { Name = "Klas 2", SchoolId = schoolGO.SchoolId }; schoolGO.ClassRooms.Add(cr); schoolGO.ClassRooms.Add(cr2); #region ProductTemplates ProductTemplate pt1 = new ProductTemplate { ProductName = "Karton", Description = "Dit is karton", AddedByGO = true, ProductImage = "https://www.manutan.be/img/S/GRP/ST/AIG2166048.jpg", Score = 9, HasMultipleDisplayVariations = true, CategoryTemplateId = ct1.CategoryTemplateId, SchoolId = schoolGO.SchoolId, ProductVariationTemplates = new List <ProductVariationTemplate> { new ProductVariationTemplate { ProductDescr = "Algemene beschrijving karton", ESchoolGrade = ESchoolGrade.ALGEMEEN }, new ProductVariationTemplate { ProductDescr = "Eerste graad beschrijving karton", ESchoolGrade = ESchoolGrade.EERSTE }, new ProductVariationTemplate { ProductDescr = "Tweede graad beschrijving karton", ESchoolGrade = ESchoolGrade.TWEEDE }, new ProductVariationTemplate { ProductDescr = "Derde graad beschrijving karton", ESchoolGrade = ESchoolGrade.DERDE } } }; ProductTemplate pt2 = new ProductTemplate { ProductName = "Lijm", Description = "Dit is lijm", AddedByGO = true, ProductImage = "https://www.manutan.be/img/S/GRP/ST/AIG2399133.jpg", Score = 6, HasMultipleDisplayVariations = true, CategoryTemplateId = ct1.CategoryTemplateId, SchoolId = schoolGO.SchoolId, ProductVariationTemplates = new List <ProductVariationTemplate> { new ProductVariationTemplate { ProductDescr = "Algemene beschrijving Lijm", ESchoolGrade = ESchoolGrade.ALGEMEEN }, new ProductVariationTemplate { ProductDescr = "Eerste graad beschrijving Lijm", ESchoolGrade = ESchoolGrade.EERSTE }, new ProductVariationTemplate { ProductDescr = "Tweede graad beschrijving Lijm", ESchoolGrade = ESchoolGrade.TWEEDE }, new ProductVariationTemplate { ProductDescr = "Derde graad beschrijving Lijm", ESchoolGrade = ESchoolGrade.DERDE } } }; ProductTemplate pt3 = new ProductTemplate { ProductName = "Plakband", Description = "Dit is Plakband", AddedByGO = true, ProductImage = "https://www.manutan.be/img/S/GRP/ST/AIG2328457.jpg", Score = 5, HasMultipleDisplayVariations = true, CategoryTemplateId = ct1.CategoryTemplateId, SchoolId = schoolGO.SchoolId, ProductVariationTemplates = new List <ProductVariationTemplate> { new ProductVariationTemplate { ProductDescr = "Algemene beschrijving Plakband", ESchoolGrade = ESchoolGrade.ALGEMEEN }, new ProductVariationTemplate { ProductDescr = "Eerste graad beschrijving Plakband", ESchoolGrade = ESchoolGrade.EERSTE }, new ProductVariationTemplate { ProductDescr = "Tweede graad beschrijving Plakband", ESchoolGrade = ESchoolGrade.TWEEDE }, new ProductVariationTemplate { ProductDescr = "Derde graad beschrijving Plakband", ESchoolGrade = ESchoolGrade.DERDE } } }; ProductTemplate pt4 = new ProductTemplate { ProductName = "Hout", Description = "Dit is hout", AddedByGO = true, ProductImage = "https://cdn.webshopapp.com/shops/34832/files/96705407/800x600x1/van-gelder-hout-schuttingplanken.jpg", Score = 8, HasMultipleDisplayVariations = true, CategoryTemplateId = ct1.CategoryTemplateId, SchoolId = schoolGO.SchoolId, ProductVariationTemplates = new List <ProductVariationTemplate> { new ProductVariationTemplate { ProductDescr = "Algemene beschrijving hout", ESchoolGrade = ESchoolGrade.ALGEMEEN }, new ProductVariationTemplate { ProductDescr = "Eerste graad beschrijving Hout", ESchoolGrade = ESchoolGrade.EERSTE }, new ProductVariationTemplate { ProductDescr = "Tweede graad beschrijving Hout", ESchoolGrade = ESchoolGrade.TWEEDE }, new ProductVariationTemplate { ProductDescr = "Derde graad beschrijving Hout", ESchoolGrade = ESchoolGrade.DERDE } } }; schoolGO.AddProductTemplate(pt1); schoolGO.AddProductTemplate(pt2); schoolGO.AddProductTemplate(pt3); schoolGO.AddProductTemplate(pt4); _dbContext.SaveChanges(); #endregion #region ProjectTemplate ProjectTemplate projectTemplate = new ProjectTemplate { AddedByGO = true, ProjectDescr = "Dit is een project voor energie", ProjectImage = "image", ProjectName = "Energie kennismaking", SchoolId = schoolGO.SchoolId, Budget = 20, MaxScore = 25, ApplicationDomainId = energie.ApplicationDomainId }; projectTemplate.AddProductTemplate(pt2); projectTemplate.AddProductTemplate(pt3); projectTemplate.AddProductTemplate(pt4); schoolGO.AddProjectTemplate(projectTemplate); _dbContext.SaveChanges(); #endregion Category cat1 = new Category { CategoryName = "Bouwmaterialen", CategoryDescr = "Zaken waarmee je kan bouwen" }; Category cat2 = new Category { CategoryName = "Diverse", CategoryDescr = "Andere gevallen" }; Product pr1 = new Product { Category = cat1, ProductName = "Hout", Description = "Algemene beschrijving van hout", Price = 5, Score = 8, ProductImage = "https://d16m3dafbknje9.cloudfront.net/imagescaler/9048544313374-500-500.jpg" }; Product pr2 = new Product { Category = cat1, ProductName = "Papier", Description = "Algemene beschrijving van papier", Price = 3, Score = 7, ProductImage = "http://tmib.com/wp-content/uploads/2014/08/stack-of-paper.jpg" }; Product pr3 = new Product { Category = cat1, ProductName = "Plastiek", Description = "Algemene beschrijving van plastiek", Price = 10, Score = 2, ProductImage = "https://img.etimg.com/thumb/msid-70477420,width-640,resizemode-4,imgsize-251889/the-most-recycled-plastic.jpg" }; Product pr4 = new Product { Category = cat2, ProductName = "Plakband", Description = "Algemene beschrijving van plakband", Price = 10, Score = 6, ProductImage = "https://discountoffice.nl/productImages/8/large/Q800250-3.jpg" }; Group groep1 = new Group { GroupId = 1, GroupName = "Groep 1", GroupCode = "abcde" }; Group groep2 = new Group { GroupId = 2, GroupName = "Groep 2", GroupCode = "12345" }; Group groep3 = new Group { GroupId = 3, GroupName = "Groep 3", GroupCode = "azert" }; groep2.InitOrder(); groep3.InitOrder(); //Projecten toevoegen //Project dat gestart is met 1 groep en 1 product Project project1 = new Project { ProjectBudget = 200, ProjectDescr = "Dit is een project over energie waar je iets leert over hechtingen, licht en schaduw via Reus en Dwerg.", ProjectImage = "image", ProjectName = "Ontdekdozen (hechtingen + licht/schaduw)", ApplicationDomainId = energie.ApplicationDomainId, ESchoolGrade = ESchoolGrade.ALGEMEEN, }; project1.AddProduct(pr1); project1.AddGroup(groep1); project1.AddGroup(groep3); cr.AddProject(project1); _dbContext.SaveChanges(); #region Add evaluations for group 1 and 3 #endregion _dbContext.SaveChanges(); //Project dat gestart is met 1 groep en 3 producten Project project2 = new Project { ProjectBudget = 100, ProjectDescr = "Dit is een project over informatie en communicatie waarbij je leert seinen en blazen.", ProjectImage = "image", ProjectName = "Ontdekdozen (leren blazen + seinen)", ApplicationDomainId = informatie.ApplicationDomainId, ESchoolGrade = ESchoolGrade.ALGEMEEN, }; project2.AddProduct(pr1); project2.AddProduct(pr2); project2.AddProduct(pr3); project2.AddProduct(pr4); project2.AddGroup(groep2); cr.AddProject(project2); _dbContext.SaveChanges(); //Project dat gestart is met geen groepen en geen producten Project project3 = new Project { ProjectBudget = 300, ProjectDescr = "Dit is een project over constructie waarbij je een muurtje maakt via het verhaal van de 3 biggetjes", ProjectImage = "image", ProjectName = "Ontdekdozen (bouwen)", ApplicationDomainId = constructie.ApplicationDomainId, ESchoolGrade = ESchoolGrade.ALGEMEEN, }; cr.AddProject(project3); _dbContext.SaveChanges(); //Project dat gesloten is met geen groepen en geen producten Project project4 = new Project { ProjectBudget = 300, ProjectDescr = "Dit is een project over transport waarbij je een beetje maakt.", ProjectImage = "image", ProjectName = "Ontdekdozen (drijven/zinken)", ApplicationDomainId = transport.ApplicationDomainId, ESchoolGrade = ESchoolGrade.EERSTE, Closed = true, }; cr.AddProject(project4); _dbContext.SaveChanges(); groep1.Order = new Order { OrderItems = new List <OrderItem> { new OrderItem { ProductId = pr1.ProductId, Amount = 2 } } }; _dbContext.SaveChanges(); groep1.AddPupil( new Pupil { FirstName = "Daan", Surname = "Dedecker", SchoolId = schoolGO.SchoolId }); groep1.AddPupil( new Pupil { FirstName = "Rambo", Surname = "Jansens", SchoolId = schoolGO.SchoolId }); groep1.AddPupil( new Pupil { FirstName = "Piet", Surname = "Petter", SchoolId = schoolGO.SchoolId }); _dbContext.SaveChanges(); Project projectCr2 = new Project { ProjectBudget = 200, ProjectDescr = "Een project van klas 2", ProjectImage = "image", ProjectName = "Ontdekdozen ", ApplicationDomainId = energie.ApplicationDomainId, ESchoolGrade = ESchoolGrade.ALGEMEEN, }; cr2.AddProject(projectCr2); _dbContext.SaveChanges(); } }
static async Task MainAsync(string[] args) { try { var productTemplate = new ProductTemplate <GenericProductV1>(Guid.NewGuid(), new GenericProductV1() { Services = { { "OxygenId", Guid.NewGuid().ToString() }, { "StoratePlatformId", Guid.NewGuid().ToString() } } } ) { DocumentMetaData = new DocumentMetaData(typeof(GenericProductV1).FullName, "1.0") }; string output = productTemplate.DocumentJson; List <Guid> productGuids = new List <Guid>(); productGuids.Add(productTemplate.Id); // Product Templates var ptRes = await CassandraDAO.CreateProductTemplateAsync(productTemplate); // make a double to test insert by type. productTemplate.DocumentMetaData.Version = "1.1"; productTemplate.Id = Guid.NewGuid(); productGuids.Add(productTemplate.Id); ptRes = await CassandraDAO.CreateProductTemplateAsync(productTemplate); Console.WriteLine("-----------------------------------------------"); foreach (var id in productGuids) { var ptRead = await CassandraDAO.FindProductTemplateByIdAsync(id); Console.WriteLine(""); Console.WriteLine("ProductTemplate"); Console.WriteLine(ptRead.Json); Console.WriteLine(ptRead.MetaDataJson); Console.WriteLine(ptRead.DocumentJson); } var ptRecords = await CassandraDAO.FindProductTemplateByTypeAsync(productTemplate.MetaData.Type); Console.WriteLine("-----------------------------------------------"); foreach (var ptRecord in ptRecords) { Console.WriteLine(""); Console.WriteLine("ProductTemplate"); Console.WriteLine(ptRecord.Json); Console.WriteLine(ptRecord.MetaDataJson); Console.WriteLine(ptRecord.DocumentJson); } Console.WriteLine("-----------------------------------------------"); productGuids.Clear(); // Bubble var bid = Guid.NewGuid(); var bubbleRecord = new BubbleRecord() { Id = bid, BubbleChainId = Guid.Empty, DeviceId = Guid.Empty, DeviceIdText = null, Name = "Nameof:" + bid }; var bidRes = await CassandraDAO.CreateBubbleRecordAsync(bubbleRecord); var bidRead = await CassandraDAO.FindBubbleRecordByIdAsync(bubbleRecord.Id); Console.WriteLine(""); Console.WriteLine("Bubbles"); Console.WriteLine(bidRead.Json); var label = "Label:" + Guid.NewGuid(); // Product Instance var doc = new GenericProductV1() { Services = { { "OxygenId", Guid.NewGuid().ToString() }, { "StoratePlatformId", Guid.NewGuid().ToString() } } }; var productInstance = new ProductInstance <GenericProductV1>( Guid.NewGuid(), doc, productTemplate.DocumentMetaData, productTemplate.Id, label, bubbleRecord.Id); productGuids.Add(productInstance.Id); var piRes = await CassandraDAO.CreateProductInstanceAsync(productInstance); productInstance.Id = Guid.NewGuid(); productInstance.BubbleId = Guid.NewGuid(); productGuids.Add(productInstance.Id); piRes = await CassandraDAO.CreateProductInstanceAsync(productInstance); Console.WriteLine("-----------------------------------------------"); foreach (var id in productGuids) { var piRead = await CassandraDAO.FindProductInstanceByIdAsync(id); Console.WriteLine(""); Console.WriteLine("ProductInstance"); Console.WriteLine(piRead.Json); Console.WriteLine(piRead.MetaDataJson); Console.WriteLine(piRead.DocumentJson); } Console.WriteLine("-----------------------------------------------"); var piRecords = await CassandraDAO.FindProductInstanceByLabelAsync(productInstance.Label); foreach (var record in piRecords) { Console.WriteLine(""); Console.WriteLine("ProductInstance"); Console.WriteLine(record.Json); Console.WriteLine(record.MetaDataJson); Console.WriteLine(record.DocumentJson); } Console.WriteLine("-----------------------------------------------"); } catch (Exception e) { } }
public Product get_product_dialog(ProductTemplate dialog) { return(new Product()); }
/// <summary> /// Run the code examples. /// </summary> public void Run(DfpUser user) { // Get the ProductTemplateService. ProductTemplateService productTemplateService = (ProductTemplateService)user.GetService(DfpService.v201708.ProductTemplateService); // Get the NetworkService. NetworkService networkService = (NetworkService)user.GetService(DfpService.v201708.NetworkService); // Create a product template. ProductTemplate productTemplate = new ProductTemplate(); productTemplate.name = "Programmatic product template #" + new Random().Next(int.MaxValue); productTemplate.description = "This product template creates programmatic proposal line " + "items targeting all ad units with product segmentation on geo targeting."; // Set the name macro which will be used to generate the names of the products. // This will create a segmentation based on the line item type, ad unit, and location. productTemplate.nameMacro = "<line-item-type> - <ad-unit> - <template-name> - <location>"; // Set the product type so the created proposal line items will be trafficked in DFP. productTemplate.productType = ProductType.DFP; // Set required Marketplace information. productTemplate.productTemplateMarketplaceInfo = new ProductTemplateMarketplaceInfo() { adExchangeEnvironment = AdExchangeEnvironment.DISPLAY, }; // Set rate type to create CPM priced proposal line items. productTemplate.rateType = RateType.CPM; // Create the creative placeholder. CreativePlaceholder creativePlaceholder = new CreativePlaceholder(); creativePlaceholder.size = new Size() { width = 300, height = 250, isAspectRatio = false }; // Set the size of creatives that can be associated with the product template. productTemplate.creativePlaceholders = new CreativePlaceholder[] { creativePlaceholder }; // Set the type of proposal line item to be created from the product template. productTemplate.lineItemType = LineItemType.STANDARD; // Get the root ad unit ID used to target the whole site. String rootAdUnitId = networkService.getCurrentNetwork().effectiveRootAdUnitId; // Create ad unit targeting for the root ad unit (i.e. the whole network). AdUnitTargeting adUnitTargeting = new AdUnitTargeting(); adUnitTargeting.adUnitId = rootAdUnitId; adUnitTargeting.includeDescendants = true; // Create geo targeting for the US. Location countryLocation = new Location(); countryLocation.id = 2840L; // Create geo targeting for Hong Kong. Location regionLocation = new Location(); regionLocation.id = 2344L; GeoTargeting geoTargeting = new GeoTargeting(); geoTargeting.targetedLocations = new Location[] { countryLocation, regionLocation }; // Add inventory and geo targeting as product segmentation. ProductSegmentation productSegmentation = new ProductSegmentation(); productSegmentation.adUnitSegments = new AdUnitTargeting[] { adUnitTargeting }; productSegmentation.geoSegment = geoTargeting; productTemplate.productSegmentation = productSegmentation; try { // Create the product template on the server. ProductTemplate[] productTemplates = productTemplateService.createProductTemplates( new ProductTemplate[] { productTemplate }); foreach (ProductTemplate createdProductTemplate in productTemplates) { Console.WriteLine("A programmatic product template with ID \"{0}\" " + "and name \"{1}\" was created.", createdProductTemplate.id, createdProductTemplate.name); } } catch (Exception e) { Console.WriteLine("Failed to create product templates. Exception says \"{0}\"", e.Message); } }
public static ProductTemplateModel ToModel(this ProductTemplate entity) { return(Mapper.Map <ProductTemplate, ProductTemplateModel>(entity)); }
public DummyApplicationDbContext() { Product testP1 = new Product { ProductId = 1, ProductName = "Karton", Description = "Karton beschrijving", Price = 5 }; Product testP2 = new Product { ProductId = 2, ProductName = "Plastiek", Description = "plastiek beschrijving", Price = 20 }; Product testP3 = new Product { ProductId = 3, ProductName = "Lijm", Description = "Lijm beschrijving", Price = 8.5 }; Product testP4 = new Product { ProductId = 4, ProductName = "Plakband", Description = "Plakband beschrijving", Price = 15 }; OrderItem testOrderItem1 = new OrderItem { OrderItemId = 1, Product = testP1, Amount = 2, ProductId = 1 }; OrderItem testOrderItem2 = new OrderItem { OrderItemId = 2, Product = testP2, Amount = 1, ProductId = 2 }; OrderItem testOrderItem3 = new OrderItem { OrderItemId = 3, Product = testP3, Amount = 3, ProductId = 3 }; testOrderItem = new OrderItem { OrderItemId = 4, Product = testP4, Amount = 5, ProductId = 4 }; testOrder = new Order { OrderId = 1, Approved = false, Submitted = false, OrderItems = new List <OrderItem> { testOrderItem1, testOrderItem2, testOrderItem3 } }; ApplicationDomain applicationDomainTest = new ApplicationDomain { ApplicationDomainId = 1, ApplicationDomainName = "naam", ApplicationDomainDescr = "niet veel speciaals" }; testGroup = new Group { GroupId = 1, GroupName = "groepsnaam", Order = testOrder }; testProject = new Project { ProjectName = "testproject", ProjectDescr = "ceci est une beschrijving", ProjectImage = "url", ProjectBudget = 20, ESchoolGrade = ESchoolGrade.ALGEMEEN, Closed = false, ApplicationDomainId = 1 }; projectTemplate1 = new ProjectTemplate { ProjectName = "DitIsEenTest", ProjectDescr = "Dit is een test voor rojecttemplate", ProjectImage = "ceci n'est pas une url", AddedByGO = true, ApplicationDomainId = 1, ApplicationDomain = applicationDomainTest, ProductTemplateProjectTemplates = new List <ProductTemplateProjectTemplate>() }; projectTemplate2 = new ProjectTemplate { ProjectName = "DitIsEenAndereTest", ProjectDescr = "Dit is 2e een test voor projecttemplate", ProjectImage = "ceci n'est aussie pas une url", AddedByGO = false, ApplicationDomainId = 2 }; producttemplate1 = new ProductTemplate { ProductName = "DitIsEenProductTemplateTest", Description = "dit is een beschrijving voor een producttemplate", ProductImage = "dit is ook geen url", AddedByGO = true }; producttemplate2 = new ProductTemplate { ProductName = "DitIsEentweedeProductTemplateTest", Description = "dit is een beschrijving voor een andere producttemplate", ProductImage = "dit is ook geen url, zot eh", AddedByGO = false }; }
/// <summary> /// Delete product template /// </summary> /// <param name="productTemplate">Product template</param> public virtual void DeleteProductTemplate(ProductTemplate productTemplate) { _productTemplateRepository.Delete(productTemplate); }
static async Task MainAsync(string[] args) { try { var productTemplate = new ProductTemplate<GenericProductV1>(Guid.NewGuid(), new GenericProductV1() { Services = { {"OxygenId", Guid.NewGuid().ToString()}, {"StoratePlatformId", Guid.NewGuid().ToString()} } } ) { DocumentMetaData = new DocumentMetaData(typeof(GenericProductV1).FullName,"1.0") }; string output = productTemplate.DocumentJson; List<Guid> productGuids = new List<Guid>(); productGuids.Add(productTemplate.Id); // Product Templates var ptRes = await CassandraDAO.CreateProductTemplateAsync(productTemplate); // make a double to test insert by type. productTemplate.DocumentMetaData.Version = "1.1"; productTemplate.Id = Guid.NewGuid(); productGuids.Add(productTemplate.Id); ptRes = await CassandraDAO.CreateProductTemplateAsync(productTemplate); Console.WriteLine("-----------------------------------------------"); foreach (var id in productGuids) { var ptRead = await CassandraDAO.FindProductTemplateByIdAsync(id); Console.WriteLine(""); Console.WriteLine("ProductTemplate"); Console.WriteLine(ptRead.Json); Console.WriteLine(ptRead.MetaDataJson); Console.WriteLine(ptRead.DocumentJson); } var ptRecords = await CassandraDAO.FindProductTemplateByTypeAsync(productTemplate.MetaData.Type); Console.WriteLine("-----------------------------------------------"); foreach (var ptRecord in ptRecords) { Console.WriteLine(""); Console.WriteLine("ProductTemplate"); Console.WriteLine(ptRecord.Json); Console.WriteLine(ptRecord.MetaDataJson); Console.WriteLine(ptRecord.DocumentJson); } Console.WriteLine("-----------------------------------------------"); productGuids.Clear(); // Bubble var bid = Guid.NewGuid(); var bubbleRecord = new BubbleRecord() { Id = bid, BubbleChainId = Guid.Empty, DeviceId = Guid.Empty, DeviceIdText = null, Name = "Nameof:" + bid }; var bidRes = await CassandraDAO.CreateBubbleRecordAsync(bubbleRecord); var bidRead = await CassandraDAO.FindBubbleRecordByIdAsync(bubbleRecord.Id); Console.WriteLine(""); Console.WriteLine("Bubbles"); Console.WriteLine(bidRead.Json); var label = "Label:" + Guid.NewGuid(); // Product Instance var doc = new GenericProductV1() { Services = { {"OxygenId", Guid.NewGuid().ToString()}, {"StoratePlatformId", Guid.NewGuid().ToString()} } }; var productInstance = new ProductInstance<GenericProductV1>( Guid.NewGuid(), doc, productTemplate.DocumentMetaData, productTemplate.Id, label, bubbleRecord.Id); productGuids.Add(productInstance.Id); var piRes = await CassandraDAO.CreateProductInstanceAsync(productInstance); productInstance.Id = Guid.NewGuid(); productInstance.BubbleId = Guid.NewGuid(); productGuids.Add(productInstance.Id); piRes = await CassandraDAO.CreateProductInstanceAsync(productInstance); Console.WriteLine("-----------------------------------------------"); foreach (var id in productGuids) { var piRead = await CassandraDAO.FindProductInstanceByIdAsync(id); Console.WriteLine(""); Console.WriteLine("ProductInstance"); Console.WriteLine(piRead.Json); Console.WriteLine(piRead.MetaDataJson); Console.WriteLine(piRead.DocumentJson); } Console.WriteLine("-----------------------------------------------"); var piRecords = await CassandraDAO.FindProductInstanceByLabelAsync(productInstance.Label); foreach (var record in piRecords) { Console.WriteLine(""); Console.WriteLine("ProductInstance"); Console.WriteLine(record.Json); Console.WriteLine(record.MetaDataJson); Console.WriteLine(record.DocumentJson); } Console.WriteLine("-----------------------------------------------"); } catch (Exception e) { } }
private void btnSaveTemplate_Click(object sender, EventArgs e) { string title = tbTitle.Text.Trim(); if (title.Length == 0) { MessageBox.Show("Chua nhap title!"); return; } string mainTag = tbMainTag.Text.Trim(); if (mainTag.Length == 0) { MessageBox.Show("Chua nhap main tag!"); return; } //string tags = string.Empty; //string description = string.Empty; string tags = tbTags.Text.Trim(); //if (tags.Length == 0) //{ // MessageBox.Show("Chua nhap tags!"); // return; //} string description = tbDescription.Text.Trim(); //if (description.Length == 0) //{ // MessageBox.Show("Chua nhap description!"); // return; //} if (SimpleControl.SimpleControlsList.Count == 0) { MessageBox.Show("Chua chon san pham nao!"); return; } List <ProductData> objList = new List <ProductData>(); if (SimpleControl.SimpleControlsList.Count > 0) { bool error = false; foreach (var item in SimpleControl.SimpleControlsList) { if (item.MyName != "APPAREL") { if (item.CurrentColor == null) { MessageBox.Show("Chua nhap mau cho product " + item.MyName); error = true; break; } } } if (error) { return; } foreach (var item in SimpleControl.SimpleControlsList) { objList.Add(item.ConvertToDynamicObj()); } } ProductTemplate template = new ProductTemplate { Title = title, MainTag = mainTag, Tags = tags, Description = description, Products = objList }; var saveDlg = new SaveFileDialog(); saveDlg.Filter = "Json|*.json"; var result = saveDlg.ShowDialog(); if (result == DialogResult.OK) { File.WriteAllText(saveDlg.FileName, JsonConvert.SerializeObject(template)); CurrentTemplate = template; MessageBox.Show("Saved!"); } }
public HttpResponseMessage UpdateProduct(ProductTemplate product) { var result = ProductService.UpdateProduct(product); return(ControllerHelper.GetJsonResponseMessage(result)); }
public string UploadDesign(ProductTemplate template, string logoName) { // try { Thread.Sleep(1000); string title = template.Title.Replace("{NAME}", logoName); var titleInput = GetElement(webDriver, By.Name("design[design_title]")); titleInput.Clear(); titleInput.SendKeys(title); Thread.Sleep(500); if (!string.IsNullOrEmpty(template.Description)) { string des = template.Description.Replace("{NAME}", logoName); var desInput = webDriver.FindElement(By.Name("design[design_description]")); desInput.Clear(); desInput.SendKeys(des); Thread.Sleep(500); } string mainTag = template.MainTag.Replace("{NAME}", logoName); var mainTagInput = webDriver.FindElement(By.Name("design[primary_tag]")); mainTagInput.Clear(); mainTagInput.SendKeys(mainTag); Thread.Sleep(1500); //if (!string.IsNullOrEmpty(template.Tags)) //{ // var tagInput = webDriver.FindElement(By.XPath("//input[@class='select2-input select2-default']")); // tagInput.Clear(); // tagInput.SendKeys(template.Tags); // Thread.Sleep(500); // tagInput.SendKeys(","); // Thread.Sleep(1000); //} // for (int i = 0; i < template.Products.Count; i++) { var product = template.Products[i]; if (product.ProductType == (int)ProductType.APPAREL) { if (!product.UseDefault) { ClickPanel("T-Shirt"); // update slider var input = webDriver.FindElement(By.XPath("//input[@name='design[print_mockup_config_attributes][image_size]']")); ChangeToInputAndSetText(webDriver, input, ((int)product.SizePercent).ToString()); } for (int k = 0; k < product.ShirtColors.Count; k++) { var shirtColor = product.ShirtColors[k]; if (shirtColor.Name == "Baseball Tee" || shirtColor.Name == "T-Shirt") { SelectOption("primary_color_" + shirtColor.Name.ToLower().Replace("-", "") .Replace(" ", ""), shirtColor.Color); } } } else if (product.ProductType == (int)ProductType.PRINTS) { if (!product.UseDefault) { ClickPanel(product.Name); if (product.FullBleedPrint) { var bleedInput = webDriver.FindElement(By.XPath("//input[@name='design[print_mockup_config_attributes][scale_to_fill]']")); var divParent = bleedInput.FindElement(By.XPath("..")); DivClick(webDriver, divParent, 1); } else { // update slider var input = webDriver.FindElement(By.XPath("//input[@name='design[print_mockup_config_attributes][image_size]']")); ChangeToInputAndSetText(webDriver, input, ((int)product.SizePercent).ToString()); // update color var colorInput = webDriver.FindElement(By.XPath("//input[@name='design[print_mockup_config_attributes][bg_color]']")); colorInput.Clear(); colorInput.SendKeys(product.HexColor); Thread.Sleep(500); } var orientInput = webDriver.FindElement(By.XPath("//input[@class='" + product.OrientationType.ToLower() + "']")); DivClick(webDriver, orientInput, 1); var aspectInput = webDriver.FindElement(By.XPath("//input[@data-name='" + product.AspectRatio + "']")); DivClick(webDriver, aspectInput, 1); } } else { if (!product.UseDefault) { ClickPanel(product.Name); string item1 = string.Empty; string color1 = string.Empty; string color2 = string.Empty; string item2 = string.Empty; if (product.Name == "CASE") { item1 = "design[case_mockup_config_attributes][image_size]"; color1 = "design[case_mockup_config_attributes][bg_color]"; item2 = "design[laptop_case_mockup_config_attributes][image_size]"; color2 = "design[laptop_case_mockup_config_attributes][bg_color]"; } else if (product.Name == "NOTEBOOK") { item1 = "design[hardcover_notebook_mockup_config_attributes][image_size]"; color1 = "design[hardcover_notebook_mockup_config_attributes][bg_color]"; item2 = "design[spiral_notebook_mockup_config_attributes][image_size]"; color2 = "design[spiral_notebook_mockup_config_attributes][bg_color]"; } else if (product.Name == "MUG") { item1 = "design[coffee_mug_mockup_config_attributes][image_size]"; color1 = "design[coffee_mug_mockup_config_attributes][bg_color]"; item2 = "design[travel_mug_mockup_config_attributes][image_size]"; color2 = "design[travel_mug_mockup_config_attributes][bg_color]"; } // update slider var input = webDriver.FindElement(By.XPath("//input[@name='" + item1 + "']")); ChangeToInputAndSetText(webDriver, input, ((int)product.SizePercent).ToString()); // update color var colorInput = webDriver.FindElement(By.XPath("//input[@name='" + color1 + "']")); colorInput.Clear(); colorInput.SendKeys(product.HexColor); Thread.Sleep(1000); // update slider var input2 = webDriver.FindElement(By.XPath("//input[@name='" + item2 + "']")); ChangeToInputAndSetText(webDriver, input2, ((int)product.SizePercent).ToString()); // update color var colorInput2 = webDriver.FindElement(By.XPath("//input[@name='" + color2 + "']")); colorInput2.Clear(); colorInput2.SendKeys(product.HexColor); Thread.Sleep(1000); } } } //SelectOption("primary_color_tshirt", "Black"); //SelectOption("primary_color_baseballtee", "Black/White"); //var tshirtInput = webDriver.FindElement(By.Id("primary_color_tshirt")); //var label = tshirtInput.FindElement(By.XPath(".//label[contains(., Black)]")); //var ahref = label.FindElement(By.XPath("..")); //ahref.Click(); // term var ahref = webDriver.FindElement(By.Id("terms")); ahref.Click(); Thread.Sleep(1000); var submitBtn = webDriver.FindElement(By.XPath("//input[@class='publish-and-promote-button btn big green']")); submitBtn.Click(); Thread.Sleep(2000); return(webDriver.Url); } ////catch (Exception ex) ////{ //// logger.ErrorFormat("Login error: {0}, stacktrace: {1}", ex.Message, ex.StackTrace); ////} }
public async Task <ProductAggregate> Process(Stream csvStream) { var streamReader = new StreamReader(csvStream); List <string> lines = new List <string>(); while (!streamReader.EndOfStream) { lines.Add(await streamReader.ReadLineAsync()); } var headers = lines.Take(1).SelectMany(a => a.Split(',')).ToArray(); var values = lines.Skip(1).ToArray(); var productTemplateDictionary = new Dictionary <string, int>(); var productCatalogDictionary = new Dictionary <string, int>(); var productDetailsDictionary = new Dictionary <string, int>(); var productCatalogs = new List <ProductCatalog>(); var productTemplates = new List <ProductTemplate>(); var productCatalogType = typeof(ProductCatalog); var productTemplateType = typeof(ProductCatalog); for (int i = 0; i < headers.Count(); i++) { if (productCatalogType.GetProperties().Any(prop => prop.Name == headers[i])) { productCatalogDictionary.Add(headers[i], i); } if (productTemplateType.GetProperties().Any(prop => prop.Name == headers[i])) { productTemplateDictionary.Add(headers[i], i); } if (productTemplateType.GetProperties().All(prop => prop.Name != headers[i]) && productCatalogType.GetProperties().All(prop => prop.Name != headers[i])) { productDetailsDictionary.Add(headers[i], i); } } var productTemplateGroup = new HashSet <string>(); for (int i = 0; i < values.Length; i++) { var extraFields = new Dictionary <string, string>(); var line = values[i]; var cells = Regex.Split(line, ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)"); if (productTemplateGroup.Contains(cells[productTemplateDictionary["Id"]])) { var productCatalog = new ProductCatalog(); productCatalog.ProductTemplateId = int.Parse(cells[productTemplateDictionary["Id"]]); productCatalog.Id = i + 1; productCatalog.Name = cells[productCatalogDictionary["Name"]]; productCatalog.Price = cells[productCatalogDictionary["Price"]]; productCatalog.Tags = cells[productCatalogDictionary["Tags"]]; foreach (var item in productDetailsDictionary) { if (!string.IsNullOrEmpty(cells[productDetailsDictionary[item.Key]])) { extraFields.Add(item.Key, cells[productDetailsDictionary[item.Key]]); } } productCatalog.Details = JsonSerializer.Serialize(extraFields); productCatalogs.Add(productCatalog); } else { var productCatalog = new ProductCatalog(); var productTemplate = new ProductTemplate(); productTemplateGroup.Add(cells[productTemplateDictionary["Id"]]); productTemplate.Id = int.Parse(cells[productTemplateDictionary["Id"]]); productTemplate.Name = cells[productTemplateDictionary["Name"]]; productCatalog.Id = i + 1; productCatalog.ProductTemplateId = productTemplate.Id; productCatalog.Name = cells[productCatalogDictionary["Name"]]; productCatalog.Price = cells[productCatalogDictionary["Price"]]; productCatalog.Tags = cells[productCatalogDictionary["Tags"]]; foreach (var item in productDetailsDictionary) { if (!string.IsNullOrEmpty(cells[productDetailsDictionary[item.Key]])) { extraFields.Add(item.Key, cells[productDetailsDictionary[item.Key]]); } } productTemplates.Add(productTemplate); productCatalog.Details = JsonSerializer.Serialize(extraFields); productCatalogs.Add(productCatalog); } } var aggregate = new ProductAggregate { ProductTemplates = productTemplates, ProductCatalogs = productCatalogs }; return(await Task.FromResult(aggregate)); }
public ProductResponse FetchProducts(string Query) { // Instance the response ProductResponse response = new ProductResponse(); try { response.KeywordSearch = Query; // replace spaces by | for regexp to process multiple keywords in MYSQL Query = Query.Replace(' ', '|'); DataSet output = new ProductTemplate().FetchAllProducts(Query); // check the row count if (output.Tables[0].Rows.Count == 0) { response.HasProducts = false; response.responseString = "No products available with Query : " + Query; } else { // we have the products // get the unique list of categories DataView dv = new DataView(output.Tables[0]); DataTable UniqueCategories = dv.ToTable(true, "CategoryName"); response.HasProducts = true; response.responseString = "SUCCESS"; response.TotalCategories = UniqueCategories.Rows.Count; // we have the unique categories response.productsByCategory = new List <Category>(); foreach (DataRow dr in UniqueCategories.Rows) { string CategoryName = dr["CategoryName"].ToString(); ProductsByCategory ProductsByCategoryObj = new ProductsByCategory(); ProductsByCategoryObj.SetCategoryName(CategoryName); DataView dvFiltered = new DataView(output.Tables[0]) { RowFilter = "CategoryName = '" + CategoryName + "'" }; List <Products> ProductList = new List <Products>(); // from dv filtered, get all the product details foreach (DataRowView FilteredRow in dvFiltered) { Products ProdObj = new Products { pbsID = int.Parse(FilteredRow["pbsID"].ToString()), ProductName = FilteredRow["productName"].ToString(), Price = Double.Parse(FilteredRow["Price"].ToString()), StoreLogo = FilteredRow["storeLogo"].ToString(), QuantityType = FilteredRow["quantityperunit"].ToString(), ProductImage = FilteredRow["productImage"].ToString() }; ProductList.Add(ProdObj); } ProductsByCategoryObj.SetProductList(ProductList); response.productsByCategory.Add(ProductsByCategoryObj); } } } catch (Exception ex) { // log the event Logger.Instance().Log(Fatal.Instance(), ex); response.HasProducts = false; response.responseString = " Unable to fetch products this time, please try again later. This event has been logged".ToString(); throw ex; } return(response); }
/// <summary> /// Inserts product template /// </summary> /// <param name="productTemplate">Product template</param> public virtual void InsertProductTemplate(ProductTemplate productTemplate) { _productTemplateRepository.Insert(productTemplate); }
/// <summary> /// Updates the product template /// </summary> /// <param name="productTemplate">Product template</param> public virtual void UpdateProductTemplate(ProductTemplate productTemplate) { _productTemplateRepository.Update(productTemplate); }
public Product get_product_dialog(ProductTemplate dialog) { return new Product(); }
/// <summary> /// Inserts product template /// </summary> /// <param name="productTemplate">Product template</param> /// <returns>A task that represents the asynchronous operation</returns> public virtual async Task InsertProductTemplateAsync(ProductTemplate productTemplate) { await _productTemplateRepository.InsertAsync(productTemplate); }
/// <summary> /// Run the code examples. /// </summary> /// <param name="user">The DFP user object running the code examples.</param> public override void Run(DfpUser user) { // Get the ProductTemplateService. ProductTemplateService productTemplateService = (ProductTemplateService) user.GetService(DfpService.v201508.ProductTemplateService); // Get the NetworkService. NetworkService networkService = (NetworkService) user.GetService(DfpService.v201508.NetworkService); // Create a product template. ProductTemplate productTemplate = new ProductTemplate(); productTemplate.name = "Product template #" + new Random().Next(int.MaxValue); productTemplate.description = "This product template creates standard proposal line items " + "targeting Chrome browsers with product segmentation on ad units and geo targeting."; // Set the name macro which will be used to generate the names of the products. // This will create a segmentation based on the line item type, ad unit, and location. productTemplate.nameMacro = "<line-item-type> - <ad-unit> - <template-name> - <location>"; // Set the product type so the created proposal line items will be trafficked in DFP. productTemplate.productType = ProductType.DFP; // Set rate type to create CPM priced proposal line items. productTemplate.rateType = RateType.CPM; // Optionally set the creative rotation of the product to serve one or more creatives. productTemplate.roadblockingType = RoadblockingType.ONE_OR_MORE; // Create the master creative placeholder. CreativePlaceholder creativeMasterPlaceholder = new CreativePlaceholder(); creativeMasterPlaceholder.size = new Size() {width = 728, height = 90, isAspectRatio = false}; // Create companion creative placeholders. CreativePlaceholder companionCreativePlaceholder = new CreativePlaceholder(); companionCreativePlaceholder.size = new Size() {width = 300, height = 250, isAspectRatio = false}; // Set the size of creatives that can be associated with the product template. productTemplate.creativePlaceholders = new CreativePlaceholder[] {creativeMasterPlaceholder, companionCreativePlaceholder}; // Set the type of proposal line item to be created from the product template. productTemplate.lineItemType = LineItemType.STANDARD; // Get the root ad unit ID used to target the whole site. String rootAdUnitId = networkService.getCurrentNetwork().effectiveRootAdUnitId; // Create ad unit targeting for the root ad unit (i.e. the whole network). AdUnitTargeting adUnitTargeting = new AdUnitTargeting(); adUnitTargeting.adUnitId = rootAdUnitId; adUnitTargeting.includeDescendants = true; // Create geo targeting for the US. Location countryLocation = new Location(); countryLocation.id = 2840L; // Create geo targeting for Hong Kong. Location regionLocation = new Location(); regionLocation.id = 2344L; GeoTargeting geoTargeting = new GeoTargeting(); geoTargeting.targetedLocations = new Location[] {countryLocation, regionLocation}; // Add browser targeting to Chrome on the product template distinct from product // segmentation. Browser chromeBrowser = new Browser(); chromeBrowser.id = 500072L; BrowserTargeting browserTargeting = new BrowserTargeting(); browserTargeting.browsers = new Browser[] {chromeBrowser}; TechnologyTargeting technologyTargeting = new TechnologyTargeting(); technologyTargeting.browserTargeting = browserTargeting; Targeting productTemplateTargeting = new Targeting(); productTemplateTargeting.technologyTargeting = technologyTargeting; productTemplate.builtInTargeting = productTemplateTargeting; // Add inventory and geo targeting as product segmentation. ProductSegmentation productSegmentation = new ProductSegmentation(); productSegmentation.adUnitSegments = new AdUnitTargeting[] {adUnitTargeting}; productSegmentation.geoSegment = geoTargeting; productTemplate.productSegmentation = productSegmentation; try { // Create the product template on the server. ProductTemplate[] productTemplates = productTemplateService.createProductTemplates( new ProductTemplate[] {productTemplate}); foreach (ProductTemplate createdProductTemplate in productTemplates) { Console.WriteLine("A product template with ID \"{0}\" and name \"{1}\" was created.", createdProductTemplate.id, createdProductTemplate.name); } } catch (Exception e) { Console.WriteLine("Failed to create product templates. Exception says \"{0}\"", e.Message); } }
/// <summary> /// Run the code examples. /// </summary> public void Run(DfpUser user) { // Get the ProductTemplateService. ProductTemplateService productTemplateService = (ProductTemplateService)user.GetService(DfpService.v201705.ProductTemplateService); // Get the NetworkService. NetworkService networkService = (NetworkService)user.GetService(DfpService.v201705.NetworkService); // Create a product template. ProductTemplate productTemplate = new ProductTemplate(); productTemplate.name = "Product template #" + new Random().Next(int.MaxValue); productTemplate.description = "This product template creates standard proposal line items " + "targeting Chrome browsers with product segmentation on ad units and geo targeting."; // Set the name macro which will be used to generate the names of the products. // This will create a segmentation based on the line item type, ad unit, and location. productTemplate.nameMacro = "<line-item-type> - <ad-unit> - <template-name> - <location>"; // Set the product type so the created proposal line items will be trafficked in DFP. productTemplate.productType = ProductType.DFP; // Set rate type to create CPM priced proposal line items. productTemplate.rateType = RateType.CPM; // Optionally set the creative rotation of the product to serve one or more creatives. productTemplate.roadblockingType = RoadblockingType.ONE_OR_MORE; productTemplate.deliveryRateType = DeliveryRateType.AS_FAST_AS_POSSIBLE; // Create the master creative placeholder. CreativePlaceholder creativeMasterPlaceholder = new CreativePlaceholder(); creativeMasterPlaceholder.size = new Size() { width = 728, height = 90, isAspectRatio = false }; // Create companion creative placeholders. CreativePlaceholder companionCreativePlaceholder = new CreativePlaceholder(); companionCreativePlaceholder.size = new Size() { width = 300, height = 250, isAspectRatio = false }; // Set the size of creatives that can be associated with the product template. productTemplate.creativePlaceholders = new CreativePlaceholder[] { creativeMasterPlaceholder, companionCreativePlaceholder }; // Set the type of proposal line item to be created from the product template. productTemplate.lineItemType = LineItemType.STANDARD; // Get the root ad unit ID used to target the whole site. String rootAdUnitId = networkService.getCurrentNetwork().effectiveRootAdUnitId; // Create ad unit targeting for the root ad unit (i.e. the whole network). AdUnitTargeting adUnitTargeting = new AdUnitTargeting(); adUnitTargeting.adUnitId = rootAdUnitId; adUnitTargeting.includeDescendants = true; // Create geo targeting for the US. Location countryLocation = new Location(); countryLocation.id = 2840L; // Create geo targeting for Hong Kong. Location regionLocation = new Location(); regionLocation.id = 2344L; GeoTargeting geoTargeting = new GeoTargeting(); geoTargeting.targetedLocations = new Location[] { countryLocation, regionLocation }; // Add browser targeting to Chrome on the product template distinct from product // segmentation. Browser chromeBrowser = new Browser(); chromeBrowser.id = 500072L; BrowserTargeting browserTargeting = new BrowserTargeting(); browserTargeting.browsers = new Browser[] { chromeBrowser }; TechnologyTargeting technologyTargeting = new TechnologyTargeting(); technologyTargeting.browserTargeting = browserTargeting; Targeting productTemplateTargeting = new Targeting(); productTemplateTargeting.technologyTargeting = technologyTargeting; productTemplate.builtInTargeting = productTemplateTargeting; productTemplate.customizableAttributes = new CustomizableAttributes() { allowPlacementTargetingCustomization = true }; // Add inventory and geo targeting as product segmentation. ProductSegmentation productSegmentation = new ProductSegmentation(); productSegmentation.adUnitSegments = new AdUnitTargeting[] { adUnitTargeting }; productSegmentation.geoSegment = geoTargeting; productTemplate.productSegmentation = productSegmentation; try { // Create the product template on the server. ProductTemplate[] productTemplates = productTemplateService.createProductTemplates( new ProductTemplate[] { productTemplate }); foreach (ProductTemplate createdProductTemplate in productTemplates) { Console.WriteLine("A product template with ID \"{0}\" and name \"{1}\" was created.", createdProductTemplate.id, createdProductTemplate.name); } } catch (Exception e) { Console.WriteLine("Failed to create product templates. Exception says \"{0}\"", e.Message); } }
public HttpResponseMessage GetProduct(ProductTemplate product) { var result = OrderService.GetProductById(product.Id, product.Count); return(ControllerHelper.GetJsonResponseMessage(result)); }
public static ProductTemplate ToEntity(this ProductTemplateModel model, ProductTemplate destination) { return(model.MapTo(destination)); }
private void ProcessRules(BreadCrumbItem breadCrumbItem) { int id; if (breadCrumbItem.Url == "#") { return; } switch (breadCrumbItem.Url.ToLowerInvariant()) { case "~/admin/orders/shipments/editshipment.aspx": id = AlwaysConvert.ToInt(Request.QueryString["OrderShipmentId"]); breadCrumbItem.Url += "?OrderShipmentId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, id); break; case "~/admin/products/editproduct.aspx": case "~/admin/products/variants/variants.aspx": case "~/admin/products/variants/options.aspx": case "~/admin/products/digitalgoods/digitalgoods.aspx": case "~/admin/products/kits/editkit.aspx": case "~/admin/products/assets/images.aspx": case "~/admin/products/editproducttemplate.aspx": case "~/admin/products/specials/default.aspx": int categoryId = AbleCommerce.Code.PageHelper.GetCategoryId(); id = AbleCommerce.Code.PageHelper.GetProductId(); Product product = ProductDataSource.Load(id); if (categoryId > 0) { breadCrumbItem.Url += "?CategoryId=" + categoryId + "&ProductId=" + id; } else { breadCrumbItem.Url += "?ProductId=" + id; } breadCrumbItem.Title = string.Format(breadCrumbItem.Title, product.Name); break; case "~/admin/orders/vieworder.aspx": case "~/admin/orders/edit/editorderitems.aspx": case "~/admin/orders/viewdigitalgoods.aspx": case "~/admin/orders/payments/default.aspx": case "~/admin/orders/shipments/default.aspx": id = AbleCommerce.Code.PageHelper.GetOrderId(); Order order = OrderDataSource.Load(id); breadCrumbItem.Url += "?OrderNumber=" + order.OrderNumber; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, order.OrderNumber); break; case "~/admin/marketing/coupons/editcoupon.aspx": id = AlwaysConvert.ToInt(Request.QueryString["CouponId"]); Coupon coupon = CouponDataSource.Load(id); breadCrumbItem.Url += "?CouponId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, coupon.Name); break; case "~/admin/products/variants/editoption.aspx": case "~/admin/products/variants/editchoices.aspx": id = AlwaysConvert.ToInt(Request.QueryString["OptionId"]); Option option = OptionDataSource.Load(id); breadCrumbItem.Url += "?OptionId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, option.Name); break; case "~/admin/products/giftwrap/editwrapgroup.aspx": id = AlwaysConvert.ToInt(Request.QueryString["WrapGroupId"]); WrapGroup wrapGroup = WrapGroupDataSource.Load(id); breadCrumbItem.Url += "?WrapGroupId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, wrapGroup.Name); break; case "~/admin/marketing/email/managelist.aspx": id = AlwaysConvert.ToInt(Request.QueryString["EmailListId"]); EmailList emailList = EmailListDataSource.Load(id); if (emailList != null) { breadCrumbItem.Url += "?EmailListId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, emailList.Name); } break; case "~/admin/marketing/discounts/editdiscount.aspx": id = AlwaysConvert.ToInt(Request.QueryString["VolumeDiscountId"]); VolumeDiscount discount = VolumeDiscountDataSource.Load(id); breadCrumbItem.Url += "?VolumeDiscountId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, discount.Name); break; case "~/admin/catalog/editwebpage.aspx": id = AbleCommerce.Code.PageHelper.GetWebpageId(); Webpage webpage = WebpageDataSource.Load(id); breadCrumbItem.Url += "?WebpageId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, webpage.Name); break; case "~/admin/catalog/editLink.aspx": id = AbleCommerce.Code.PageHelper.GetLinkId(); Link link = LinkDataSource.Load(id); breadCrumbItem.Url += "?LinkId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, link.Name); break; case "~/admin/people/users/edituser.aspx": id = AlwaysConvert.ToInt(Request.QueryString["UserId"]); User user = UserDataSource.Load(id); breadCrumbItem.Url += "?UserId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, user.UserName); break; case "~/admin/digitalgoods/editdigitalgood.aspx": case "~/admin/digitalgoods/serialkeyproviders/defaultprovider/configure.aspx": id = AlwaysConvert.ToInt(Request.QueryString["DigitalGoodId"]); DigitalGood dg = DigitalGoodDataSource.Load(id); if (dg != null) { breadCrumbItem.Url += "?DigitalGoodId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, dg.Name); } break; case "~/admin/products/producttemplates/editproducttemplate.aspx": id = AlwaysConvert.ToInt(Request.QueryString["ProductTemplateId"]); ProductTemplate template = ProductTemplateDataSource.Load(id); if (template == null) { InputField field = InputFieldDataSource.Load(AlwaysConvert.ToInt(Request.QueryString["InputFieldId"])); if (field != null) { template = field.ProductTemplate; id = template.Id; } } if (template != null) { breadCrumbItem.Url += "?ProductTemplateId=" + id; breadCrumbItem.Title = string.Format(breadCrumbItem.Title, template.Name); } else { } break; case "~/admin/reports/dailyabandonedbaskets.aspx": id = AlwaysConvert.ToInt(Request.QueryString["BasketId"]); Basket basket = BasketDataSource.Load(id); if (basket != null) { breadCrumbItem.Url += "?ReportDate=" + basket.User.LastActivityDate.Value.ToShortDateString(); } break; } // resolve relative urls if (breadCrumbItem.Url.StartsWith("~/")) { breadCrumbItem.Url = Page.ResolveUrl(breadCrumbItem.Url); } }
protected ProductTemplate Save() { ProductTemplate productTemplate = ctrlProductTemplateInfo.SaveInfo(); return(productTemplate); }
/// <summary> /// Updates the product template /// </summary> /// <param name="productTemplate">Product template</param> /// <returns>A task that represents the asynchronous operation</returns> public virtual async Task UpdateProductTemplateAsync(ProductTemplate productTemplate) { await _productTemplateRepository.UpdateAsync(productTemplate); }
public void onStoreDataReceived(string data) { if(data.Equals(string.Empty)) { Debug.Log("InAppPurchaseManager, no products avaiable: " + _products.Count.ToString()); dispatch (STORE_KIT_INITIALIZED); return; } string[] storeData; storeData = data.Split("|" [0]); for(int i = 0; i < storeData.Length; i+=7) { ProductTemplate tpl = new ProductTemplate(); tpl.id = storeData[i]; tpl.title = storeData[i + 1]; tpl.description = storeData[i + 2]; tpl.localizedPrice = storeData[i + 3]; tpl.price = storeData[i + 4]; tpl.currencyCode = storeData[i + 5]; tpl.currencySymbol = storeData[i + 6]; _products.Add(tpl); } Debug.Log("InAppPurchaseManager, tottal products loaded: " + _products.Count.ToString()); _IsStoreLoaded = true; _IsWaitingLoadResult = false; dispatch (STORE_KIT_INITIALIZED); }
public static ProductTemplateModel ToModel(this ProductTemplate entity) { return(entity.MapTo <ProductTemplate, ProductTemplateModel>()); }
public void Add(ProductTemplate obj) { _context.Add(obj); }
/// <summary> /// Run the code example. /// </summary> /// <param name="user">The DFP user object running the code example.</param> public override void Run(DfpUser user) { // Get the ProductTemplateService. ProductTemplateService productTemplateService = (ProductTemplateService)user.GetService(DfpService.v201511.ProductTemplateService); // Set the ID of the product template. long productTemplateId = long.Parse(_T("INSERT_PRODUCT_TEMPLATE_ID_HERE")); // Create a statement to get the product template. StatementBuilder statementBuilder = new StatementBuilder() .Where("id = :id") .OrderBy("id ASC") .Limit(1) .AddValue("id", productTemplateId); try { // Get product templates by statement. ProductTemplatePage page = productTemplateService .getProductTemplatesByStatement(statementBuilder.ToStatement()); ProductTemplate productTemplate = page.results[0]; // Add geo targeting for Canada to the product template. Location countryLocation = new Location(); countryLocation.id = 2124L; Targeting productTemplateTargeting = productTemplate.builtInTargeting; GeoTargeting geoTargeting = productTemplateTargeting.geoTargeting; List <Location> existingTargetedLocations = new List <Location>(); if (geoTargeting == null) { geoTargeting = new GeoTargeting(); } else if (geoTargeting.targetedLocations != null) { existingTargetedLocations = new List <Location>(geoTargeting.targetedLocations); } existingTargetedLocations.Add(countryLocation); Location[] newTargetedLocations = new Location[existingTargetedLocations.Count]; existingTargetedLocations.CopyTo(newTargetedLocations); geoTargeting.targetedLocations = newTargetedLocations; productTemplateTargeting.geoTargeting = geoTargeting; productTemplate.builtInTargeting = productTemplateTargeting; // Update the product template on the server. ProductTemplate[] productTemplates = productTemplateService .updateProductTemplates(new ProductTemplate[] { productTemplate }); if (productTemplates != null) { foreach (ProductTemplate updatedProductTemplate in productTemplates) { Console.WriteLine("A product template with ID = '{0}' and name '{1}' was updated.", updatedProductTemplate.id, updatedProductTemplate.name); } } else { Console.WriteLine("No product templates updated."); } } catch (Exception e) { Console.WriteLine("Failed to update product templates. Exception says \"{0}\"", e.Message); } }
public void Remove(ProductTemplate obj) { _context.Remove(obj); }