private ReturnPrice GetPriceEncarte(ReturnPrice returnPrice, CustomerScore customerScore, long storeId) { MedalCode medalCode; if (customerScore.Score == null) { medalCode = MedalCode.NotRegistered; } else { medalCode = (MedalCode)int.Parse(customerScore.Score.Id); } PriceEncarte priceEncarte = _precoRepository.GetPriceEncarte(returnPrice.ProductId, storeId, medalCode); ReturnPrice price = new ReturnPrice(); if (priceEncarte.SalePrice > 0) { price = new ReturnPrice { ProductId = returnPrice.ProductId, SalePrice = priceEncarte.SalePrice, MaximumPrice = returnPrice.SalePrice, DiscountType = DiscountType.Encarte, PercentageDiscount = Math.Round(((returnPrice.SalePrice - priceEncarte.SalePrice) / returnPrice.SalePrice) * 100, 2) }; } return(price); }
private GetCustomerCreditDto GetCustomerCredit(CustomerScore customerScore, decimal monthlyIncome) { var customerCredit = new GetCustomerCreditDto { CreditResult = CreditResultType.Reject, CreditLimit = 0, CreditResultReason = string.Empty }; if (customerScore.Score < 500) { customerCredit.CreditResultReason = "Credit score is less than 500 points"; } else if (customerScore.Score >= 500 && customerScore.Score < 1000 && monthlyIncome < 5000) { customerCredit.CreditResultReason = "Success"; customerCredit.CreditResult = CreditResultType.Accept; customerCredit.CreditLimit = 10000; } else { customerCredit.CreditResultReason = "Success"; customerCredit.CreditResult = CreditResultType.Accept; customerCredit.CreditLimit = monthlyIncome * creditLimitMultiplier; } return(customerCredit); }
public List <BestPriceReturn> GetPrice(RequisitionData request) { List <BestPriceReturn> bestPriceReturnList = new List <BestPriceReturn>(); CustomerScore customerScore = GetCustomerScoreAsync(request.CpfCnpjCustomer).Result; foreach (Product product in request.Products) { List <ReturnPrice> returnPriceList = new List <ReturnPrice>(); ReturnPrice baseReturnprice = GetPriceAzulAsync(product.Id.ToString(), request.StoreId.ToString(), customerScore.Score != null).Result; ReturnPrice priceEncarte = GetPriceEncarte(baseReturnprice, customerScore, request.StoreId); if (priceEncarte.SalePrice > 0) { returnPriceList.Add(priceEncarte); } if (customerScore.Score != null) { switch ((MedalCode)Enum.Parse(typeof(MedalCode), customerScore.Score.Id)) { case MedalCode.Ouro: returnPriceList.Add(GetPriceOuro(baseReturnprice, request.StoreId, MedalCode.Ouro)); break; case MedalCode.Senior: returnPriceList.Add(GetPriceSenior(baseReturnprice, request.StoreId, MedalCode.Senior)); break; case MedalCode.Hapvida: returnPriceList.Add(GetPriceHapvida(baseReturnprice, request.StoreId, MedalCode.Senior)); break; default: returnPriceList.Add(baseReturnprice); break; } } else { returnPriceList.Add(GetPriceNotRegistered(baseReturnprice)); } bestPriceReturnList.Add(GetBestPrice(returnPriceList)); } return(bestPriceReturnList); }
public GameScoreItem(GameMain game, Texture2D texture, SpriteFont font, CustomerScore score) : base(game) { this.Texture = texture; this.scale = 1f; this.Size = new Vector2(this.Texture.Width, this.Texture.Height) * this.scale; this.iconPosition = Vector2.Zero; this.scoreData = score; this.Font = font; this.Label1 = new GameLabel(game, font); this.Label2 = new GameLabel(game, font); this.Color = Color.White; this.Initialize(); }
public override void LoadContent(object obj = null) { this.validButtonTexture = ContentHandler.Load <Texture2D>(GameResources.ValidGreenButton); this.replayButtonTexture = ContentHandler.Load <Texture2D>(GameResources.ReplayOrangeButton); this.homeButtonTexture = ContentHandler.Load <Texture2D>(GameResources.HomeGrayButton); this.scoreItemTexture = ContentHandler.Load <Texture2D>(GameResources.CustomerScoreBackground); this.fontTexture = ContentHandler.Load <SpriteFont>(GameResources.FontSpriteFontName); GameScore score = obj as GameScore; CustomerScore currentScore = new CustomerScore("User", (score != null) ? (int)score.Score : -1); this.timer = new Timer(); this.scoreItem = new GameScoreItem(this.Game, this.scoreItemTexture, this.fontTexture, currentScore); this.scoreItem.Color = Color.Orange; this.scoreItem.Size = new Vector2(Game.Window.ClientBounds.Width * 3 / 4, GameScoreItem.HEIGHT_DEFAULT); this.scoreItem.Label1.Color = Color.White; this.scoreItem.Label1.BorderColor = Color.Black; this.scoreItem.Label1.BorderThickness = 1; this.scoreItem.Label2.BorderColor = Color.White; this.scoreItem.Label2.BorderThickness = 1; this.scoreItem.Position = new Vector2(Game.Window.ClientBounds.Width / 2 - this.scoreItem.Size.X / 2, Game.Window.ClientBounds.Height / 6 - this.scoreItem.Size.Y / 2); this.scorePanel = new GamePanel(this.Game); this.scorePanel.Size = new Vector2(Game.Window.ClientBounds.Width * 3 / 4, 5 * GameScoreItem.HEIGHT_DEFAULT); this.scorePanel.Position = new Vector2(Game.Window.ClientBounds.Width / 2 - this.scorePanel.Size.X / 2, Game.Window.ClientBounds.Height * 2 / 5 - this.scorePanel.Size.Y / 2); this.scoresList.ForEach(item => this.scorePanel.Add(new GameScoreItem(this.Game, this.scoreItemTexture, this.fontTexture, item))); this.replayButton = new GameButton(this.Game, this.replayButtonTexture); this.replayButton.Scale = 1.5f; this.replayButton.Position = new Vector2(Game.Window.ClientBounds.Width / 4 - this.replayButton.Size.X / 2, Game.Window.ClientBounds.Height * 4 / 5 - this.replayButton.Size.Y / 2); this.homeButton = new GameButton(this.Game, this.homeButtonTexture); this.homeButton.Scale = 1.5f; this.homeButton.Position = new Vector2(Game.Window.ClientBounds.Width / 2 - this.homeButton.Size.X / 2, Game.Window.ClientBounds.Height * 4 / 5 - this.homeButton.Size.Y / 2); this.validButton = new GameButton(this.Game, this.validButtonTexture); this.validButton.Scale = 1.5f; this.validButton.Position = new Vector2(Game.Window.ClientBounds.Width * 3 / 4 - this.validButton.Size.X / 2, Game.Window.ClientBounds.Height * 4 / 5 - this.validButton.Size.Y / 2); this.replayButton.OnClick += replayButton_OnClick; this.homeButton.OnClick += HomeButton_OnClick; this.validButton.OnClick += ValidButton_OnClick; Thread.Sleep(1000); }