public UserController(IUserService userService, IStudentService studentService, IClubService clubservice, ISponsorService sponsorService)
 {
     _userservice    = userService;
     _studentservice = studentService;
     _clubservice    = clubservice;
     _sponsorservice = sponsorService;
 }
Example #2
0
 public PromoService()
 {
     _globalOptionService = DependencyService.Get <IGlobalOptionService>();
     _softwareService     = DependencyService.Get <ISoftwareService>();
     _sponsorService      = DependencyService.Get <ISponsorService>();
     _logService          = DependencyService.Get <ILogService>();
 }
Example #3
0
 public SponsorApiController(IWorkContext workContext,
                             ISponsorService sponsorService,
                             ISponsorPassService sponsorPassService,
                             IOrderService orderService,
                             IVideoBattleService videoBattleService,
                             ICustomerService customerService,
                             IPictureService pictureService,
                             IPriceFormatter priceFormatter,
                             IDateTimeHelper dateTimeHelper,
                             ILocalizationService localizationService,
                             ICurrencyService currencyService,
                             MediaSettings mediaSettings, IMobSocialMessageService mobSocialMessageService, IStoreContext storeContext, IVideoBattlePrizeService videoBattlePrizeService, IPaymentProcessingService paymentProcessingService)
 {
     _workContext              = workContext;
     _sponsorPassService       = sponsorPassService;
     _sponsorService           = sponsorService;
     _orderService             = orderService;
     _videoBattleService       = videoBattleService;
     _customerService          = customerService;
     _pictureService           = pictureService;
     _priceFormatter           = priceFormatter;
     _dateTimeHelper           = dateTimeHelper;
     _localizationService      = localizationService;
     _currencyService          = currencyService;
     _mediaSettings            = mediaSettings;
     _mobSocialMessageService  = mobSocialMessageService;
     _storeContext             = storeContext;
     _videoBattlePrizeService  = videoBattlePrizeService;
     _paymentProcessingService = paymentProcessingService;
 }
Example #4
0
 public SponsorController(
     ILogger <SponsorController> logger,
     ISponsorService sponsorService)
 {
     this.logger         = logger;
     this.sponsorService = sponsorService;
 }
        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;
        }
 public SponsorRepository(ISponsorService sponsorService, IVerenigingRepository verenigingRepository, IEventAggregator eventAggregator, ISessionStateService sessionStateService)
 {
     _sponsorService       = sponsorService;
     _eventAggregator      = eventAggregator;
     _sessionStateService  = sessionStateService;
     _verenigingRepository = verenigingRepository;
 }
        public SecurityAdminController(UserManager <IdentityUser> userManager,
                                       RoleManager <IdentityRole> roleManager, ISponsorService sponsorService,
                                       ApplicationDbContext dbContext, ISubscriptionService subscriptionService, ITestDataUtility testDataUtility)
        {
            if (roleManager == null)
            {
                throw new ArgumentNullException(nameof(roleManager), $"{nameof(roleManager)} is null.");
            }

            if (sponsorService == null)
            {
                throw new ArgumentNullException("presidentService", "Argument cannot be null.");
            }

            if (userManager == null)
            {
                throw new ArgumentNullException(nameof(userManager), $"{nameof(userManager)} is null.");
            }

            _UserManager         = userManager;
            _SponsorService      = sponsorService;
            _RoleManager         = roleManager;
            _Context             = dbContext;
            _SubscriptionService = subscriptionService;
            _TestDataUtility     = testDataUtility;
        }
 public SponsorsViewModel(
     ISponsorService sponsorService,
     IPageDialogService pageDialogService)
 {
     SponsorService    = sponsorService;
     PageDialogService = pageDialogService;
     Sponsors          = new ObservableCollection <object>();
     ItemSelected      = new DelegateCommand <object>(OnItemSelected);
 }
