Exemplo n.º 1
0
        public AddClaimViewModel Fill(IClaimSource claimSource, int playerUserId)
        {
            var disallowReasons = claimSource.ValidateIfCanAddClaim(playerUserId)
                                  .Select(x => x.ToViewModel()).ToList();

            CanSendClaim = !disallowReasons.Any();

            IsProjectRelatedReason = disallowReasons.Intersect(new[]
            {
                AddClaimForbideReasonViewModel.ProjectClaimsClosed,
                AddClaimForbideReasonViewModel.ProjectNotActive,
            })
                                     .Any();



            if (!disallowReasons.Any())
            {
                var myClaims = claimSource.Project.Claims.OfUserActive(playerUserId);
                if (myClaims.Any())
                {
                    disallowReasons.Add(AddClaimForbideReasonViewModel
                                        .AlredySentNotApprovedClaimToAnotherPlace);
                }
            }

            ValidationStatus = disallowReasons;
            ProjectAllowsMultipleCharacters = claimSource.Project.Details.EnableManyCharacters;

            ProjectId       = claimSource.Project.ProjectId;
            ProjectName     = claimSource.Project.ProjectName;
            TargetName      = claimSource.Name;
            Description     = claimSource.Description.ToHtmlString();
            IsAvailable     = claimSource.IsAvailable;
            ClaimApplyRules = claimSource.Project.Details.ClaimApplyRules.ToHtmlString();
            Fields          = new CustomFieldsViewModel(playerUserId, claimSource);
            IsRoot          = claimSource.IsRoot;
            return(this);
        }
 private void ShouldBeNotAllowed(IClaimSource claimSource, AddClaimForbideReason reason)
 => claimSource.ValidateIfCanAddClaim(Mock.Player.UserId).ShouldContain(reason);
 private void ShouldBeAllowed(IClaimSource mockCharacter)
 => mockCharacter.ValidateIfCanAddClaim(Mock.Player.UserId).ShouldBeEmpty();