Esempio n. 1
0
        public static SponsorPublicModel ToPublicModel(this Sponsor sponsor, IUserService userService, IMediaService pictureService, ISponsorService sponsorService, IFormatterService formatterService, MediaSettings mediaSettings)
        {
            var user = userService.Get(sponsor.UserId);
            if (user == null)
                return null;

            //get sponsor data
            var sponsorData = sponsorService.GetSponsorData(sponsor.BattleId, sponsor.BattleType, sponsor.UserId);

            var model = new SponsorPublicModel
            {
                SponsorshipStatus = sponsor.SponsorshipStatus,
                SponsorshipStatusName = sponsor.SponsorshipStatus.ToString(),
                CustomerId = sponsor.UserId,
                SeName = user.GetPermalink().ToString(),
                SponsorName = user.GetPropertyValueAs<string>(PropertyNames.DisplayName),
                SponsorProfileImageUrl =
                    pictureService.GetPictureUrl(user.GetPropertyValueAs<int>(PropertyNames.DefaultPictureId)),
                SponsorshipAmount = sponsor.SponsorshipAmount,
                SponsorshipAmountFormatted = formatterService.FormatCurrency(sponsor.SponsorshipAmount, ApplicationContext.Current.ActiveCurrency),
                SponsorData = sponsorData.ToModel(pictureService),
                SponsorshipType = sponsor.SponsorshipType
            };

            return model;
        }
Esempio n. 2
0
 public OrderModelFactory(IModelMapper modelMapper, IFormatterService formatterService, IDataSerializer dataSerializer, IMediaAccountant mediaAccountant, IPaymentTransactionService paymentTransactionService)
 {
     _modelMapper               = modelMapper;
     _formatterService          = formatterService;
     _dataSerializer            = dataSerializer;
     _mediaAccountant           = mediaAccountant;
     _paymentTransactionService = paymentTransactionService;
 }
 public static string FormatCurrency(this IFormatterService formatterService, decimal amount, bool includeSymbol = true)
 {
     if (ApplicationEngine.IsAdmin())
     {
         return(formatterService.FormatCurrency(amount, ApplicationEngine.BaseCurrency.CultureCode,
                                                includeSymbol, ApplicationEngine.BaseCurrency.CustomFormat));
     }
     return(formatterService.FormatCurrency(amount, ApplicationEngine.CurrentCurrency.CultureCode, includeSymbol, ApplicationEngine.BaseCurrency.CustomFormat));
 }