Example #9
0
 public MenuPageViewModel(HOPage root, INavigation navigation = null)
     : base(navigation)
 {
     _sponsorService = DependencyService.Get <ISponsorService>();
     _menuService    = DependencyService.Get <IMenuService>();
     _root           = root;
     MenuItems       = _menuService.GetMenus();
     Sponsors        = new ObservableCollection <Sponsor>(_sponsorService.GetDownloadedSponsors());
 }
Example #10
0
 public SponsorsController(ISponsorService service
                           , IEfRepository <Sponsor> repository
                           , IWebHostEnvironment hostEnvironment
                           , IMapper mapper)
 {
     _service         = service;
     _repository      = repository;
     _hostEnvironment = hostEnvironment;
     _mapper          = mapper;
 }
Example #11
0
        public SponsorPresenter(ISponsorView view, ISponsorService sponsorService)
            : base(view)
        {
            Guard.WhenArgument(sponsorService, "SponsorService").IsNull().Throw();
            Guard.WhenArgument(view, "SponsorView").IsNull().Throw();

            this.sponsorService     = sponsorService;
            this.View.MyInit       += this.View_Init;
            this.View.OnGetData    += this.View_OnGetData;
            this.View.OnInsertItem += this.View_OnInsertItem;
            this.View.OnDeleteItem += this.View_OnDeleteItem;
            this.View.OnUpdateItem += this.View_OnUpdateItem;
        }
 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 PaymentController(IUserPaymentMethodService paymentMethodService,
                          IPaymentProcessingService paymentProcessingService,
                          ICryptographyService cryptographyService,
                          IVideoBattleService videoBattleService,
                          ISponsorService sponsorService,
                          ICreditService creditService,
                          PaymentSettings paymentSettings,
                          IPaymentTransactionService paymentTransactionService)
 {
     _paymentMethodService      = paymentMethodService;
     _paymentProcessingService  = paymentProcessingService;
     _cryptographyService       = cryptographyService;
     _videoBattleService        = videoBattleService;
     _sponsorService            = sponsorService;
     _creditService             = creditService;
     _paymentSettings           = paymentSettings;
     _paymentTransactionService = paymentTransactionService;
 }
 public PaymentController(IUserPaymentMethodService paymentMethodService, 
     IPaymentProcessingService paymentProcessingService, 
     ICryptographyService cryptographyService, 
     IVideoBattleService videoBattleService, 
     ISponsorService sponsorService, 
     ICreditService creditService, 
     PaymentSettings paymentSettings, 
     IPaymentTransactionService paymentTransactionService)
 {
     _paymentMethodService = paymentMethodService;
     _paymentProcessingService = paymentProcessingService;
     _cryptographyService = cryptographyService;
     _videoBattleService = videoBattleService;
     _sponsorService = sponsorService;
     _creditService = creditService;
     _paymentSettings = paymentSettings;
     _paymentTransactionService = paymentTransactionService;
 }
 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;
 }
        // private IValidatorStrategy<President> _Validator;
        // private ITestDataUtility _TestDataUtility;

        public SponsorController(ISponsorService Service,
                                 IOrphanService OrphanService,
                                 ILogger Log
                                 //, IValidatorStrategy<President> validator
                                 //  ITestDataUtility testDataUtility
                                 )
        {
            //      if (Service == null)
            //          throw new ArgumentNullException("service", "service is null.");

            //if (validator == null)
            //{
            //    throw new ArgumentNullException("validator", "Argument cannot be null.");
            //}

            //  _Validator = validator;
            _Service       = Service;
            _OrphanService = OrphanService;
            _Log           = Log;
            //  _TestDataUtility = testDataUtility;
        }
Example #18
0
        public SponsorController(ISponsorService Service
                                 //, IValidatorStrategy<President> validator
                                 //  ITestDataUtility testDataUtility
                                 , IDonationService DonationService
                                 )
        {
            if (Service == null)
            {
                throw new ArgumentNullException("service", "service is null.");
            }

            //if (validator == null)
            //{
            //    throw new ArgumentNullException("validator", "Argument cannot be null.");
            //}

            //  _Validator = validator;
            _Service         = Service;
            _DonationService = DonationService;
            //  _TestDataUtility = testDataUtility;
        }
