Ejemplo n.º 1
0
        public void Sale(User user, Product product)
        {
            ICampaign campaign = _campaignService.GetCampaign(user);

            campaign.ShowOffer(user, product);
            Console.WriteLine($"{product.Name}, {user.UserName} tarafından {product.Price}TL karşılığında alındı");
        }
Ejemplo n.º 2
0
 public void Add(Customer customer, List <IGame> games, ICampaign campaign)
 {
     foreach (var item in games)
     {
         Console.WriteLine(customer.Name + " isimli müşteriye " + item.GameName + " oyunu " + campaign.CalculateCampaign(item) + " fiyatından verildi.");
     }
 }
    /// <summary>
    /// Updates the targets by data source.
    /// </summary>
    private void UpdateTargets()
    {
        switch (ddlOptions.SelectedIndex)
        {
        case 0:
            string status = Request.Form[ddlToStatus.ClientID.Replace("_", "$")];
            DoUpdateStatus(status);
            break;

        case 1:
            string stage = Request.Form[ddlToStage.ClientID.Replace("_", "$")];
            DoUpdateStage(stage);
            break;

        case 2:
            string init       = Request.Form[rdlInitTargets.ClientID.Replace("_", "$")];
            bool   initTarget = init == "Y";
            DoUpdateInit(initTarget);
            break;

        case 3:
            ICampaign campaign = (ICampaign)BindingSource.Current;
            DoAddResponse(campaign);
            break;
        }
    }
        private void CreateService()
        {
            var builder = new DbContextOptionsBuilder <SMContext>().UseSqlServer("Server=.\\SQLEXPRESS;Database=MariaDB;Trusted_Connection=True;");

            _SMContext = new SMContext(builder.Options);
            _ICampaign = new CreateCampaign(_SMContext);
        }
Ejemplo n.º 5
0
 private Validation GetCampaignTotalOrdersInRangeValidation(ICampaign campaign)
 {
     return(new CampaignTotalOrdersInRange(campaign, 1000000)
     {
         Order = _validationOrder + 1
     });
 }