Esempio n. 4
0
 public OrderModelFactory(IModelMapper modelMapper, IMediaAccountant mediaAccountant, IFormatterService formatterService, TaxSettings taxSettings, IDataSerializer dataSerializer, IShipmentModelFactory shipmentModelFactory)
 {
     _modelMapper          = modelMapper;
     _mediaAccountant      = mediaAccountant;
     _formatterService     = formatterService;
     _taxSettings          = taxSettings;
     _dataSerializer       = dataSerializer;
     _shipmentModelFactory = shipmentModelFactory;
 }
 public ConfigurationForm(IFormService formService, IHttpClientService httpClientService, ISemaphoreService semaphoreService, IFormatterService formatterService, IHtmlService htmlService)
 {
     this.formService       = formService;
     this.httpClientService = httpClientService;
     this.semaphoreService  = semaphoreService;
     this.formatterService  = formatterService;
     this.htmlService       = htmlService;
     InitializeComponent();
     InitializeTranslations();
     InitializePosition();
     InitializeFontAndOptions();
     InitializeLanguagesCombo();
     InitializeLeagueRaceCombo();
     InitializeTemplates();
 }
 public VideoBattleController(
     IVideoBattleService videoBattleService,
     IVideoBattleParticipantService videoBattleParticipantService,
     IVideoBattleVideoService videoBattleVideoService,
     IVideoBattleVoteService videoBattleVoteService,
     IVideoBattlePrizeService videoBattlePrizeService,
     IUserService userService,
     IWatchedVideoService watchedVideoService,
     IMediaService pictureService,
     ISponsorService sponsorService,
     ITimelineAutoPublisher timelineAutoPublisher,
     ISettingService settingService,
     IPaymentProcessingService paymentProcessingService,
     IFollowService followService,
     ICreditService creditService,
     IFormatterService formatterService,
     IEmailSender emailSender,
     IMobSocialVideoProcessor videoProcessor,
     MediaSettings mediaSettings,
     PaymentSettings paymentSettings,
     BattleSettings battleSettings,
     GeneralSettings generalSettings)
 {
     _videoBattleService = videoBattleService;
     _videoBattleParticipantService = videoBattleParticipantService;
     _videoBattleVideoService = videoBattleVideoService;
     _videoBattleVoteService = videoBattleVoteService;
     _videoBattlePrizeService = videoBattlePrizeService;
     _userService = userService;
     _watchedVideoService = watchedVideoService;
     _timelineAutoPublisher = timelineAutoPublisher;
     _settingService = settingService;
     _paymentProcessingService = paymentProcessingService;
     _followService = followService;
     _creditService = creditService;
     _paymentSettings = paymentSettings;
     _battleSettings = battleSettings;
     _formatterService = formatterService;
     _emailSender = emailSender;
     _generalSettings = generalSettings;
     _videoProcessor = videoProcessor;
     _sponsorService = sponsorService;
     _pictureService = pictureService;
     _mediaSettings = mediaSettings;
 }
 public SponsorController(ISponsorService sponsorService,
                          IVideoBattleService videoBattleService,
                          IUserService customerService,
                          IMediaService mediaService,
                          IFormatterService formatterService,
                          MediaSettings mediaSettings,
                          IEmailSender emailSender,
                          IVideoBattlePrizeService videoBattlePrizeService,
                          ICreditService creditService)
 {
     _sponsorService          = sponsorService;
     _videoBattleService      = videoBattleService;
     _userService             = customerService;
     _mediaService            = mediaService;
     _formatterService        = formatterService;
     _mediaSettings           = mediaSettings;
     _emailSender             = emailSender;
     _videoBattlePrizeService = videoBattlePrizeService;
     _creditService           = creditService;
 }
 public SponsorController(ISponsorService sponsorService,
     IVideoBattleService videoBattleService,
     IUserService customerService,
     IMediaService mediaService,
     IFormatterService formatterService,
     MediaSettings mediaSettings,
     IEmailSender emailSender,
     IVideoBattlePrizeService videoBattlePrizeService,
     ICreditService creditService)
 {
     _sponsorService = sponsorService;
     _videoBattleService = videoBattleService;
     _userService = customerService;
     _mediaService = mediaService;
     _formatterService = formatterService;
     _mediaSettings = mediaSettings;
     _emailSender = emailSender;
     _videoBattlePrizeService = videoBattlePrizeService;
     _creditService = creditService;
 }
Esempio n. 9
0
        public static SponsorPublicModel ToPublicModel(this Sponsor sponsor, IUserService userService, IMediaService pictureService, ISponsorService sponsorService, IFormatterService formatterService, MediaSettings mediaSettings)
        {
            var user = userService.Get(sponsor.UserId);

            if (user == null)
            {
                return(null);
            }

            //get sponsor data
            var sponsorData = sponsorService.GetSponsorData(sponsor.BattleId, sponsor.BattleType, sponsor.UserId);

            var model = new SponsorPublicModel
            {
                SponsorshipStatus     = sponsor.SponsorshipStatus,
                SponsorshipStatusName = sponsor.SponsorshipStatus.ToString(),
                CustomerId            = sponsor.UserId,
                SeName                 = user.GetPermalink().ToString(),
                SponsorName            = user.GetPropertyValueAs <string>(PropertyNames.DisplayName),
                SponsorProfileImageUrl =
                    pictureService.GetPictureUrl(user.GetPropertyValueAs <int>(PropertyNames.DefaultPictureId)),
                SponsorshipAmount          = sponsor.SponsorshipAmount,
                SponsorshipAmountFormatted = formatterService.FormatCurrency(sponsor.SponsorshipAmount, ApplicationContext.Current.ActiveCurrency),
                SponsorData     = sponsorData.ToModel(pictureService),
                SponsorshipType = sponsor.SponsorshipType
            };


            return(model);
        }
