Ejemplo n.º 1
0
        public AcknowledgementData GetAcknowledgementData(Guid id)
        {
            var player = _queries.GetPlayer(id);

            if (player == null)
            {
                throw new RegoValidationException(ErrorMessagesEnum.PlayerWithRequestedIdDoesntExist.ToString());
            }

            var date = player.SelfExclusion.HasValue
                ? ExclusionDateHelper.GetSelfExcusionEndDate(player.SelfExclusion.Value, player.SelfExclusionDate.Value)
                : player.TimeOut.HasValue
                    ? ExclusionDateHelper.GetTimeOutEndDate(player.TimeOut.Value, player.TimeOutDate.Value)
                    : new DateTimeOffset();

            return(new AcknowledgementData
            {
                Date = date.ToString("yyyy/MM/dd")
            });
        }
Ejemplo n.º 2
0
        public LoginValidator(BrandQueries brandQueries, IAuthQueries authQueries, string password)
        {
            CascadeMode = CascadeMode.StopOnFirstFailure;

            RuleFor(player => player)
            .NotNull()
            .WithMessage(PlayerAccountResponseCode.UsernamePasswordCombinationIsNotValid.ToString())
            .WithName("Player");

            When(player => player != null, () =>
            {
                RuleFor(player => player.IsInactive)
                .NotEqual(true)
                .WithMessage(PlayerAccountResponseCode.NonActive.ToString());

                RuleFor(player => player.IsLocked)
                .NotEqual(true)
                .WithMessage(PlayerAccountResponseCode.AccountLocked.ToString());

                RuleFor(player => player.BrandId)
                .Must(brandQueries.IsBrandActive)
                .WithMessage(PlayerAccountResponseCode.InactiveBrand.ToString());

                if (password != null)
                {
                    RuleFor(player => player)
                    .Must(player =>
                    {
                        var loginValidationResult = authQueries.GetValidationResult(new LoginActor
                        {
                            ActorId  = player.Id,
                            Password = password
                        });

                        return(loginValidationResult.IsValid);
                    })
                    .WithMessage(PlayerAccountResponseCode.UsernamePasswordCombinationIsNotValid.ToString())
                    .WithName("Player");
                }

                RuleFor(player => player.SelfExclusion)
                .Must(selfExclusion => !selfExclusion.HasValue || selfExclusion.Value != SelfExclusion.Permanent)
                .WithMessage(PlayerAccountResponseCode.SelfExcludedPermanent.ToString(),
                             player => new ValidationParam
                {
                    Name  = "start",
                    Value = player.SelfExclusionDate.Value.ToString("yyyy/MM/dd hh:mm tt")
                })
                .Must(selfExclusion => !selfExclusion.HasValue)
                .WithMessage(PlayerAccountResponseCode.SelfExcluded.ToString(),
                             player => new ValidationParam
                {
                    Name  = "start",
                    Value = player.SelfExclusionDate.Value.ToString("yyyy/MM/dd hh:mm tt")
                },
                             player =>
                {
                    var endDate = ExclusionDateHelper.GetSelfExcusionEndDate(player.SelfExclusion.Value,
                                                                             player.SelfExclusionDate.Value);

                    return(new ValidationParam
                    {
                        Name = "end",
                        Value = endDate.ToString("yyyy/MM/dd hh:mm tt")
                    });
                },
                             player =>
                {
                    return(new ValidationParam
                    {
                        Name = "length",
                        Value = Enum.GetName(typeof(SelfExclusion), player.SelfExclusion.Value)
                    });
                });

                RuleFor(player => player.TimeOut.HasValue)
                .NotEqual(true)
                .WithMessage(PlayerAccountResponseCode.TimedOut.ToString(),
                             player => new ValidationParam
                {
                    Name  = "start",
                    Value = player.TimeOutDate.Value.ToString("yyyy/MM/dd hh:mm tt")
                },
                             player =>
                {
                    var endDate = ExclusionDateHelper.GetTimeOutEndDate(player.TimeOut.Value,
                                                                        player.TimeOutDate.Value);

                    return(new ValidationParam
                    {
                        Name = "end",
                        Value = endDate.ToString("yyyy/MM/dd hh:mm tt")
                    });
                },
                             player =>
                {
                    return(new ValidationParam
                    {
                        Name = "length",
                        Value = Enum.GetName(typeof(TimeOut), player.TimeOut.Value)
                    });
                });
            });
        }
Ejemplo n.º 3
0
 public DateTimeOffset GetTimeOutEndDate(TimeOut timeOutType, DateTimeOffset startDate)
 {
     return(ExclusionDateHelper.GetTimeOutEndDate(timeOutType, startDate));
 }
Ejemplo n.º 4
0
 public DateTimeOffset GetSelfExclusionEndDate(SelfExclusion exclusionType, DateTimeOffset startDate)
 {
     return(ExclusionDateHelper.GetSelfExcusionEndDate(exclusionType, startDate));
 }