private async Task <ActionResult> ShowClaim(Claim claim)
        {
            var error = WithClaim(claim);

            if (error != null)
            {
                return(error);
            }

            var printPlugins = claim.HasMasterAccess(CurrentUserId) && claim.IsApproved
        ? (await PluginFactory.GetPossibleOperations <IPrintCardPluginOperation>(claim.ProjectId)).Where(
                p => p.AllowPlayerAccess || claim.HasMasterAccess(CurrentUserId))
        : Enumerable.Empty <PluginOperationData <IPrintCardPluginOperation> >();

            var plots = claim.IsApproved && claim.Character != null
        ? await _plotRepository.GetPlotsForCharacter(claim.Character)
        : new PlotElement[]
            {
            };
            var claimViewModel = new ClaimViewModel(CurrentUserId, claim, printPlugins, plots);

            if (claimViewModel.Comments.Any(c => !c.IsRead))
            {
                await
                _claimService.UpdateReadCommentWatermark(claim.ProjectId, claim.ClaimId, CurrentUserId,
                                                         claim.Comments.Max(c => c.CommentId));
            }

            return(View("Edit", claimViewModel));
        }
        private async Task <ActionResult> ShowClaim(Claim claim)
        {
            var error = WithClaim(claim);

            if (error != null)
            {
                return(error);
            }

            var printPlugins = claim.HasMasterAccess(CurrentUserId) && claim.IsApproved
        ? (PluginFactory.GetProjectOperations <IPrintCardPluginOperation>(claim.Project)).Where(
                p => p.AllowPlayerAccess || claim.HasMasterAccess(CurrentUserId))
        : Enumerable.Empty <PluginOperationData <IPrintCardPluginOperation> >();

            var currentUser = await GetCurrentUserAsync();

            var plots = claim.IsApproved && claim.Character != null
        ? await _plotRepository.GetPlotsForCharacter(claim.Character)
        : new PlotElement[]
            {
            };
            var claimViewModel = new ClaimViewModel(currentUser, claim, printPlugins, plots);

            if (claim.CommentDiscussion.Comments.Any(c => !c.IsReadByUser(CurrentUserId)))
            {
                await
                _claimService.UpdateReadCommentWatermark(claim.ProjectId, claim.CommentDiscussion.CommentDiscussionId,
                                                         claim.CommentDiscussion.Comments.Max(c => c.CommentId));
            }


            var parents = claim.GetTarget().GetParentGroupsToTop();

            claimViewModel.SubscriptionTooltip =
                claimViewModel.GetFullSubscriptionTooltip(parents, currentUser.Subscriptions, claimViewModel.ClaimId);

            return(View("Edit", claimViewModel));
        }
Exemple #3
0
        private async Task <ActionResult> ShowClaim(Claim claim)
        {
            var error = WithClaim(claim);

            if (error != null)
            {
                return(error);
            }

            var printPlugins = claim.HasMasterAccess(CurrentUserId) && claim.IsApproved
        ? (PluginFactory.GetProjectOperations <IPrintCardPluginOperation>(claim.Project)).Where(
                p => p.AllowPlayerAccess || claim.HasMasterAccess(CurrentUserId))
        : Enumerable.Empty <PluginOperationData <IPrintCardPluginOperation> >();

            var currentUser = await GetCurrentUserAsync().ConfigureAwait(false);

            var plots = claim.IsApproved && claim.Character != null
        ? await _plotRepository.GetPlotsForCharacter(claim.Character).ConfigureAwait(false)
        : new PlotElement[]
            {
            };

            IEnumerable <ProjectAccommodationType>        availableAccommodation  = null;
            IEnumerable <AccommodationRequest>            requestForAccommodation = null;
            IEnumerable <AccommodationPotentialNeighbors> potentialNeighbors      = null;
            IEnumerable <AccommodationInvite>             incomingInvite          = null;
            IEnumerable <AccommodationInvite>             outgoingInvite          = null;


            if (claim.Project.Details.EnableAccommodation)
            {
                availableAccommodation = await
                                         _accommodationRepository.GetAccommodationForProject(claim.ProjectId).ConfigureAwait(false);

                requestForAccommodation = await _accommodationRequestRepository
                                          .GetAccommodationRequestForClaim(claim.ClaimId).ConfigureAwait(false);

                var acceptedRequest = requestForAccommodation
                                      .FirstOrDefault(request => request.IsAccepted == AccommodationRequest.InviteState.Accepted);
                var acceptedRequestId = acceptedRequest?.Id;
                var acceptedRequestAccommodationTypeIdId = acceptedRequest?.AccommodationTypeId;

                if (acceptedRequestId != null)
                {
                    var sameRequest = (await
                                       _accommodationRequestRepository.GetClaimsWithSameAccommodationTypeToInvite(
                                           acceptedRequestAccommodationTypeIdId.Value).ConfigureAwait(false)).Where(c => c.ClaimId != claim.ClaimId)
                                      .Select(c => new AccommodationPotentialNeighbors(c, NeighborType.WithSameType));;
                    var noRequest = (await
                                     _accommodationRequestRepository.GetClaimsWithOutAccommodationRequest(claim.ProjectId).ConfigureAwait(false)).Select(c => new AccommodationPotentialNeighbors(c, NeighborType.NoRequest));;
                    var currentNeighbors = (await
                                            _accommodationRequestRepository.GetClaimsWithSameAccommodationRequest(
                                                acceptedRequestId.Value).ConfigureAwait(false)).Select(c => new AccommodationPotentialNeighbors(c, NeighborType.Current));
                    potentialNeighbors = sameRequest.Union(noRequest).Where(element => currentNeighbors.All(el => el.ClaimId != element.ClaimId));
                }

                incomingInvite = await AccommodationInviteRepository.GetIncomingInviteForClaim(claim).ConfigureAwait(false);

                outgoingInvite = await AccommodationInviteRepository.GetOutgoingInviteForClaim(claim).ConfigureAwait(false);
            }

            var claimViewModel = new ClaimViewModel(currentUser, claim, printPlugins, plots, UriService, availableAccommodation, requestForAccommodation, potentialNeighbors, incomingInvite, outgoingInvite);

            if (claim.CommentDiscussion.Comments.Any(c => !c.IsReadByUser(CurrentUserId)))
            {
                await
                _claimService.UpdateReadCommentWatermark(claim.ProjectId, claim.CommentDiscussion.CommentDiscussionId,
                                                         claim.CommentDiscussion.Comments.Max(c => c.CommentId)).ConfigureAwait(false);
            }


            var parents = claim.GetTarget().GetParentGroupsToTop();

            claimViewModel.SubscriptionTooltip =
                claimViewModel.GetFullSubscriptionTooltip(parents, currentUser.Subscriptions, claimViewModel.ClaimId);

            return(View("Edit", claimViewModel));
        }