Example #19
0
        public TestDataUtility(ISponsorService service, NoorTrustDbContext dbContext,
                               UserManager <IdentityUser> userManager,
                               RoleManager <IdentityRole> roleManager
                               )
        {
            if (service == null)
            {
                throw new ArgumentNullException("service", "service is null.");
            }

            _Service = service;

            if (dbContext == null)
            {
                throw new ArgumentNullException("dbContext", "Argument cannot be null.");
            }

            _DbContext = dbContext;

            _UserManager = userManager;
            _RoleManager = roleManager;
        }
        public static string GetConsolidatedPrizesString(this VideoBattle Battle,
                                                         List <VideoBattlePrize> allPrizes,
                                                         int?WinnerPosition,
                                                         IWorkContext _workContext,
                                                         IProductService _productService,
                                                         ISponsorService _sponsorService,
                                                         IVoterPassService _voterPassService,
                                                         IVideoBattlePrizeService _videoBattlePrizeService,
                                                         IPriceFormatter _priceFormatter,
                                                         ISettingService _settingService,
                                                         IPaymentProcessingService _paymentProcessingService,
                                                         mobSocialSettings _mobSocialSettings)
        {
            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 totalPrizesAmountFixed =
                battleOwnerPrizes.Where(x => x.PrizeType == VideoBattlePrizeType.FixedAmount).Sum(x => x.PrizeAmount);

            var totalPrizesAmountPercentage = 0m;

            if (battleOwnerPrizes.Any(x => x.PrizeType == VideoBattlePrizeType.PercentageAmount))
            {
                var orders      = _voterPassService.GetAllVoterPassOrders(BattleType.Video, Battle.Id, PassStatus.Used);
                var orderSum    = orders.Sum(x => x.OrderTotal);
                var netOrderSum = _paymentProcessingService.GetNetAmountAfterPaymentProcessing(orderSum);

                var totalWinners = battleOwnerPrizes.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 * _mobSocialSettings.SiteOwnerSponsorshipPercentage / 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.CustomerId == Battle.ChallengerId).Sum(x => x.SponsorshipAmount);


            var battleHostShare = (netSponsorshipAmount - battleHostAsSponsorAmount) * _mobSocialSettings.BattleHostSponsorshipPercentage / 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 ? _priceFormatter.FormatPrice(totalAmount, true, _workContext.WorkingCurrency) : "";


            if (allPrizes.Any(
                    x => x.PrizeType == VideoBattlePrizeType.FixedProduct || x.PrizeType == VideoBattlePrizeType.Other))
            {
                if (!WinnerPosition.HasValue)
                {
                    totalPrizeString += "+";
                }
                else
                {
                    //now append each product as prize with it's name to the prize string
                    foreach (var prize in battleOwnerPrizes.Where(x => x.PrizeType == VideoBattlePrizeType.FixedProduct || x.PrizeType == VideoBattlePrizeType.Other))
                    {
                        if (prize.PrizeType == VideoBattlePrizeType.FixedProduct)
                        {
                            var product = _productService.GetProductById(prize.PrizeProductId);
                            if (product != null)
                            {
                                totalPrizeString += (totalPrizeString != "" ? " + " : "") + product.Name;
                            }
                            else
                            {
                                totalPrizeString += (totalPrizeString != "" ? " + " : "") + prize.PrizeProductId;
                            }
                        }
                        else
                        {
                            totalPrizeString += (totalPrizeString != "" ? " + " : "") + prize.PrizeOther;
                        }
                    }
                    //and sponsored products
                    foreach (var prize in sponsoredPrizes.Where(x => x.PrizeType == VideoBattlePrizeType.Other))
                    {
                        totalPrizeString += (totalPrizeString != "" ? " + " : "") + prize.PrizeOther + "*";
                    }
                }
            }

            return(totalPrizeString);
        }
 public SponsorsController(ISponsorService sponsorService)
 {
     this.sponsorService = sponsorService;
 }
        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);
        }
