/// <summary> /// Sets the Add action for a new BiddableAdGroupCriterion corresponding to the specified ProductCondition, /// and adds it to the helper's list of BulkAdGroupProductPartition. /// </summary> /// <param name="parent">The parent of the product partition subdivision that you want to add.</param> /// <param name="condition">The condition or product filter for the new product partition.</param> /// <param name="clientId">The Client Id in the bulk upload file corresponding to the product partition.</param> /// <returns>The BulkAdGroupProductPartition that was added to the list of PartitionActions.</returns> public BulkAdGroupProductPartition AddSubdivision( BulkAdGroupProductPartition parent, ProductCondition condition, string clientId ) { var biddableAdGroupCriterion = new BiddableAdGroupCriterion() { Id = this.referenceId--, Criterion = new ProductPartition() { // If the root node is a unit, it would not have a parent ParentCriterionId = parent != null && parent.AdGroupCriterion != null ? parent.AdGroupCriterion.Id : null, Condition = condition, PartitionType = ProductPartitionType.Subdivision }, CriterionBid = null, AdGroupId = this.adGroupId }; var partitionAction = new BulkAdGroupProductPartition() { ClientId = clientId, AdGroupCriterion = biddableAdGroupCriterion }; this.partitionActions.Add(partitionAction); return(partitionAction); }
/// <summary> /// Sets the Add action for a new BiddableAdGroupCriterion corresponding to the specified ProductCondition, /// and adds it to the helper's list of AdGroupCriterionAction. /// </summary> /// <param name="parent">The parent of the product partition subdivision that you want to add.</param> /// <param name="condition">The condition or product filter for the new product partition.</param> /// <returns>The ad group criterion that was added to the list of PartitionActions.</returns> public AdGroupCriterion AddSubdivision( AdGroupCriterion parent, ProductCondition condition ) { var biddableAdGroupCriterion = new BiddableAdGroupCriterion() { Id = this.referenceId--, Criterion = new ProductPartition() { // If the root node is a unit, it would not have a parent ParentCriterionId = parent != null ? parent.Id : null, Condition = condition, PartitionType = ProductPartitionType.Subdivision }, CriterionBid = null, AdGroupId = this.adGroupId }; var partitionAction = new AdGroupCriterionAction() { Action = ItemAction.Add, AdGroupCriterion = biddableAdGroupCriterion }; this.partitionActions.Add(partitionAction); return(biddableAdGroupCriterion); }
public Product() { Color = ProductColor.Invalid; Warranty = new ProductWarranty(); PicturesUrls = new List <string>(); Condition = ProductCondition.Invalid; Type = "Base Class"; }
public Product(string category, decimal price, string name, string description, ProductCondition productCondition) { Id = Guid.NewGuid(); Category = category; Price = price; SetName(name); SetDescription(description); ProductCondition = productCondition; IsArchived = false; CreatedAt = DateTime.Now; }
/// <summary> /// 分页方法 /// </summary> /// <param name="page"></param> /// <param name="size"></param> /// <param name="sort"></param> /// <param name="condition"></param> /// <returns></returns> public PageModel <Product> GetByPage(int page, int size, string sort, ProductCondition condition) { var dbCondition = new List <DbCondition <Product> > { new DbCondition <Product> { IsWhere = !string.IsNullOrEmpty(condition.Name), Expression = o => o.Name.Contains(condition.Name) } }; return(_unitOfWork.ProductManage.GetByPage(page, size, sort, dbCondition)); }
public async Task EditAsyncShouldSaveProductChanges() { //Arrange const int id = 1; const string nameVaue = "Name"; const string descriptionValue = "Description"; const int brandId = 1; const int categoryId = 1; const string imageUrlValue = "ImageUrl"; const decimal priceValue = 5; const ProductCondition condition = ProductCondition.BrandNew; var product = new Product() { Id = id, Category = new Category(), Brand = new Brand() }; var productFormModel = new ProductFormModel { Name = nameVaue, BrandId = brandId, CategoryId = categoryId, Description = descriptionValue, ImageUrl = imageUrlValue, Price = priceValue, Condition = condition }; //Act this.context.Add(product); await this.context.SaveChangesAsync(); var result = await this.adminProductService.EditAsync(id, productFormModel); var productAfterChanges = this.context .Products .Find(id); //Assert result .Should() .BeTrue(); Assert.Same(product.Name, nameVaue); Assert.Equal(product.BrandId, brandId); Assert.Equal(product.CategoryId, categoryId); Assert.Same(product.Description, descriptionValue); Assert.Same(product.ImageURL, imageUrlValue); Assert.Equal(product.Price, priceValue); Assert.Equal(product.Condition, condition); }
/// <summary> /// Sets the Add action for a new AdGroupCriterion corresponding to the specified ProductCondition, /// and adds it to the helper's list of BulkAdGroupProductPartition. /// </summary> /// <param name="parent">The parent of the product partition unit that you want to add.</param> /// <param name="condition">The condition or product filter for the new product partition.</param> /// <param name="bidAmount">The bid amount for the new product partition.</param> /// <param name="isNegative">Indicates whether or not to add a NegativeAdGroupCriterion. /// The default value is false, in which case a BiddableAdGroupCriterion will be added.</param> /// <returns>The BulkAdGroupProductPartition that was added to the list of PartitionActions.</returns> public BulkAdGroupProductPartition AddUnit( BulkAdGroupProductPartition parent, ProductCondition condition, double bidAmount, bool isNegative, string clientId ) { AdGroupCriterion adGroupCriterion; if (isNegative) { adGroupCriterion = new NegativeAdGroupCriterion(); } else { adGroupCriterion = new BiddableAdGroupCriterion() { CriterionBid = new FixedBid() { Bid = new Bid() { Amount = bidAmount } }, DestinationUrl = "http://www.contoso.com/womenshoesale/?season=spring&promocode=PROMO123", }; } adGroupCriterion.Criterion = new ProductPartition() { // If the root node is a unit, it would not have a parent ParentCriterionId = parent != null && parent.AdGroupCriterion != null ? parent.AdGroupCriterion.Id : null, Condition = condition, PartitionType = ProductPartitionType.Unit }; adGroupCriterion.AdGroupId = this.adGroupId; var partitionAction = new BulkAdGroupProductPartition() { ClientId = clientId, AdGroupCriterion = adGroupCriterion }; this.partitionActions.Add(partitionAction); return(partitionAction); }
/// <summary> /// Sets the Add action for a new AdGroupCriterion corresponding to the specified ProductCondition, /// and adds it to the helper's list of AdGroupCriterionAction. /// </summary> /// <param name="parent">The parent of the product partition unit that you want to add.</param> /// <param name="condition">The condition or product filter for the new product partition.</param> /// <param name="bidAmount">The bid amount for the new product partition.</param> /// <param name="isNegative">Indicates whether or not to add a NegativeAdGroupCriterion. /// The default value is false, in which case a BiddableAdGroupCriterion will be added.</param> /// <returns>The ad group criterion that was added to the list of PartitionActions.</returns> public AdGroupCriterion AddUnit( AdGroupCriterion parent, ProductCondition condition, double bidAmount, bool isNegative ) { AdGroupCriterion adGroupCriterion; if (isNegative) { adGroupCriterion = new NegativeAdGroupCriterion(); } else { adGroupCriterion = new BiddableAdGroupCriterion() { CriterionBid = new FixedBid() { Bid = new Bid() { Amount = bidAmount } } }; } adGroupCriterion.Criterion = new ProductPartition() { // If the root node is a unit, it would not have a parent ParentCriterionId = parent != null ? parent.Id : null, Condition = condition, PartitionType = ProductPartitionType.Unit }; adGroupCriterion.AdGroupId = this.adGroupId; var partitionAction = new AdGroupCriterionAction() { Action = ItemAction.Add, AdGroupCriterion = adGroupCriterion }; this.partitionActions.Add(partitionAction); return(adGroupCriterion); }
public static void Validate(ProductCondition condition) { try { var enumMax = ProductCondition.Invalid; var enumMin = ProductCondition.New; var conditionIsOutOfRange = (condition > enumMax) || (condition < enumMin); if (condition == ProductCondition.Invalid) { throw new ValidationException("Condição do Porduto", "Condição Não Existe"); } if (conditionIsOutOfRange) { throw new ValidationException("Condição do Porduto", "Condição Inválida"); } } catch (Exception e) { throw e; } }
public IActionResult GetByPage(int?page = null, int?size = null, string sort = "addTime desc", ProductCondition condition = null) { if (page.HasValue && size.HasValue && page > 0 && size > 0) { var result = _productService.GetByPage(page.Value, size.Value, sort, condition); return(Ok(new PageModel <ProductDto> { Total = result.Total, Data = Mapper.Map <List <ProductDto> >(result.Data) })); } return(BadRequest()); }
/// <summary> /// Sets the Add action for a new AdGroupCriterion corresponding to the specified ProductCondition, /// and adds it to the helper's list of AdGroupCriterionAction. /// </summary> /// <param name="parent">The parent of the product partition unit that you want to add.</param> /// <param name="condition">The condition or product filter for the new product partition.</param> /// <param name="bidAmount">The bid amount for the new product partition.</param> /// <param name="isNegative">Indicates whether or not to add a NegativeAdGroupCriterion. /// The default value is false, in which case a BiddableAdGroupCriterion will be added.</param> /// <returns>The ad group criterion that was added to the list of PartitionActions.</returns> public AdGroupCriterion AddUnit( AdGroupCriterion parent, ProductCondition condition, double bidAmount, bool isNegative ) { AdGroupCriterion adGroupCriterion; if (isNegative) { adGroupCriterion = new NegativeAdGroupCriterion(); } else { adGroupCriterion = new BiddableAdGroupCriterion() { CriterionBid = new FixedBid() { Bid = new Bid() { Amount = bidAmount } } }; } adGroupCriterion.Criterion = new ProductPartition() { // If the root node is a unit, it would not have a parent ParentCriterionId = parent != null ? parent.Id : null, Condition = condition, PartitionType = ProductPartitionType.Unit }; adGroupCriterion.AdGroupId = this.adGroupId; var partitionAction = new AdGroupCriterionAction() { Action = ItemAction.Add, AdGroupCriterion = adGroupCriterion }; this.partitionActions.Add(partitionAction); return adGroupCriterion; }
/// <summary> /// Sets the Add action for a new BiddableAdGroupCriterion corresponding to the specified ProductCondition, /// and adds it to the helper's list of AdGroupCriterionAction. /// </summary> /// <param name="parent">The parent of the product partition subdivision that you want to add.</param> /// <param name="condition">The condition or product filter for the new product partition.</param> /// <returns>The ad group criterion that was added to the list of PartitionActions.</returns> public AdGroupCriterion AddSubdivision( AdGroupCriterion parent, ProductCondition condition ) { var biddableAdGroupCriterion = new BiddableAdGroupCriterion() { Id = this.referenceId--, Criterion = new ProductPartition() { // If the root node is a unit, it would not have a parent ParentCriterionId = parent != null ? parent.Id : null, Condition = condition, PartitionType = ProductPartitionType.Subdivision }, CriterionBid = null, AdGroupId = this.adGroupId }; var partitionAction = new AdGroupCriterionAction() { Action = ItemAction.Add, AdGroupCriterion = biddableAdGroupCriterion }; this.partitionActions.Add(partitionAction); return biddableAdGroupCriterion; }
/// <summary> /// Sets the Add action for a new AdGroupCriterion corresponding to the specified ProductCondition, /// and adds it to the helper's list of BulkAdGroupProductPartition. /// </summary> /// <param name="parent">The parent of the product partition unit that you want to add.</param> /// <param name="condition">The condition or product filter for the new product partition.</param> /// <param name="bidAmount">The bid amount for the new product partition.</param> /// <param name="isNegative">Indicates whether or not to add a NegativeAdGroupCriterion. /// The default value is false, in which case a BiddableAdGroupCriterion will be added.</param> /// <returns>The BulkAdGroupProductPartition that was added to the list of PartitionActions.</returns> public BulkAdGroupProductPartition AddUnit( BulkAdGroupProductPartition parent, ProductCondition condition, double bidAmount, bool isNegative, string clientId ) { AdGroupCriterion adGroupCriterion; if (isNegative) { adGroupCriterion = new NegativeAdGroupCriterion(); } else { adGroupCriterion = new BiddableAdGroupCriterion() { CriterionBid = new FixedBid() { Bid = new Bid() { Amount = bidAmount } }, DestinationUrl = "http://www.contoso.com/womenshoesale/?season=spring&promocode=PROMO123", }; } adGroupCriterion.Criterion = new ProductPartition() { // If the root node is a unit, it would not have a parent ParentCriterionId = parent != null && parent.AdGroupCriterion != null ? parent.AdGroupCriterion.Id : null, Condition = condition, PartitionType = ProductPartitionType.Unit }; adGroupCriterion.AdGroupId = this.adGroupId; var partitionAction = new BulkAdGroupProductPartition() { ClientId = clientId, AdGroupCriterion = adGroupCriterion }; this.partitionActions.Add(partitionAction); return partitionAction; }
/// <summary> /// Sets the Add action for a new BiddableAdGroupCriterion corresponding to the specified ProductCondition, /// and adds it to the helper's list of BulkAdGroupProductPartition. /// </summary> /// <param name="parent">The parent of the product partition subdivision that you want to add.</param> /// <param name="condition">The condition or product filter for the new product partition.</param> /// <param name="clientId">The Client Id in the bulk upload file corresponding to the product partition.</param> /// <returns>The BulkAdGroupProductPartition that was added to the list of PartitionActions.</returns> public BulkAdGroupProductPartition AddSubdivision( BulkAdGroupProductPartition parent, ProductCondition condition, string clientId ) { var biddableAdGroupCriterion = new BiddableAdGroupCriterion() { Id = this.referenceId--, Criterion = new ProductPartition() { // If the root node is a unit, it would not have a parent ParentCriterionId = parent != null && parent.AdGroupCriterion != null ? parent.AdGroupCriterion.Id : null, Condition = condition, PartitionType = ProductPartitionType.Subdivision }, CriterionBid = null, AdGroupId = this.adGroupId }; var partitionAction = new BulkAdGroupProductPartition() { ClientId = clientId, AdGroupCriterion = biddableAdGroupCriterion }; this.partitionActions.Add(partitionAction); return partitionAction; }
public JsonResult Get(int draw, int start) { var filteredData = _db.ProductInfoes.AsQueryable(); string parameter = Request.Query["search[value]"].FirstOrDefault(); ProductCondition condition = null; if (parameter != "") { condition = (ProductCondition)JsonConvert.DeserializeObject(parameter, typeof(ProductCondition)); } List <ProductInfoes> rows = null; if (condition != null) { if (condition.ProductNo != "") { filteredData = filteredData.Where(e => e.ProductNo.Contains(condition.ProductNo)); } if (condition.ProductName != "") { filteredData = filteredData.Where(e => e.ProductName.Contains(condition.ProductName)); } } int recordsTotal = filteredData.Count(); rows = filteredData.OrderBy(e => e.ProductNo).Skip(start).Take(10).ToList(); var renderModel = new DataTablesRenderModel { draw = draw, data = rows, length = rows.Count(), recordsFiltered = recordsTotal, recordsTotal = recordsTotal }; return(Json(renderModel)); //////////////// //var filteredData = (from p in _db.ProductInfoes // select new // { // p.ProductNo, // p.ProductName, // p.Spec, // p.Unit, // p.Capcity // }).AsQueryable(); //int recordsTotal = _db.ProductInfoes.Count(); //var rows = filteredData.OrderBy(e => e.ProductNo).ToList(); //var rows = filteredData.OrderBy(e => e.ProductNo).Skip(start).Take(10).ToList(); //rows = filteredData.OrderBy(e => e.ProductNo).Where(s => s.ProductNo == searchProductNo).Skip(start).Take(10).ToList(); //var renderModel = new DataTablesRenderModel //{ // draw = draw, // data = rows, // length = rows.Count(), // recordsFiltered = recordsTotal, // recordsTotal = recordsTotal //}; //return Json(renderModel); }
/// <summary> /// Sets the Add action for a new AdGroupCriterion corresponding to the specified ProductCondition, /// and adds it to the helper's list of BulkAdGroupProductPartition. /// </summary> /// <param name="parent">The parent of the product partition unit that you want to add.</param> /// <param name="condition">The condition or product filter for the new product partition.</param> /// <param name="bidAmount">The bid amount for the new product partition.</param> /// <param name="isNegative">Indicates whether or not to add a NegativeAdGroupCriterion. /// The default value is false, in which case a BiddableAdGroupCriterion will be added.</param> /// <returns>The BulkAdGroupProductPartition that was added to the list of PartitionActions.</returns> public BulkAdGroupProductPartition AddUnit( BulkAdGroupProductPartition parent, ProductCondition condition, double bidAmount, bool isNegative, string clientId ) { AdGroupCriterion adGroupCriterion; if (isNegative) { adGroupCriterion = new NegativeAdGroupCriterion(); } else { adGroupCriterion = new BiddableAdGroupCriterion() { CriterionBid = new FixedBid() { Amount = bidAmount }, // This destination URL is used if specified; otherwise, the destination URL is determined // by the corresponding value of the 'Link' that you specified for the product offer // in your Bing Merchant Center catalog. DestinationUrl = null, // You could use a tracking template which would override the campaign level // tracking template. Tracking templates defined for lower level entities // override those set for higher level entities. // In this example we are using the campaign level tracking template. TrackingUrlTemplate = null, // Set custom parameters that are specific to this criterion, // and can be used by the criterion, ad group, campaign, or account level tracking template. // In this example we are using the campaign level tracking template. UrlCustomParameters = new CustomParameters { Parameters = new[] { new CustomParameter() { Key = "promoCode", Value = "PROMO1" }, new CustomParameter() { Key = "season", Value = "summer" }, } } }; } adGroupCriterion.Criterion = new ProductPartition() { // If the root node is a unit, it would not have a parent ParentCriterionId = parent != null && parent.AdGroupCriterion != null ? parent.AdGroupCriterion.Id : null, Condition = condition, PartitionType = ProductPartitionType.Unit }; adGroupCriterion.AdGroupId = this.adGroupId; var partitionAction = new BulkAdGroupProductPartition() { ClientId = clientId, AdGroupCriterion = adGroupCriterion }; this.partitionActions.Add(partitionAction); return(partitionAction); }
public Task CreateAsync(string category, decimal price, string name, string description, ProductCondition productCondition) { throw new NotImplementedException(); }