Esempio n. 10
0
 public ShipmentModelFactory(IFormatterService formatterService, IMediaAccountant mediaAccountant, TaxSettings taxSettings)
 {
     _formatterService = formatterService;
     _mediaAccountant  = mediaAccountant;
     _taxSettings      = taxSettings;
 }
        public static string GetConsolidatedPrizesString(this VideoBattle battle,
                                                         List <VideoBattlePrize> allPrizes,
                                                         int?winnerPosition,
                                                         ISponsorService sponsorService,
                                                         ISettingService settingService,
                                                         IPaymentProcessingService paymentProcessingService,
                                                         IFormatterService formatterService,
                                                         ICreditService creditService,
                                                         BattleSettings battleSettings)
        {
            var battleOwnerPrizes = allPrizes.Where(x => !x.IsSponsored && (!winnerPosition.HasValue || x.WinnerPosition == winnerPosition.Value));
            var sponsoredPrizes   = allPrizes.Where(x => x.IsSponsored && (!winnerPosition.HasValue || x.WinnerPosition == winnerPosition.Value));

            var videoBattlePrizes      = battleOwnerPrizes as VideoBattlePrize[] ?? battleOwnerPrizes.ToArray();
            var totalPrizesAmountFixed = videoBattlePrizes.Where(x => x.PrizeType == BattlePrizeType.FixedAmount).Sum(x => x.PrizeAmount);

            var totalPrizesAmountPercentage = 0m;

            if (videoBattlePrizes.Any(x => x.PrizeType == BattlePrizeType.PercentageAmount))
            {
                var contextKeyName = string.Format(CreditContextKeyNames.BattleVote, battle.Id);
                //get spent credits for battle votes
                var credits = creditService.GetCredits(contextKeyName, null, CreditTransactionType.Spent);

                var orderSum    = credits.Sum(x => x.CreditCount);
                var netOrderSum = paymentProcessingService.GetNetAmountAfterPaymentProcessing(orderSum);

                var totalWinners = videoBattlePrizes.Count();

                //total voting amount from percentage
                totalPrizesAmountPercentage = netOrderSum -
                                              totalWinners * netOrderSum * battle.ParticipantPercentagePerVote / 100;
            }

            var sponsorships = sponsorService.GetSponsorsGrouped(null, battle.Id, BattleType.Video,
                                                                 SponsorshipStatus.Accepted);

            var sponsorshipAmount = sponsorships.Sum(x => x.SponsorshipAmount);

            //amount after payment processing
            var netSponsorshipAmount = paymentProcessingService.GetNetAmountAfterPaymentProcessing(sponsorshipAmount);

            var siteOwnerShare = netSponsorshipAmount * battleSettings.SiteOwnerVideoBattleSponsorshipPercentage / 100;

            //it may be possible that battle host himself is sponsor, he won't be getting commissions for that :)
            var battleHostAsSponsorAmount =
                sponsorships.Where(x => x.UserId == battle.ChallengerId).Sum(x => x.SponsorshipAmount);


            var battleHostShare = (netSponsorshipAmount - battleHostAsSponsorAmount) * battleSettings.BattleHostVideoBattleSponsorshipPercentage / 100;

            //amount available for winners
            var winnerPrizePool = netSponsorshipAmount - siteOwnerShare - battleHostShare;

            if (winnerPosition.HasValue)
            {
                winnerPrizePool = PrizeDistributionHelper.GetPrizeDistributionPercentage(winnerPosition.Value,
                                                                                         allPrizes.Count(x => !x.IsSponsored), settingService) * winnerPrizePool;
            }

            var totalAmount = Math.Round(totalPrizesAmountFixed + totalPrizesAmountPercentage + winnerPrizePool);

            var totalPrizeString = totalAmount > 0 ? formatterService.FormatCurrency(totalAmount, ApplicationContext.Current.ActiveCurrency) : "";


            if (allPrizes.Any(x => x.PrizeType == BattlePrizeType.FixedProduct || x.PrizeType == BattlePrizeType.Other))
            {
                if (!winnerPosition.HasValue)
                {
                    totalPrizeString += "+";
                }
                else
                {
                    //now append each product as prize with it's name to the prize string
                    foreach (var prize in videoBattlePrizes.Where(x => x.PrizeType == BattlePrizeType.FixedProduct || x.PrizeType == BattlePrizeType.Other))
                    {
                        if (prize.PrizeType == BattlePrizeType.FixedProduct)
                        {
                            //todo: do something for fixed product
                        }
                        else
                        {
                            totalPrizeString += (totalPrizeString != "" ? " + " : "") + prize.PrizeOther;
                        }
                    }
                    //and sponsored products
                    foreach (var prize in sponsoredPrizes.Where(x => x.PrizeType == BattlePrizeType.Other))
                    {
                        totalPrizeString += (totalPrizeString != "" ? " + " : "") + prize.PrizeOther + "*";
                    }
                }
            }

            return(totalPrizeString);
        }
Esempio n. 12
0
 public HtmlService(IFormatterService formatterService, ICharacterService characterService)
 {
     this.formatterService = formatterService;
     this.characterService = characterService;
     parser = new HtmlParser();
 }
Esempio n. 13
0
 public ReturnRequestModelFactory(IFormatterService formatterService, IMediaAccountant mediaAccountant, IUserModelFactory userModelFactory)
 {
     _formatterService = formatterService;
     _mediaAccountant  = mediaAccountant;
     _userModelFactory = userModelFactory;
 }