Example #23
0
 public SponsorAPIController(ISponsorService SponsorService)
 {
     _SponsorService = SponsorService;
     _mainResponse   = new MainResponse();
 }
        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;
        }
Example #25
0
 public MeetupModelMapper(IPersonService personService, IVideoService videoService, ISponsorService sponsorService)
 {
     _personService  = personService;
     _videoService   = videoService;
     _sponsorService = sponsorService;
 }
Example #26
0
        public SponsorServiceTest()
        {
            List <Sponsor> sponsorProfileList = new List <Sponsor>();
            Sponsor        s1 = new Sponsor();

            s1.Address     = new Address();
            s1.SponsorType = new SponsorType();
            Sponsor s2 = new Sponsor();

            s2.Address     = new Address();
            s2.SponsorType = new SponsorType();
            Sponsor s3 = new Sponsor();

            s3.Address     = new Address();
            s3.SponsorType = new SponsorType();

            s1.Id             = 1;
            s1.Name           = "Google";
            s1.CompanyUrl     = new Uri("https://www.google.com/");
            s1.Address.Id     = 1;
            s1.PhoneNumber    = "8184239283";
            s1.ContactPerson  = "Sundar Pichai";
            s1.SponsorType.Id = 1;

            s2.Id             = 2;
            s2.Name           = "Facebook";
            s2.CompanyUrl     = new Uri("https://www.facebook.com/");
            s2.Address.Id     = 2;
            s2.PhoneNumber    = "8185309283";
            s2.ContactPerson  = "Mark Zuckerberg";
            s2.SponsorType.Id = 2;

            s3.Id             = 3;
            s3.Name           = "VK";
            s3.CompanyUrl     = new Uri("https://www.facebook.com/");
            s3.Address.Id     = 3;
            s3.PhoneNumber    = "1235309283";
            s3.ContactPerson  = "Pavel Durov";
            s3.SponsorType.Id = 3;

            sponsorProfileList.Add(s1);
            sponsorProfileList.Add(s2);
            sponsorProfileList.Add(s3);

            List <SponsorAddRequest> sponsorAddProfileList = new List <SponsorAddRequest>();
            SponsorAddRequest        sar1 = new SponsorAddRequest();
            int userId1 = 1;

            sar1.Name                 = "Microsoft";
            sar1.CompanyUrl           = "https://www.microsoft.com/";
            sar1.AddressId            = 1;
            sar1.PhoneNumber          = "8184309283";
            sar1.ContactPerson        = "Bill Gates";
            sar1.PrimarySponsorTypeId = 1;

            sponsorAddProfileList.Add(sar1);

            List <SponsorUpdateRequest> sponsorUpdateProfileList = new List <SponsorUpdateRequest>();
            SponsorUpdateRequest        sur1 = new SponsorUpdateRequest();

            sur1.Id                   = 1;
            sur1.Name                 = "Twitter";
            sur1.CompanyUrl           = "https://twitter.com/";
            sur1.AddressId            = 1;
            sur1.PhoneNumber          = "2215309283";
            sur1.ContactPerson        = "Jack Dorsey";
            sur1.PrimarySponsorTypeId = 1;

            sponsorUpdateProfileList.Add(sur1);

            List <SponsorType> sponsorTypesList = new List <SponsorType>();

            SponsorType st1 = new SponsorType();
            SponsorType st2 = new SponsorType();
            SponsorType st3 = new SponsorType();

            st1.Id   = 0;
            st1.Name = "int";

            st2.Id   = 1;
            st2.Name = "bool";

            st3.Id   = 2;
            st3.Name = "string";

            sponsorTypesList.Add(st1);
            sponsorTypesList.Add(st2);
            sponsorTypesList.Add(st3);


            var mock = new Mock <ISponsorService>();



            mock.Setup(m => m.Insert(It.IsAny <SponsorAddRequest>(), It.IsAny <int>())).Returns(
                (SponsorAddRequest insertRequestModel, int userId) =>
            {
                List <ValidationResult> validationResults = ValidateModal(insertRequestModel);

                if (validationResults.Count > 0)
                {
                    throw new ValidationException(validationResults[0], null, insertRequestModel);
                }
                return(sponsorAddProfileList.Count + 1);
            }
                );

            mock.Setup(m => m.Get()).Returns(
                () =>
            {
                List <Sponsor> sponsorsList = new List <Sponsor>();
                foreach (var item in sponsorProfileList)
                {
                    Sponsor model     = new Sponsor();
                    model.Address     = new Address();
                    model.SponsorType = new SponsorType();

                    model.Id             = item.Id;
                    model.Name           = item.Name;
                    model.CompanyUrl     = item.CompanyUrl;
                    model.Address.Id     = item.Address.Id;
                    model.PhoneNumber    = item.PhoneNumber;
                    model.ContactPerson  = item.ContactPerson;
                    model.SponsorType.Id = item.SponsorType.Id;
                    sponsorsList.Add(model);
                }
                return(sponsorsList);
            });

            mock.Setup(m => m.Get(It.IsAny <int>())).Returns(
                (int id) =>
            {
                Sponsor modal = sponsorProfileList.Where(m => m.Id == id).FirstOrDefault();

                Sponsor newModal = null;
                if (modal != null)
                {
                    newModal             = new Sponsor();
                    newModal.Address     = new Address();
                    newModal.SponsorType = new SponsorType();

                    newModal.Id             = modal.Id;
                    newModal.Name           = modal.Name;
                    newModal.CompanyUrl     = modal.CompanyUrl;
                    newModal.Address.Id     = modal.Address.Id;
                    newModal.PhoneNumber    = modal.PhoneNumber;
                    newModal.ContactPerson  = modal.ContactPerson;
                    newModal.SponsorType.Id = modal.SponsorType.Id;
                }
                return(newModal);
            });


            mock.Setup(m => m.Update(It.IsAny <SponsorUpdateRequest>())).Callback(
                (SponsorUpdateRequest updateRequestModel) =>
            {
                List <ValidationResult> validationResults = ValidateModal(updateRequestModel);

                if (validationResults.Count > 0)
                {
                    throw new ValidationException(validationResults[0], null, updateRequestModel);
                }
                Sponsor model        = sponsorProfileList.Where(m => m.Id == updateRequestModel.Id).Single();
                model.Name           = updateRequestModel.Name;
                model.CompanyUrl     = new Uri(updateRequestModel.CompanyUrl);
                model.Address.Id     = updateRequestModel.AddressId;
                model.PhoneNumber    = updateRequestModel.PhoneNumber;
                model.ContactPerson  = updateRequestModel.ContactPerson;
                model.SponsorType.Id = updateRequestModel.PrimarySponsorTypeId;
            }
                );

            mock.Setup(m => m.Delete(It.IsAny <int>())).Callback(
                (int id) =>
            {
                Sponsor sponsor = sponsorProfileList.Where(m => m.Id == id).Single();
                sponsorProfileList.Remove(sponsor);
            });

            mock.Setup(m => m.Get(It.IsAny <int>(), It.IsAny <int>())).Returns(
                (int pageIndex, int pageSize) =>
            {
                List <Sponsor> sponsorsList = new List <Sponsor>();
                int count = (pageIndex) * pageSize;

                for (int i = count; i < sponsorProfileList.Count; i++)
                {
                    if (i < count + pageSize)
                    {
                        sponsorsList.Add(sponsorProfileList[i]);
                    }
                    else
                    {
                        break;
                    }
                }
                Paged <Sponsor> paged = new Paged <Sponsor>(sponsorsList, pageIndex, pageSize, sponsorProfileList.Count);
                return(paged);
            });

            mock.Setup(m => m.Get(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>())).Returns(
                (int pageIndex, int pageSize, int typeId) =>
            {
                List <Sponsor> sponsorsListResult = new List <Sponsor>();

                List <Sponsor> sponsorsByType = new List <Sponsor>();
                for (int i = 0; i < sponsorProfileList.Count; i++)
                {
                    if (sponsorProfileList[i].SponsorType.Id == typeId)
                    {
                        sponsorsByType.Add(sponsorProfileList[i]);
                    }
                }
                int count = (pageIndex) * pageSize;

                for (int i = count; i < sponsorsByType.Count; i++)
                {
                    if (i < count + pageSize)
                    {
                        sponsorsListResult.Add(sponsorsByType[i]);
                    }
                    else
                    {
                        break;
                    }
                }
                Paged <Sponsor> paged = new Paged <Sponsor>(sponsorsListResult, pageIndex, pageSize, sponsorsByType.Count);
                return(paged);
            });

            mock.Setup(m => m.GetTypes()).Returns(
                () =>
            {
                List <SponsorType> sponsorsTypesList = new List <SponsorType>();
                foreach (var item in sponsorTypesList)
                {
                    SponsorType model = new SponsorType();

                    model.Id   = item.Id;
                    model.Name = item.Name;
                    sponsorsTypesList.Add(model);
                }
                return(sponsorsTypesList);
            });

            _sponsorService = mock.Object;
        }
 public SponsorsApiController(ISponsorService sponsorService, IAuthenticationService <int> auth)
 {
     _service = sponsorService;
     _auth    = auth;
 }
