public async Task <ActionResult> Subscribe(int projectid, int claimid) { var user = await GetCurrentUserAsync(); var claim = await _claimsRepository.GetClaim(projectid, claimid); if (claim == null) { return(NotFound()); } var claimViewModel = new ClaimViewModel(user, claim, Array.Empty <PlotElement>(), UriService); await _claimService.SubscribeClaimToUser(projectid, claimid); var parents = claim.GetTarget().GetParentGroupsToTop(); var tooltip = claimViewModel.GetFullSubscriptionTooltip(parents, user.Subscriptions, claimViewModel.ClaimId); return(Json(tooltip)); }
public async Task <ActionResult> Subscribe(int projectid, int claimid) { var user = await GetCurrentUserAsync(); var claim = await _claimsRepository.GetClaim(projectid, claimid); if (claim == null) { return(HttpNotFound()); } var claimViewModel = new ClaimViewModel(user, claim, Enumerable.Empty <PluginOperationData <IPrintCardPluginOperation> >(), new PlotElement[] { }); await _claimService.SubscribeClaimToUser(projectid, claimid); var parents = claim.GetTarget().GetParentGroupsToTop(); var tooltip = claimViewModel.GetFullSubscriptionTooltip(parents, user.Subscriptions, claimViewModel.ClaimId); return(Json(tooltip, JsonRequestBehavior.AllowGet)); }
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)); }
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)); }