Esempio n. 14
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, ILogger <Startup> logger, IFormatterService formatter,
                              ISiteInfo siteInfo, IRepository <Post> postRepository, IRepository <Author> authorRepository)
        {
            if (_env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            logger.LogInformation($"Settings directory: {siteInfo.BasePath}");
            if (!String.IsNullOrWhiteSpace(siteInfo.BasePath))
            {
                app.UseStaticFiles(new StaticFileOptions()
                {
                    FileProvider = new PhysicalFileProvider(Path.Combine(siteInfo.BasePath, "Images")),
                    RequestPath  = "/images"
                });
            }

            logger.LogInformation($"Posts directory: {postRepository.BasePath}");
            if (!String.IsNullOrWhiteSpace(postRepository.BasePath))
            {
                app.UseStaticFiles(new StaticFileOptions()
                {
                    FileProvider = new PhysicalFileProvider(postRepository.BasePath),
                    RequestPath  = "/posts"
                });
            }

            logger.LogInformation($"Authors directory: {authorRepository.BasePath}");
            if (!String.IsNullOrWhiteSpace(authorRepository.BasePath))
            {
                app.UseStaticFiles(new StaticFileOptions()
                {
                    FileProvider = new PhysicalFileProvider(authorRepository.BasePath),
                    RequestPath  = "/authors"
                });
            }

            app.UseStaticFiles(new StaticFileOptions()
            {
                FileProvider = new PhysicalFileProvider(_env.WebRootPath),
                RequestPath  = ""
            });

            app.UseCookiePolicy();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "tags",
                    template: "Posts/Tag/{tag}/Page/{pageNumber?}/",
                    defaults: new { Controller = "Posts", Action = "Index", tag = "", pageNumber = 1 });
                routes.MapRoute(
                    name: "posts",
                    template: "Posts/Page/{pageNumber?}",
                    defaults: new { Controller = "Posts", Action = "Index", pageNumber = 1 });
                routes.MapRoute(
                    name: "post",
                    template: "Posts/{id}",
                    defaults: new { Controller = "Posts", Action = "Post" });
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Posts}/{action=Index}");
            });
        }
Esempio n. 15
0
 public ReturnRequestModelFactory(IFormatterService formatterService, IMediaAccountant mediaAccountant)
 {
     _formatterService = formatterService;
     _mediaAccountant  = mediaAccountant;
 }
Esempio n. 16
0
 public QuotesService(IFormatterService formatterService)
 {
     this.formatterService = formatterService;
 }
Esempio n. 17
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, ILogger <Startup> logger, IFormatterService formatter,
                              ISiteInfo siteInfo, IRepository <Post> postRepository, IRepository <Author> authorRepository)
        {
            if (_env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            logger.LogInformation($"Settings directory: {siteInfo.BasePath}");
            if (!String.IsNullOrWhiteSpace(siteInfo.BasePath))
            {
                app.UseStaticFiles(new StaticFileOptions()
                {
                    FileProvider = new PhysicalFileProvider(Path.Combine(siteInfo.BasePath, "Images")),
                    RequestPath  = "/images"
                });
            }

            logger.LogInformation($"Posts directory: {postRepository.BasePath}");
            if (!String.IsNullOrWhiteSpace(postRepository.BasePath))
            {
                app.UseStaticFiles(new StaticFileOptions()
                {
                    FileProvider = new PhysicalFileProvider(postRepository.BasePath),
                    RequestPath  = "/posts"
                });
            }

            logger.LogInformation($"Authors directory: {authorRepository.BasePath}");
            if (!String.IsNullOrWhiteSpace(authorRepository.BasePath))
            {
                app.UseStaticFiles(new StaticFileOptions()
                {
                    FileProvider = new PhysicalFileProvider(authorRepository.BasePath),
                    RequestPath  = "/authors"
                });
            }

            app.UseStaticFiles(new StaticFileOptions()
            {
                FileProvider = new PhysicalFileProvider(_env.WebRootPath),
                RequestPath  = ""
            });

            app.UseCookiePolicy();

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    "default",
                    pattern: "{controller=Posts}/{action=Index}/{id?}"
                    );
            });
        }
Esempio n. 18
0
 public ShipmentModelFactory(IModelMapper modelMapper, IFormatterService formatterService, IWarehouseModelFactory warehouseModelFactory)
 {
     _modelMapper           = modelMapper;
     _formatterService      = formatterService;
     _warehouseModelFactory = warehouseModelFactory;
 }
