Beispiel #1
0
        public ClaimViewModel(int currentUserId, Claim claim, IEnumerable <PluginOperationData <IPrintCardPluginOperation> > pluginOperationDatas, IReadOnlyCollection <PlotElement> plotElements)
        {
            ClaimId  = claim.ClaimId;
            Comments =
                claim.Comments.Where(comment => comment.ParentCommentId == null)
                .Select(comment => new CommentViewModel(comment, currentUserId)).OrderBy(c => c.CreatedTime);
            HasMasterAccess    = claim.HasMasterAccess(currentUserId);
            CanManageThisClaim = claim.CanManageClaim(currentUserId);
            IsMyClaim          = claim.PlayerUserId == currentUserId;
            Player             = claim.Player;
            ProjectId          = claim.ProjectId;
            Status             = claim.ClaimStatus;
            CharacterGroupId   = claim.CharacterGroupId;
            GroupName          = claim.Group?.CharacterGroupName;
            CharacterId        = claim.CharacterId;
            CharacterActive    = claim.Character?.IsActive;
            OtherClaimsForThisCharacterCount = claim.IsApproved ? 0 : claim.OtherClaimsForThisCharacter().Count();
            HasOtherApprovedClaim            = !claim.IsApproved && claim.OtherClaimsForThisCharacter().Any(c => c.IsApproved);
            Data = new CharacterTreeBuilder(claim.Project.RootGroup, currentUserId).Generate();
            OtherClaimsFromThisPlayerCount     =
                OtherClaimsFromThisPlayerCount = claim.IsApproved || (claim.Project.Details?.EnableManyCharacters ?? false)
          ? 0
          : claim.OtherPendingClaimsForThisPlayer().Count();
            Description = claim.Character?.Description.ToHtmlString();
            Masters     =
                claim.Project.GetMasterListViewModel()
                .Union(new MasterListItemViewModel()
            {
                Id = "-1", Name = "Нет"
            });
            ResponsibleMasterId = claim.ResponsibleMasterUserId ?? -1;
            ResponsibleMaster   = claim.ResponsibleMasterUser;
            Fields        = new CustomFieldsViewModel(currentUserId, claim);
            Navigation    = CharacterNavigationViewModel.FromClaim(claim, currentUserId, CharacterNavigationPage.Claim);
            ClaimFee      = new ClaimFeeViewModel(claim, currentUserId);
            Problems      = claim.GetProblems().Select(p => new ProblemViewModel(p)).ToList();
            PlayerDetails = UserProfileDetailsViewModel.FromUser(claim.Player);
            PrintPlugins  = pluginOperationDatas.Select(PluginOperationDescriptionViewModel.Create);
            ProjectActive = claim.Project.Active;

            if (claim.PlayerUserId == currentUserId || claim.HasMasterAccess(currentUserId, acl => acl.CanManageMoney))
            {
                //Finance admins can create any payment. User also can create any payment, but it will be moderated
                PaymentTypes = claim.Project.ActivePaymentTypes;
            }
            else
            {
                //All other master can create only payment from user to himself.
                PaymentTypes = claim.Project.ActivePaymentTypes.Where(pt => pt.UserId == currentUserId);
            }


            if (claim.Character != null)
            {
                ParentGroups = new CharacterParentGroupsViewModel(claim.Character,
                                                                  claim.HasMasterAccess(currentUserId));
            }

            Plot = claim.IsApproved && claim.Character != null
        ? claim.Character.GetOrderedPlots(plotElements).ToViewModels(currentUserId, claim.Character)
        : Enumerable.Empty <PlotElementViewModel>();
        }
        public ClaimViewModel(User currentUser,
                              Claim claim,
                              IEnumerable <PluginOperationData <IPrintCardPluginOperation> > pluginOperationDatas,
                              IReadOnlyCollection <PlotElement> plotElements,
                              IUriService uriService,
                              IEnumerable <ProjectAccommodationType> availableAccommodationTypes = null,
                              IEnumerable <AccommodationRequest> accommodationRequests           = null,
                              IEnumerable <AccommodationPotentialNeighbors> potentialNeighbors   = null,
                              IEnumerable <AccommodationInvite> incomingInvite = null,
                              IEnumerable <AccommodationInvite> outgoingInvite = null)
        {
            ClaimId             = claim.ClaimId;
            CommentDiscussionId = claim.CommentDiscussionId;
            RootComments        = claim.CommentDiscussion.ToCommentTreeViewModel(currentUser.UserId);
            HasMasterAccess     = claim.HasMasterAccess(currentUser.UserId);
            CanManageThisClaim  = claim.HasAccess(currentUser.UserId,
                                                  acl => acl.CanManageClaims,
                                                  ExtraAccessReason.ResponsibleMaster);
            CanChangeRooms = claim.HasAccess(currentUser.UserId,
                                             acl => acl.CanSetPlayersAccommodations,
                                             ExtraAccessReason.PlayerOrResponsible);
            IsMyClaim                   = claim.PlayerUserId == currentUser.UserId;
            Player                      = claim.Player;
            ProjectId                   = claim.ProjectId;
            ProjectName                 = claim.Project.ProjectName;
            Status                      = new ClaimFullStatusView(claim, new AccessArguments(claim, currentUser.UserId));
            CharacterGroupId            = claim.CharacterGroupId;
            GroupName                   = claim.Group?.CharacterGroupName;
            CharacterId                 = claim.CharacterId;
            CharacterActive             = claim.Character?.IsActive;
            CharacterAutoCreated        = claim.Character?.AutoCreated;
            AvailableAccommodationTypes = availableAccommodationTypes?.Where(a =>
                                                                             a.IsPlayerSelectable || a.Id == claim.AccommodationRequest?.AccommodationTypeId ||
                                                                             claim.HasMasterAccess(currentUser.UserId)).ToList();
            PotentialNeighbors               = potentialNeighbors;
            AccommodationRequest             = claim.AccommodationRequest;
            IncomingInvite                   = incomingInvite;
            OutgoingInvite                   = outgoingInvite;
            OtherClaimsForThisCharacterCount = claim.IsApproved
              ? 0
              : claim.OtherClaimsForThisCharacter().Count();
            HasOtherApprovedClaim = !claim.IsApproved &&
                                    claim.OtherClaimsForThisCharacter().Any(c => c.IsApproved);
            Data = new CharacterTreeBuilder(claim.Project.RootGroup, currentUser.UserId).Generate();
            OtherClaimsFromThisPlayerCount     =
                OtherClaimsFromThisPlayerCount =
                    claim.IsApproved || claim.Project.Details.EnableManyCharacters
                      ? 0
                      : claim.OtherPendingClaimsForThisPlayer().Count();
            Masters =
                claim.Project.GetMasterListViewModel()
                .Union(new MasterListItemViewModel()
            {
                Id = "-1", Name = "Нет"
            });
            ResponsibleMasterId = claim.ResponsibleMasterUserId ?? -1;
            ResponsibleMaster   = claim.ResponsibleMasterUser;
            Fields     = new CustomFieldsViewModel(currentUser.UserId, claim);
            Navigation =
                CharacterNavigationViewModel.FromClaim(claim,
                                                       currentUser.UserId,
                                                       CharacterNavigationPage.Claim);
            ClaimFee      = new ClaimFeeViewModel(claim, this, currentUser.UserId);
            Problems      = claim.GetProblems().Select(p => new ProblemViewModel(p)).ToList();
            PlayerDetails = new UserProfileDetailsViewModel(claim.Player,
                                                            (AccessReason)claim.Player.GetProfileAccess(currentUser));
            PrintPlugins         = pluginOperationDatas.Select(PluginOperationDescriptionViewModel.Create);
            ProjectActive        = claim.Project.Active;
            CheckInStarted       = claim.Project.Details.CheckInProgress;
            CheckInModuleEnabled = claim.Project.Details.EnableCheckInModule;
            Validator            = new ClaimCheckInValidator(claim);

            AccommodationEnabled = claim.Project.Details.EnableAccommodation;

            if (claim.HasAccess(currentUser.UserId,
                                acl => acl.CanManageMoney, ExtraAccessReason.Player))
            {
                //Finance admins can create any payment. User also can create any payment, but it will be moderated
                PaymentTypes = claim.Project.ActivePaymentTypes;
            }
            else
            {
                //All other master can create only payment from user to himself.
                PaymentTypes =
                    claim.Project.ActivePaymentTypes.Where(pt => pt.UserId == currentUser.UserId);
            }


            if (claim.Character != null)
            {
                ParentGroups = new CharacterParentGroupsViewModel(claim.Character,
                                                                  claim.HasMasterAccess(currentUser.UserId));
            }

            if (claim.IsApproved && claim.Character != null)
            {
                var readOnlyList = claim.Character.GetOrderedPlots(plotElements);
                Plot = PlotDisplayViewModel.Published(readOnlyList,
                                                      currentUser.UserId,
                                                      claim.Character,
                                                      uriService);
            }
            else
            {
                Plot = PlotDisplayViewModel.Empty();
            }
        }
Beispiel #3
0
 public FinanceOperationAdminFunctionsViewModel(ClaimFeeViewModel source)
 {
     Allowed = source.HasFeeAdminAccess;
     PreferentialFeeEnabled = source.PreferentialFeeEnabled;
     PreferentialFeeUser    = source.PreferentialFeeUser;
 }