Example #28
0
 public HomeController(ISponsorService Service, IOrphanService OrphanService)
 {
     _SponsorService = Service;
     _OrphanService  = OrphanService;
 }
Example #29
0
 public SponsorController(ISponsorService sponsorService)
 {
     _sponsorService = sponsorService;
 }
Example #30
0
 public SponsorController(ISponsorService sponsor)
 {
     this.sponsor = sponsor;
 }
 public SponsorController(ILogger <SponsorController> logger, ISponsorService sponsorService)
 {
     _logger         = logger;
     _sponsorService = sponsorService;
 }
Example #32
0
        public static SponsorPublicModel ToPublicModel(this Sponsor Sponsor, IWorkContext _workContext,
                                                       ICustomerService _customerService, IPictureService _pictureService, ISponsorService _sponsorService, IPriceFormatter _priceFormatter, MediaSettings _mediaSettings)
        {
            var customer = _customerService.GetCustomerById(Sponsor.CustomerId);

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

            //get sponsor data
            var sponsorData = _sponsorService.GetSponsorData(Sponsor.BattleId, Sponsor.BattleType, Sponsor.CustomerId);

            var model = new SponsorPublicModel
            {
                SponsorshipStatus     = Sponsor.SponsorshipStatus,
                SponsorshipStatusName = Sponsor.SponsorshipStatus.ToString(),
                CustomerId            = Sponsor.CustomerId,
                SeName                 = customer.GetSeName(_workContext.WorkingLanguage.Id),
                SponsorName            = customer.GetFullName(),
                SponsorProfileImageUrl =
                    _pictureService.GetPictureUrl(
                        customer.GetAttribute <int>(SystemCustomerAttributeNames.AvatarPictureId),
                        _mediaSettings.AvatarPictureSize, false),
                SponsorshipAmount          = Sponsor.SponsorshipAmount,
                SponsorshipAmountFormatted =
                    _priceFormatter.FormatPrice(Sponsor.SponsorshipAmount, true, _workContext.WorkingCurrency),
                SponsorData     = sponsorData.ToModel(_pictureService),
                SponsorshipType = Sponsor.SponsorshipType
            };


            return(model);
        }
Example #33
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);
        }