Esempio n. 19
0
        public static string GetConsolidatedPrizesString(this VideoBattle battle, 
            List<VideoBattlePrize> allPrizes, 
            int? winnerPosition,
            ISponsorService sponsorService,
            ISettingService settingService,
            IPaymentProcessingService paymentProcessingService,
            IFormatterService formatterService,
            ICreditService creditService,
            BattleSettings battleSettings)
        {
            var battleOwnerPrizes = allPrizes.Where(x => !x.IsSponsored  && (!winnerPosition.HasValue || x.WinnerPosition == winnerPosition.Value));
            var sponsoredPrizes = allPrizes.Where(x => x.IsSponsored && (!winnerPosition.HasValue || x.WinnerPosition == winnerPosition.Value));

            var videoBattlePrizes = battleOwnerPrizes as VideoBattlePrize[] ?? battleOwnerPrizes.ToArray();
            var totalPrizesAmountFixed = videoBattlePrizes.Where(x => x.PrizeType == BattlePrizeType.FixedAmount).Sum(x => x.PrizeAmount);

            var totalPrizesAmountPercentage = 0m;
            if (videoBattlePrizes.Any(x => x.PrizeType == BattlePrizeType.PercentageAmount))
            {
                var contextKeyName = string.Format(CreditContextKeyNames.BattleVote, battle.Id);
                //get spent credits for battle votes
                var credits = creditService.GetCredits(contextKeyName, null, CreditTransactionType.Spent);

                var orderSum = credits.Sum(x => x.CreditCount);
                var netOrderSum = paymentProcessingService.GetNetAmountAfterPaymentProcessing(orderSum);

                var totalWinners = videoBattlePrizes.Count();

                //total voting amount from percentage
                totalPrizesAmountPercentage = netOrderSum -
                                              totalWinners*netOrderSum*battle.ParticipantPercentagePerVote/100;

            }

            var sponsorships = sponsorService.GetSponsorsGrouped(null, battle.Id, BattleType.Video,
                SponsorshipStatus.Accepted);

            var sponsorshipAmount = sponsorships.Sum(x => x.SponsorshipAmount);

            //amount after payment processing
            var netSponsorshipAmount = paymentProcessingService.GetNetAmountAfterPaymentProcessing(sponsorshipAmount);

            var siteOwnerShare = netSponsorshipAmount * battleSettings.SiteOwnerVideoBattleSponsorshipPercentage / 100;

            //it may be possible that battle host himself is sponsor, he won't be getting commissions for that :)
            var battleHostAsSponsorAmount =
                sponsorships.Where(x => x.UserId == battle.ChallengerId).Sum(x => x.SponsorshipAmount);

            var battleHostShare = (netSponsorshipAmount - battleHostAsSponsorAmount) * battleSettings.BattleHostVideoBattleSponsorshipPercentage / 100;

            //amount available for winners
            var winnerPrizePool = netSponsorshipAmount - siteOwnerShare - battleHostShare;

            if (winnerPosition.HasValue)
            {
                winnerPrizePool = PrizeDistributionHelper.GetPrizeDistributionPercentage(winnerPosition.Value,
                    allPrizes.Count(x => !x.IsSponsored), settingService) * winnerPrizePool;
            }

            var totalAmount = Math.Round(totalPrizesAmountFixed + totalPrizesAmountPercentage + winnerPrizePool);

            var totalPrizeString = totalAmount > 0 ? formatterService.FormatCurrency(totalAmount, ApplicationContext.Current.ActiveCurrency) : "";

            if (allPrizes.Any(x => x.PrizeType == BattlePrizeType.FixedProduct || x.PrizeType == BattlePrizeType.Other))
            {
                if (!winnerPosition.HasValue)
                    totalPrizeString += "+";
                else
                {
                    //now append each product as prize with it's name to the prize string
                    foreach (var prize in videoBattlePrizes.Where(x => x.PrizeType == BattlePrizeType.FixedProduct || x.PrizeType == BattlePrizeType.Other))
                    {
                        if (prize.PrizeType == BattlePrizeType.FixedProduct)
                        {
                            //todo: do something for fixed product
                        }
                        else
                        {
                            totalPrizeString += (totalPrizeString != "" ? " + " : "") + prize.PrizeOther;
                        }
                    }
                    //and sponsored products
                    foreach (var prize in sponsoredPrizes.Where(x => x.PrizeType == BattlePrizeType.Other))
                    {
                        totalPrizeString += (totalPrizeString != "" ? " + " : "") + prize.PrizeOther + "*";
                    }
                }
            }

            return totalPrizeString;
        }