Exemplo n.º 1
0
 public void AddOfferDefinition(Guid competitorId, string productCategory, string name, int downloadSpeed, int uploadSpeed, double baseSetupPrice)
 {
     //add standalone and bundled packages
     //apply promotions to all packages
     var newStandAlonePackage = new CompetitorDto.ComponentPackageDto()
                                    {
                                        Name = name,
                                        ProductCategory = productCategory,
                                        DownloadSpeed = downloadSpeed,
                                        UploadSpeed = uploadSpeed,
                                        Location = "Not Applicable",
                                        BaseSetupPrice=baseSetupPrice
                                    };
     competitors.Find(x=>x.Id.Equals(competitorId)).StandAlonePackages.Add(newStandAlonePackage);
 }
Exemplo n.º 2
0
 public void AddOfferPolicy(Guid competitorId, string name, List<string> locations)
 {
     var competitor = competitors.Find(x => x.Id.Equals(competitorId));
     var competitorPackage=competitor.StandAlonePackages.Find(x => x.Name.Equals(name));
     var newPackages = new List<CompetitorDto.ComponentPackageDto>();
     locations.ForEach(location=>
                           {
                               var newPackage = new CompetitorDto.ComponentPackageDto()
                                                    {
                                                        Name = competitorPackage.Name,
                                                        DownloadSpeed = competitorPackage.DownloadSpeed,
                                                        Location = location,
                                                        ProductCategory = competitorPackage.ProductCategory,
                                                        BaseSetupPrice = competitorPackage.BaseSetupPrice,
                                                        PromotionalSetupPrice = competitorPackage.PromotionalSetupPrice,
                                                        UploadSpeed = competitorPackage.UploadSpeed
                                                    };
                               //TODO: apply existing promotion policies to the new package
                               newPackages.Add(newPackage);
                           });
     newPackages.ForEach(component =>
                           {
                               competitor.StandAlonePackages.ForEach(existingPackage =>
                                                       {
                                                           //if location matches and the product categories are different,
                                                           if(component.Location.Equals(existingPackage.Location))
                                                           {
                                                               //bundle these component packages with all other component packages
                                                               var bundledPackage = new CompetitorDto.BundledPackageDto(existingPackage.Location);
                                                               bundledPackage.ComponentPackages.Add(component);
                                                               bundledPackage.ComponentPackages.Add(existingPackage);
                                                               competitor.BundledPackages.Add(bundledPackage);
                                                           }
                                                       });
                           });
     competitor.StandAlonePackages.AddRange(newPackages);
 }