public async Task <ApiPromotionTypeResponse> DeletePromotionType(int id) { var apiResp = new ApiPromotionTypeResponse { ResponseType = -1, ResponseMessage = "Failed" }; var promotionTypeId = await _promotion.DeletePromtionType(id); if (promotionTypeId) { var retVal = await _promotion.GetAllPromotion(1); if (retVal.Count > 0) { apiResp.ResponseObject = new List <PromotionType>(); foreach (var _promo in retVal) { var promotion = new PromotionType(); promotion.Bind(_promo); apiResp.ResponseObject.Add(promotion); } apiResp.ResponseType = 1; apiResp.ResponseMessage = "Success"; } } return(apiResp); }
// Qualifiers and Action Methods private void PopulateLists(PromotionType mode) { if (mode == PromotionType.Sale) { // sale this.lstNewQualification.Items.Clear(); this.lstNewQualification.Items.Add(new ListItem("Any Product", PromotionQualificationBase.TypeIdAnyProduct)); this.lstNewQualification.Items.Add(new ListItem("When Product Is...", PromotionQualificationBase.TypeIdProductBvin)); this.lstNewQualification.Items.Add(new ListItem("When Product Category Is...", PromotionQualificationBase.TypeIdProductCategory)); this.lstNewQualification.Items.Add(new ListItem("When Product Type Is...", PromotionQualificationBase.TypeIdProductType)); this.lstNewQualification.Items.Add(new ListItem("When User Is...", PromotionQualificationBase.TypeIdUserIs)); this.lstNewQualification.Items.Add(new ListItem("When User Price Group Is...", PromotionQualificationBase.TypeIdUserIsInGroup)); this.lstNewAction.Items.Clear(); this.lstNewAction.Items.Add(new ListItem("Adjust Product Price", "A07AFF02-BA28-42E0-B334-324DE467B2D7")); } else { // offer this.lstNewQualification.Items.Clear(); this.lstNewQualification.Items.Add(new ListItem("Any Order", PromotionQualificationBase.TypeIdAnyOrder)); this.lstNewQualification.Items.Add(new ListItem("Order Has Coupon Code...", PromotionQualificationBase.TypeIdOrderHasCoupon)); this.lstNewQualification.Items.Add(new ListItem("When Order Has Products...", PromotionQualificationBase.TypeIdOrderHasProducts)); this.lstNewQualification.Items.Add(new ListItem("When Order Total >= ", PromotionQualificationBase.TypeIdOrderSubTotalIs)); this.lstNewQualification.Items.Add(new ListItem("When User Is...", PromotionQualificationBase.TypeIdUserIs)); this.lstNewQualification.Items.Add(new ListItem("When User Price Group Is...", PromotionQualificationBase.TypeIdUserIsInGroup)); this.lstNewQualification.Items.Add(new ListItem("Any Shipping Method", PromotionQualificationBase.TypeIdAnyShippingMethod)); this.lstNewAction.Items.Clear(); this.lstNewAction.Items.Add(new ListItem("Adjust Order Total", PromotionActionBase.TypeIdOrderTotalAdjustment)); this.lstNewAction.Items.Add(new ListItem("Adjust Shipping By...", PromotionActionBase.TypeIdOrderShippingAdjustment)); } }
public void TestMethod7() { Basket basket = new Basket(); BasketItem basketItem1 = new BasketItem(); basketItem1.SKU = "A"; basketItem1.price = 50; basket.BasketItemList.Add(basketItem1); BasketItem basketItem2 = new BasketItem(); basketItem2.SKU = "A"; basketItem2.price = 50; basket.BasketItemList.Add(basketItem2); BasketItem basketItem3 = new BasketItem(); basketItem3.SKU = "B"; basketItem3.price = 60; basket.BasketItemList.Add(basketItem3); PromotionObj promotion = new PromotionObj(); List <PromotionType> PromotionList = new List <PromotionType>(); PromotionType promotionType = new PromotionType(); promotionType.operand = 50; promotionType.operatorKey = new List <string>(); promotionType.operatorKey.Add("A"); promotionType.operatorKey.Add("A"); promotionType.operatorKey.Add("B"); promotionType.operatorType = "static"; promotionType.SKU_percentage = ""; promotion.PromotionList.Add(promotionType); List <SKU_Item> SKU_PriceList = new List <SKU_Item>(); SKU_Item SKU_Item1 = new SKU_Item(); SKU_Item1.SKU = "A"; SKU_Item1.price = 50; SKU_PriceList.Add(SKU_Item1); SKU_Item SKU_Item2 = new SKU_Item(); SKU_Item2.SKU = "B"; SKU_Item2.price = 60; SKU_PriceList.Add(SKU_Item2); SKU_Item SKU_Item3 = new SKU_Item(); SKU_Item3.SKU = "C"; SKU_Item3.price = 40; SKU_PriceList.Add(SKU_Item3); List <string> AppliedPromotions; int total = promotion.ApplyPromotion(basket, promotion.PromotionList, SKU_PriceList, out AppliedPromotions); Assert.AreEqual(50, total); //Assert.ThrowsException<NullReferenceException>(() => promotion.ApplyPromotion(basket, promotion.PromotionList, SKU_PriceList, out AppliedPromotions)); }
/// <summary> /// Used the constructor to initialize the type and price of individual units. Can create a function as well. /// </summary> /// <param name="skuType"></param> public SkuProduct(string skuType) { this.SkuType = skuType; switch (skuType) { case "A": this.Price = 50; this.promotionType = PromotionType.TypeA; break; case "B": this.Price = 30; this.promotionType = PromotionType.TypeA; break; case "C": this.Price = 20; this.promotionType = PromotionType.TypeB; break; case "D": this.Price = 15; this.promotionType = PromotionType.TypeB; break; default: throw new Exception("Invalid product type"); } }
public override string getNotation(ChessSide side, ChessPiece[,] positions, int sr, int sf, int dr, int df, PromotionType promotion_type) { string str; if (sf == df) { str = "" + (char) ('a' + df) + (dr + 1); } else { str = "" + (char) ('a' + sf); if (positions[dr, df] != null) str += 'x'; str += "" + (char) ('a' + df) + (dr + 1); } if (dr == 7 || dr == 0) { /* No need to verify for specific colors * only whites can reach 7 and blacks can reach 0 */ str += ChessPiece. getPromotionString (promotion_type); } return str; }
/// <summary> /// A method to create promotion calculator object. /// </summary> /// <param name="promotionType">Promotion type enum.</param> /// <returns>A instance of <see cref="IPromotionCalculator"/>.</returns> public static IPromotionCalculator GetPromotionCalculator(PromotionType promotionType, Cart cart) { IPromotionCalculator promotionCalculator; switch (promotionType) { case PromotionType.BulkItems: { promotionCalculator = new BulkPromotion(); break; } case PromotionType.Combo: { promotionCalculator = new ComboPromotion(cart); break; } default: { return(null); } } return(promotionCalculator); }
public static PromotionCalculator GetPromotionCalculator(PromotionType type) { switch (type) { case PromotionType.AQuantity: IDictionary <SkuType, decimal> skuA = new Dictionary <SkuType, decimal>() { { SkuType.A, 3 } }; return(new AQuantityCalculator(skuA, 130, true)); case PromotionType.BQuantity: IDictionary <SkuType, decimal> skuB = new Dictionary <SkuType, decimal>() { { SkuType.B, 2 } }; return(new BQuantityCalculator(skuB, 45, true)); case PromotionType.CDQuantity: IDictionary <SkuType, decimal> skuCD = new Dictionary <SkuType, decimal>() { { SkuType.C, 1 }, { SkuType.D, 1 } }; return(new CDQuantityCalculator(skuCD, 30, true)); default: return(null); } }
public void TestScenarioB() { // Arrange var cartItems = new List <CartItemViewModel> { new CartItemViewModel { Result = new CartItemDTO { Item = Items.A, ItemCount = 5 } }, new CartItemViewModel { Result = new CartItemDTO { Item = Items.B, ItemCount = 5 } }, new CartItemViewModel { Result = new CartItemDTO { Item = Items.C, ItemCount = 1 } } }; // Act var promotionTypes = new PromotionType[] { PromotionType.Promotion3A, PromotionType.Promotion2B, PromotionType.PromotionCD }; var result = Using <IPromotionEngineService>().ProcessCheckout(cartItems, promotionTypes).Result; // Assert Assert.AreEqual(370, result.TotalOrderValue); }
public Request(string sku, int quantity, PromotionType promotionType, int promotionValue = 0, int unitPrice = 0) { Sku = sku; Quantity = quantity; PromotionType = promotionType; PromotionValue = promotionValue; UnitPrice = unitPrice; }
public PromotionContext(HccRequestContext requestContext, PromotionType mode, long promotionId) { CustomerDescription = string.Empty; CurrentShippingMethodId = string.Empty; AdjustedShippingRate = 0; RequestContext = requestContext; Mode = mode; PromotionId = promotionId; }
public override string getNotation(ChessSide side, ChessPiece[,] positions, int sr, int sf, int dr, int df, PromotionType promotion) { return "K" + (char) ('a' + df) + (dr + 1); }
/// <summary> /// Instantiate the promotion service on the basis of promotion type /// </summary> /// <param name="promotionType"></param> /// <returns></returns> public static IPromotionService GetPromotionService(PromotionType promotionType) { switch (promotionType) { case PromotionType.TypeA: return(new PromotionServiceA()); case PromotionType.TypeB: return(new PromotionServiceB()); } return(null); }
public ActionResult Create([DataSourceRequest] DataSourceRequest request, PromotionType promotionType) { if (ModelState.IsValid) { db.PromotionTypes.Add(promotionType); db.SaveChanges(); return(RedirectToAction("Index")); } return(RedirectToAction("Index")); }
internal Move(Move source, PromotionType promotion) { Piece = source.Piece; OriginalPosition = source.OriginalPosition; NewPosition = source.NewPosition; CapturedPiece = source.CapturedPiece; Parameter = new MovePromotion(promotion); IsCheck = source.IsCheck; IsMate = source.IsMate; San = source.San; }
public Promotion(int productId, string description, PromotionType promotionType, decimal productPriceAfterDiscount, int quantity, float discountNextItem, DateTime startDate, DateTime endDate) { this.ProductId = productId; this.Description = description; this.PromotionType = promotionType; this.ProductPriceAfterDiscount = productPriceAfterDiscount; this.Quantity = quantity; this.DiscountNextItem = discountNextItem; this.StartDate = startDate; this.EndDate = endDate; }
/// <summary> /// initializes the available promotion object with passed values /// </summary> /// <param name="sku"></param> /// <param name="promotionType"></param> /// <param name="discountPercentage"></param> /// <param name="promotionPrice"></param> /// <param name="minQuantityToAvailPromotion"></param> /// <param name="regularPriceForUnitItem"></param> /// <param name="combinationList"></param> public AvailablePromotion(string sku, PromotionType promotionType, int discountPercentage, decimal promotionPrice, int minQuantityToAvailPromotion, decimal regularPriceForUnitItem, List <string> combinationList) { this.PromotionApplicableOnSku = sku; this.PromotionType = promotionType; this.DiscountPercentage = discountPercentage; this.PromotionPrice = promotionPrice; this.MinQuantityToAvailPromotion = minQuantityToAvailPromotion; this.RegularPriceForUnitItem = regularPriceForUnitItem; this.CombinationItemList = combinationList; this.PromotedPriceForUnitItem = CalculatePromotedPriceForUnitItem(); }
public Promotion(string name, string productName, PromotionType promotionType, int?quantity, decimal?price, float?discount, DateTime startDate, DateTime endDate, string description) { Name = name; ProductName = productName; PromotionType = promotionType; Quantity = quantity; Price = price; Discount = discount; StartDate = startDate; EndDate = endDate; Description = description; }
static void Main(string[] args) { while (true) { Console.WriteLine("Enter SKUIDs"); string skuID = Console.ReadLine(); List <string> ids = skuID.Split(',').ToList(); IPromotionType promotionType = new PromotionType(); int _output = promotionType.CalculateCost(ids); Console.Write(_output); Console.ReadLine(); } }
public static IPromotionStrategy Factory(PromotionType type) { switch (type) { case PromotionType.NonePromotion: return(new NonePromotionStrategy()); case PromotionType.SinglePromotion: return(new SinglePromotionStrategy()); default: return(new NonePromotionStrategy()); } }
private void ApplyOffers(Order order, PromotionType mode) { if (mode == PromotionType.OfferForShipping) { string[] skipOfferForShipping = { ShippingMethod.MethodUnknown, ShippingMethod.MethodToBeDetermined }; if (skipOfferForShipping.Contains(order.ShippingMethodId)) { return; } } _app.MarketingServices.ApplyOffers(order, mode); }
public Promotion(Product Pname, PromotionType pt, int qty, Product Cp, double v3) { ProductId = Pname; Ptype = pt; if (pt == PromotionType.quantity) { quantity = qty; } else { CombiProct = Cp; } value = v3; }
public void ApplyOffers(Order order, PromotionType mode) { var offers = Promotions.FindAllPotentiallyActive(DateTime.UtcNow, mode); foreach (var offer in offers) { // do not apply the offer if the current offer is marked as Do Not Combine, // and other offers appear to be applied already if (offer.DoNotCombine && order.HasAnyNonSaleDiscounts) { continue; } offer.ApplyToOrder(Context, order); } }
public ActionResult Update([DataSourceRequest] DataSourceRequest request, PromotionType promotionType) { if (ModelState.IsValid) { try { db.Entry(promotionType).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { } } return(RedirectToAction("Index")); }
public void TestMethod2() { PromotionObj promotion = new PromotionObj(); PromotionType promotionType = new PromotionType(); promotionType.SKU_percentage = "A"; promotionType.operand = 25; promotionType.operatorType = "%"; promotionType.operatorKey = new List <string>() { "A", "B" }; promotion.PromotionList.Add(promotionType); Assert.IsNotNull(promotion); }
public SKU CalculatePromotionForItem(PromotionType promotionType, PromotionModel promotionModel, SKU sku) { SKU _sku = new SKU(); if (promotionType == PromotionType.OnOneSKU) { if (promotionModel.QutyOfSKUCollection.FirstOrDefault().Value > sku.Quty) { var rem = 0; var cost = (Math.DivRem(sku.Quty, promotionModel.QutyOfSKUCollection.FirstOrDefault().Value, out rem) * promotionModel.CostCollection.FirstOrDefault().Value) + (rem * sku.CostPerSKU); _sku.TotalSavings = _sku.TotalCost - cost; _sku.TotalCost = cost; } } return(_sku); }
/// <summary> /// Calculate the bonus according the type and value of the promotion. /// this method is open so, any dev can add more promotion type depending on the clients needs. /// </summary> /// <param name="avg">Customer Recharge Value</param> /// <param name="ptype">Promotion type</param> /// <param name="promValue">Promotion Value</param> /// <returns>Value awarded</returns> public static decimal calculateBonus(decimal avg, PromotionType ptype, int promValue) { try { switch (ptype) { case PromotionType.Percentaje: return((avg * promValue) / 100); default: return(0); } } catch (Exception ex) { throw new Exception("calculateBonus error: " + ex.Message); } }
public PromoPage(PromotionType promotionType) { InitializeComponent(); var mainViewModel = MainViewModel.GetInstance(); if (promotionType.HasCategory == true) { mainViewModel.LibraryPromoModel.GetPromotionCategory(promotionType.PromotionTypeId); PromoCategoryListView.IsVisible = true; } else { ImgPromo.Source = promotionType.PromotionImage; mainViewModel.LibraryPromoModel.GetPromotionResult(promotionType.PromotionTypeId, 0); PromoCategoryListView.IsVisible = false; PromoListView.IsVisible = true; } }
public Promote(Board board, Piece piece, Coordinate to, PromotionType type) : base(board, piece, to) { var color = piece.Color; switch (type) { case PromotionType.Queen: PromotedPiece = new Queen(to, piece.Color); break; case PromotionType.Rook: PromotedPiece = new Rook(to, piece.Color); break; case PromotionType.Bishop: PromotedPiece = new Bishop(to, piece.Color); break; case PromotionType.Knight: PromotedPiece = new Knight(to, piece.Color); break; default: break; } }
public static decimal CalculateDiscount(PromotionType promotionType, decimal totalSKUAmount, decimal ruleAmount) { decimal percentageDiscount = 0; switch (promotionType) { case PromotionType.FixedRateDiscount: percentageDiscount = totalSKUAmount == 0 ? 0 : 100.00M - ((ruleAmount / totalSKUAmount) * 100); break; case PromotionType.PercentageDiscount: percentageDiscount = ruleAmount; break; default: percentageDiscount = 0; break; } return(percentageDiscount); }
public override decimal CalculateSumPrice(Guid?couponId) { decimal price = 0; List <ShopCartItem> items = new List <ShopCartItem>(); //todo:: 从数据源获取购物车items foreach (var item in items) { //计算每一项购物车item的价格 var isChecked = true; //todo::检查是否选中状态的购物车项 if (isChecked) { PromotionType type = PromotionType.NonePromotion; //todo:: 从item中获取促销类型 Guid itemId = Guid.Empty; //todo:: 从item中获取id IPromotionStrategy strategy = PromotionStrategyCreater.Factory(type); price += strategy.CalculatePromotionPrice(itemId); } } return(price); }
public Promote(Board board, Piece piece, Coordinate to, PromotionType type) : base(board, piece, to) { switch (type) { case PromotionType.Queen: PromotedPiece = new Queen(to, piece.Color); break; case PromotionType.Rook: PromotedPiece = new Rook(to, piece.Color); break; case PromotionType.Bishop: PromotedPiece = new Bishop(to, piece.Color); break; case PromotionType.Knight: PromotedPiece = new Knight(to, piece.Color); break; default: break; } }
public List <Promotion> FindAllWithFilter(PromotionType type, string keyword, bool showDisabled, int pageNumber, int pageSize, ref int totalRowCount) { var storeId = Context.CurrentStore.Id; using (var s = CreateStrategy()) { var query = GetJoinedQuery(s) .Where(y => y.Item.StoreId == storeId); // type if (type != PromotionType.Unknown) { query = query.Where(y => y.Item.Mode == (int)type); } // keyword if (!string.IsNullOrWhiteSpace(keyword)) { query = query.Where( y => y.Item.Name.Contains(keyword) || y.ItemTranslation.CustomerDescription.Contains(keyword)); } // show/hide disabled flag if (!showDisabled) { query = query.Where(y => y.Item.IsEnabled); } totalRowCount = query.Count(); var items = GetPagedItems(query.OrderBy(y => y.Item.SortOrder), pageNumber, pageSize); return(ListPoco(items)); } }
private void CreatePromotion(PromotionDto dto, string name, decimal reward, PromotionType rewardType, string promotionType, string promotionGroup, int campaignId) { var promotionRow = dto.Promotion.NewPromotionRow(); promotionRow.ApplicationId = AppContext.Current.ApplicationId; promotionRow.Name = name; promotionRow.StartDate = DateTime.Today; promotionRow.EndDate = DateTime.Today.AddYears(1); promotionRow.Created = DateTime.UtcNow; promotionRow.ModifiedBy = "admin"; promotionRow.Status = "active"; promotionRow.OfferAmount = reward; promotionRow.OfferType = (int)rewardType; promotionRow.PromotionGroup = promotionGroup; promotionRow.CampaignId = campaignId; promotionRow.ExclusivityType = "none"; promotionRow.PromotionType = promotionType; promotionRow.PerOrderLimit = 0; promotionRow.ApplicationLimit = 0; promotionRow.CustomerLimit = 0; promotionRow.Priority = 1; promotionRow.CouponCode = ""; if (name.Equals("25 % off Mens Shoes")) { promotionRow.OfferAmount = 25m; promotionRow.OfferType = 0; } //In commerce manager, this promotion type is displayed quite differently from others. //The percentage based offer type has value "0" and value based offer type has value "1". //But in C# code, PromotionType.Percentage = 1 and PromotionType.ValueBased = 2 else if (name.Equals("$10 off shipping from Women's Shoes")) { promotionRow.OfferType = 1; } dto.Promotion.Rows.Add(promotionRow); return; }
public virtual string getNotation(ChessSide side, ChessPiece[,] positions, int sr, int sf, int dr, int df, PromotionType promotion_type) { int count = 0; IList cands = getNotationCandidates (); if (cands != null && cands.Count > 1) { foreach (ChessPiece cand in cands) { if (cand. isValidMove (dr, df, positions, ChessBoardConstants. MOVE_EXCHANGE)) count++; } } string str = ""; string dest_square = "" + (char) ('a' + df) + (dr + 1); if (positions[dr, df] != null) dest_square = 'x' + dest_square; if (count <= 1) { str = getNotationPrefix () + dest_square; } else if (count == 2) { str = getNotationPrefix (); if (((ChessPiece) cands[0]).File == ((ChessPiece) cands[1]).File) // Both on the same file str += (sr + 1); else str += (char) ('a' + sf); str += dest_square; } else { // more than two candidates str = getNotationPrefix (); str = str + (char) ('a' + sf) + (sr + 1) + dest_square; } switch (promotion_type) { case PromotionType.QUEEN: str += "=Q"; break; case PromotionType.ROOK: str += "=R"; break; case PromotionType.BISHOP: str += "=B"; break; case PromotionType.KNIGHT: str += "=N"; break; } return str; }
protected static string getPromotionString(PromotionType type) { switch (type) { case PromotionType.QUEEN: return "=Q"; case PromotionType.ROOK: return "=R"; case PromotionType.BISHOP: return "=B"; case PromotionType.KNIGHT: return "=N"; } return ""; }
private void GetPromotionInfo(ref string move, out PromotionType type) { type = PromotionType.NONE; int len = move.Length; if (Char.IsNumber (move[len - 1])) return; string str; int index; if ((index = move.IndexOf ('=')) > 0) { str = move.Substring (0, index) + move.Substring (index + 1); len--; } else str = move; char last_char = str[len - 1]; switch (last_char) { case 'Q': type = PromotionType.QUEEN; break; case 'R': type = PromotionType.ROOK; break; case 'B': type = PromotionType.BISHOP; break; case 'N': type = PromotionType.KNIGHT; break; default: throw new InvalidMoveException (Catalog.GetString("Invalid move ") + str + Catalog.GetString(". Invalid promotion type: ") + last_char); } move = str.Substring (0, len - 1); }
protected bool move(int i1, int j1, int i2, int j2, PromotionType promoted_piece_type) { if (gameStatus != GAME_STATUS_PLAYING) { return false; } // CBSquare cbs = new CBSquare( i1, j1 ); ChessPiece piece = positions[i1, j1]; if (piece == null) { // No source piece return false; } // Not your turn! if (piece.Color != turn) { return false; } /* special case for enpass */ if (piece.Type == PieceType.PAWN && j1 != j2 && positions[i2, j2] == null) return move_enpass (i1, j1, i2, j2); bool promotion_case = ChessUtils.isPawnPromotion (piece, i2); if (piece.Type == PieceType.PAWN && promotion_case && promoted_piece_type == PromotionType.NONE) // promotion case but promotion type not specified return false; /* Now change the position */ piece = removePiece (i1, j1); if (positions[i2, j2] != null) { positions[i2, j2].removeFromSide (); removePiece (i2, j2); } /* special case for pawn */ if (promotion_case) { ChessPiece promoted_piece = createPiece ((PieceType) promoted_piece_type, piece.Color, i2, j2); piece.removeFromSide (); piece = promoted_piece; piece.addToSide (); } setPiece (piece, i2, j2); lastMoveInfo.movedPiece = piece; lastMoveInfo.SetInfo (i1, j1, i2, j2, promotion_case); FlipTurn (); return true; }
public PromotionTypeContract(PromotionType promotion) { this.ID = promotion.ID; this.Name = promotion.Name; }
private void GetPromotionInfo(ref string move, out PromotionType type) { type = PromotionType.NONE; int len = move.Length; if (len < 2 || move[len - 2] != '=' || Char.IsNumber (move[len - 1])) return; string str; str = move; char last_char = str[len - 1]; switch (last_char) { case 'Q': type = PromotionType.QUEEN; break; case 'R': type = PromotionType.ROOK; break; case 'B': type = PromotionType.BISHOP; break; case 'N': type = PromotionType.KNIGHT; break; default: throw new InvalidMoveException (Catalog. GetString ("Invalid move ") + str + Catalog. GetString (". Invalid promotion type: ") + last_char); } move = str.Substring (0, len - 2); }