Ejemplo n.º 6
0
 public Time(CoreDB db, IProduct productRepository, ICampaign campaignRepository, IOrder orderRepository)
 {
     _campaignRepository = campaignRepository;
     _orderRepository    = orderRepository;
     _productRepository  = productRepository;
     _db = db;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Apply coupon to cart
 /// </summary>
 /// <param name="coupon">Caoupon to appy to cart</param>
 public void ApplyCoupon(ICampaign coupon)
 {
     if (coupon.IsValid())
     {
         _appliedCoupon = coupon;
     }
 }
Ejemplo n.º 8
0
        double GetCampaignDiscountAmount(ICampaign campaign)
        {
            double discountAmount;

            if (campaign is IAmountCampaign)
            {
                var amountCampaign = campaign as IAmountCampaign;

                discountAmount = amountCampaign.DiscountAmount;
            }
            else if (campaign is IRateCampaign)
            {
                var rateCampaign = campaign as IRateCampaign;

                var totalPriceCampaignCategoryItems = this.Items
                                                      .Where(x => x.ActualProduct.Category.Id == campaign.Category.Id).ToList()
                                                      .Sum(x => x.ActualProduct.Price * x.Quantity);

                discountAmount = rateCampaign.DiscountRate * totalPriceCampaignCategoryItems;
            }
            else
            {
                throw new NotImplementedException();
            }

            return(discountAmount);
        }
Ejemplo n.º 9
0
 private Validation GetCampaignDurationMatchesDaySubmissionValidation(ICampaign campaign)
 {
     return(new CampaignDurationMatchesDaySubmission(campaign)
     {
         Order = _validationOrder + 1
     });
 }
Ejemplo n.º 10
0
 private Validation GetCampaignDurationInRangeValidation(ICampaign campaign)
 {
     return(new CampaignDurationInRange(1, 5000, campaign)
     {
         Order = _validationOrder + 1
     });
 }
        private ObservableCollection <ICampaign> GetCampaignList()
        {
            ObservableCollection <ICampaign> result = new ObservableCollection <ICampaign>();

            string campaignDirectory = "Campaign";

            if (Directory.Exists(campaignDirectory))
            {
                List <string> dirs = new List <string>(Directory.EnumerateDirectories(campaignDirectory));
                foreach (var dir in dirs)
                {
                    IEnumerable <string> files = Directory.EnumerateFiles(dir);
                    string campaignFilePath    = string.Concat(dir, "\\Campaign.txt");
                    if (files.Contains(campaignFilePath))
                    {
                        ICampaign campaign = XmlService <Campaign> .ReadXml(campaignFilePath);

                        if (campaign != null)
                        {
                            while (result.Select(x => x.Name).Contains(campaign.Name))
                            {
                                string.Concat(campaign.Name, "1");
                            }
                            result.Add(campaign);
                        }
                    }
                }
            }
            else
            {
                // RAF
            }
            return(result);
        }
Ejemplo n.º 12
0
    /// <summary>
    /// Loads the campaign stages.
    /// </summary>
    private void LoadCampaignStages()
    {
        lbxStages.Items.Clear();
        lbxStages.Items.Add(string.Empty);
        ITargetResponse targetResponse = BindingSource.Current as ITargetResponse;

        if (targetResponse == null)
        {
            return;
        }
        ICampaign campaign = targetResponse.Campaign;

        if (campaign == null)
        {
            return;
        }
        bool valueFound = false;

        foreach (ICampaignStage stage in campaign.CampaignStages)
        {
            lbxStages.Items.Add(stage.Description);
            if (stage.Description != targetResponse.Stage)
            {
                continue;
            }
            lbxStages.SelectedValue = stage.Description;
            valueFound = true;
        }

        if (!valueFound && !string.IsNullOrEmpty(targetResponse.Stage))
        {
            lbxStages.Items.Add(targetResponse.Stage);
        }
    }
Ejemplo n.º 13
0
 public GetTotalPrizeMoneyCommand(IDataReader dataReader,
                                  IInputValidator validator,
                                  ICampaign campaign)
 {
     _dataReader = dataReader;
     _validator  = validator;
     _campaign   = campaign;
 }
Ejemplo n.º 14
0
 public void Update(int campaignId, ICampaign campaign)
 {
     Console.WriteLine("[" + this.GetType().ToString() + "]" + " Updating campaign");
     if (storage.ContainsKey(campaignId))
     {
         storage[campaignId] = campaign;
     }
 }
Ejemplo n.º 15
0
 public void AddNewCampaign(ICampaign campaign)
 {
     Console.WriteLine("Enter a new campaign name:");
     campaign.Name = Console.ReadLine();
     Console.WriteLine("Discount of the new campaign");
     campaign.Discount = Convert.ToInt32(Console.ReadLine());
     Console.WriteLine($"New campaign is succesfully added!\nName: {campaign.Name}\nDiscount: {campaign.Discount}");
 }
Ejemplo n.º 16
0
        public int Save(ICampaign campaign)
        {
            Console.WriteLine("[" + this.GetType().ToString() + "]" + " Saving campaign");
            int newId = ++id;

            storage.Add(newId, campaign);
            return(newId);
        }
Ejemplo n.º 17
0
        public void ApplyDiscount(Game game, ICampaign campaign)
        {
            var _discount    = campaign.DiscountRate;
            var _gamePrice   = game.Price;
            var newGamePrice = _gamePrice * (100 - _discount) / 100;

            game.Price = newGamePrice;
            Console.WriteLine("Campaign price of " + game.Name + " is " + game.Price + "$" + " with " + campaign.Name);
        }
Ejemplo n.º 18
0
        public void CalculatePrizeMoney_ValidCampaign_ExpectedTotalPrizeMoney(ICampaign campaign)
        {
            //Arrange
            //Act
            var result = new PrizeMoneyCalculator().CalculatePrizeMoney(campaign);

            //Assert
            Assert.Equal(19, result);
        }
Ejemplo n.º 19
0
 public void UpdateCampaign(ICampaign campaign)
 {
     Console.WriteLine("Please update the campaign");
     Console.WriteLine("Name:");
     campaign.Name = Console.ReadLine();
     Console.WriteLine("Discount:");
     campaign.Discount = Convert.ToInt32(Console.ReadLine());
     Console.WriteLine($"Campaign is succesfully updated!\nName: {campaign.Name}\nDiscount: {campaign.Discount}");
 }
Ejemplo n.º 20
0
        public void ApplyDiscount(Game game, ICampaign campaign)
        {
            var _discount    = campaign.DiscountRate;
            var _gamePrice   = game.Price;
            var newGamePrice = _gamePrice * (100 - _discount) / 100;

            game.Price = newGamePrice;
            Console.WriteLine("Price of {0} is now ${1} with {2} campaign", game.Name, game.Price, campaign.Name);
        }
 /// <summary>
 /// Loads the grid.
 /// </summary>
 private void LoadGrid()
 {
     using (new SessionScopeWrapper(true))
     {
         ICampaign campaign = EntityFactory.GetById <ICampaign>(_campaign.Id);
         grdStages.DataSource = Sage.SalesLogix.Campaign.Rules.GetStageAndTasks(campaign);
         grdStages.DataBind();
     }
 }
Ejemplo n.º 22
0
        public void ApplyDiscont(IGame game, ICampaign campaign)
        {
            var discont  = campaign.Discont;
            var price    = game.GamePrice;
            var newPrice = price - (price * discont / 100);

            game.GamePrice = newPrice;

            Console.WriteLine("{0} is {1} right now via {2}  ", game.Name, game.GamePrice, campaign.name);
        }
Ejemplo n.º 23
0
 private IEnumerable <Validation> GetNumberOrdersMatchesSubmissionValidation(ICampaign campaign)
 {
     return(campaign.Days.Select
            (
                day => new NumberOrdersMatchesSubmission(day)
     {
         Order = _validationOrder + 1
     }
            ));
 }
Ejemplo n.º 24
0
 public void Sale(IGame game, IPlayer player, ICampaign campaign = null)
 {
     if (campaign != null)
     {
         Console.WriteLine("Uygulanan İndirim: " + campaign.CampaignName);
         Console.WriteLine(campaign.CampaignInfo);
         game.GamePrice *= (100 - campaign.CampaignDiscountRate) / 100;
     }
     Console.WriteLine(player.PlayerName + " Oyuncusu " + game.GameName + " Oyununu " + game.GamePrice + " TL'ye Satın Aldı.");
 }
Ejemplo n.º 25
0
 private IEnumerable <Validation> GetNumberOrdersInRangeValidations(ICampaign campaign)
 {
     return(campaign.Days.Select
            (
                day => new NumberOrdersInRange(0, 100000, day)
     {
         Order = _validationOrder + 1
     }
            ));
 }
        public int AddCampaign(int length, string type)
        {
            Console.WriteLine("[" + this.GetType().ToString() + "]" + " Creating new campaign");
            ICampaign newCampaign = marketingFactory.CreateCampaign(length, type);

            Console.WriteLine("[" + this.GetType().ToString() + "]" + " Saving campaign");
            int campaignId = campaigns.Save(newCampaign);

            return(campaignId);
        }
 /// <summary>
 /// Loads the stage to DDL.
 /// </summary>
 /// <param name="campaign">The campaign.</param>
 private void LoadStageToDDL(ICampaign campaign)
 {
     ddlToStage.Items.Clear();
     if (campaign != null)
     {
         foreach (ICampaignStage stage in campaign.CampaignStages)
         {
             ddlToStage.Items.Add(stage.Description);
         }
     }
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Sepete kampanya indirimleri tanımlama methodu
        /// </summary>
        /// <param name="campaigns">Kampanylar</param>
        public void ApplyDiscount(IEnumerable <ICampaign> campaigns)
        {
            ICampaign campaign = FindCampaignHighestDiscount(campaigns);

            if (campaign != null)
            {
                UsedCampaigns.Clear();
                UsedCampaigns.Add(campaign);
                CartPrice          = campaign.CalculateCampign(items, TotalPrice);
                _discountCampaigns = TotalPrice - CartPrice;
            }
        }
Ejemplo n.º 29
0
        public void ProduceCampaign_WhenCalledForRateCampaign_ReturnsRateCampaignObject()
        {
            //Arrange
            Category        category = new Category("Food");
            CampaignFactory factory  = new CampaignFactory();

            //Act
            ICampaign coupon = factory.ProduceCampaign(category, 50, 10, DiscountType.Rate);

            //Assert
            Assert.IsType <RateCampaign>(coupon);
        }
Ejemplo n.º 30
0
 private IEnumerable <Validation> GetAmountInRangeValidations(ICampaign campaign)
 {
     return
         (
         from day in campaign.Days
         from orderAmount in day.OrderAmounts
         select new AmountInRange(1000000, day)
     {
         Order = _validationOrder + 1
     }
         );
 }
Ejemplo n.º 31
0
    private void DoAddResponse(List<String> targetIds, ICampaign campaign)
    {
        string stage = ddlStage.Text;
        string comment = txtComment.Text;
        string responseMethod = ddlResponseMethods.Text;
        string leadSource = luLeadSource.Text;
        string responseInterest = ddlResponseInterests.Text;
        string responseInterestLevel = ddlResponseInterestLevels.Text;
        DateTime? responseDate = dtpResponseDate.DateTimeValue;

        String[] propNames = { "Stage", "Comment", "ResponseMethod", "LeadSource", "ResponseDate", "Interest", "InterestLevel" };
        object[] propValues = { stage, comment, responseMethod, leadSource, responseDate, responseInterest, responseInterestLevel };
        ComponentView responseData = new ComponentView(propNames, propValues);
        Helpers.AddTargetResponses(targetIds, campaign, responseData);
    }
Ejemplo n.º 32
0
 /// <summary>
 /// Loads the view.
 /// </summary>
 private void LoadView()
 {
     _campaign = GetParentEntity() as ICampaign;
     LoadGrid();
 }
Ejemplo n.º 33
0
 /// <summary>
 /// Loads the stage to DDL.
 /// </summary>
 /// <param name="campaign">The campaign.</param>
 private void LoadStageToDDL(ICampaign campaign)
 {
     ddlToStage.Items.Clear();
     if (campaign != null)
     {
         foreach (ICampaignStage stage in campaign.CampaignStages)
         {
             ddlToStage.Items.Add(stage.Description);
         }
     }
 }
Ejemplo n.º 34
0
    /// <summary>
    /// Does the add response.
    /// </summary>
    /// <param name="targetIds">The target ids.</param>
    /// <param name="campaign">The campaign.</param>
    private void DoAddResponse(object[] targetIds, ICampaign campaign)
    {
        string stage = Request.Form[ddlStage.ClientID.Replace("_", "$")];
        string comment = txtComment.Text;
        string responseMethod = Request.Form[ddlResponseMethods.ClientID.Replace("_", "$")];
        string Id = luLeadSource.ClientID + "_LookupText";
        string leadSource = Request.Form[Id.Replace("_", "$")];
        string responseInterest = Request.Form[ddlResponseInterests.ClientID.Replace("_", "$")];
        string responseInterestLevel = Request.Form[ddlResponseInterestLevels.ClientID.Replace("_", "$")];
        DateTime? responseDate = dtpResponseDate.DateTimeValue;

        String[] propNames = { "Stage", "Comment", "ResponseMethod", "LeadSource", "ResponseDate", "Interest", "InterestLevel" };
        object[] propValues = { stage, comment, responseMethod, leadSource, responseDate, responseInterest, responseInterestLevel };
        ComponentView responseData = new ComponentView(propNames, propValues);

        Sage.SalesLogix.CampaignTarget.Helpers.AddTargetResponses(targetIds, campaign, responseData);
    }
Ejemplo n.º 35
0
    /// <summary>
    /// Called when [form bound].
    /// </summary>
    /// 
    protected override void OnFormBound()
    {
        base.OnFormBound();
        ClientBindingMgr.RegisterDialogCancelButton(cmdCancel);
        _campaign = (ICampaign) this.BindingSource.Current;
        if (txtInit.Value == "F")
        {

        }
        if (DialogService.DialogParameters.Count > 0)
        {
            object filterStateObj;
            if (DialogService.DialogParameters.TryGetValue("TargetSelectedFilterState", out filterStateObj))
            {
                _filterState = filterStateObj as TargetSelectedFilterState;
                _filterState.IncludeSelectedOnly = true;
            }
        }
        LoadView();
    }