public CharacterListItemViewModel(
            [NotNull]
            Character character,
            int currentUserId,
            IEnumerable <ClaimProblem> problems)
        {
            if (character == null)
            {
                throw new ArgumentNullException(nameof(character));
            }

            BusyStatus = character.GetBusyStatus();

            if (character.ApprovedClaim != null)
            {
                ApprovedClaimId = character.ApprovedClaim.ClaimId;
                Player          = character.ApprovedClaim.Player;
            }

            Name        = character.CharacterName;
            CharacterId = character.CharacterId;
            ProjectId   = character.ProjectId;
            Fields      = character.Project.GetFieldsNotFilledWithoutOrder().ToList();
            Fields.FillFrom(character);
            Fields.FillFrom(character.ApprovedClaim);
            Problems = problems.Select(p => new ProblemViewModel(p)).ToList();

            Groups = new CharacterParentGroupsViewModel(character,
                                                        character.HasMasterAccess(currentUserId));

            Responsible = character.GetResponsibleMaster();
        }
Exemple #2
0
 public CharacterDetailsViewModel(int?currentUserIdOrDefault, Character character, IEnumerable <PlotElement> plots)
 {
     Description  = character.Description.ToHtmlString();
     Player       = character.ApprovedClaim?.Player;
     HasAccess    = character.HasAnyAccess(currentUserIdOrDefault);
     ParentGroups = new CharacterParentGroupsViewModel(character, character.HasMasterAccess(currentUserIdOrDefault));
     HidePlayer   = character.HidePlayerForCharacter;
     Navigation   =
         CharacterNavigationViewModel.FromCharacter(character, CharacterNavigationPage.Character,
                                                    currentUserIdOrDefault);
     Fields = new CustomFieldsViewModel(currentUserIdOrDefault, character, disableEdit: true);
     Plot   = plots.ToViewModels(currentUserIdOrDefault, character);
 }
Exemple #3
0
        public CharacterDetailsViewModel(int?currentUserIdOrDefault, Character character, IReadOnlyCollection <PlotElement> plots, IUriService uriService)
        {
            Player       = character.ApprovedClaim?.Player;
            HasAccess    = character.HasAnyAccess(currentUserIdOrDefault);
            ParentGroups = new CharacterParentGroupsViewModel(character, character.HasMasterAccess(currentUserIdOrDefault));
            HidePlayer   = character.HidePlayerForCharacter;
            Navigation   =
                CharacterNavigationViewModel.FromCharacter(character, CharacterNavigationPage.Character,
                                                           currentUserIdOrDefault);
            Fields = new CustomFieldsViewModel(currentUserIdOrDefault, character, disableEdit: true);
            Plot   = PlotDisplayViewModel.Published(plots, currentUserIdOrDefault, character, uriService);

            HasMasterAccess = character.HasMasterAccess(currentUserIdOrDefault);
            CreatedAt       = character.CreatedAt;
            UpdatedAt       = character.UpdatedAt;
            CreatedBy       = character.CreatedBy;
            UpdatedBy       = character.UpdatedBy;
        }
        public CharacterListItemViewModel([NotNull] Character character, int currentUserId, IEnumerable <ClaimProblem> problems, IReadOnlyCollection <PlotElement> plots)
        {
            if (character == null)
            {
                throw new ArgumentNullException(nameof(character));
            }


            if (character.ApprovedClaim != null)
            {
                BusyStatus      = CharacterBusyStatusView.HasPlayer;
                ApprovedClaimId = character.ApprovedClaim.ClaimId;
                Player          = character.ApprovedClaim.Player;
            }
            else if (character.Claims.Any(c => c.IsActive))
            {
                BusyStatus = CharacterBusyStatusView.Discussed;
            }
            else if (character.IsAcceptingClaims)
            {
                BusyStatus = CharacterBusyStatusView.NotSend;
            }
            else
            {
                BusyStatus = CharacterBusyStatusView.Npc;
            }
            Name        = character.CharacterName;
            CharacterId = character.CharacterId;
            ProjectId   = character.ProjectId;
            Fields      = new CustomFieldsViewModel(currentUserId, character, disableEdit: true); //This disable edit will speed up some requests.
            Problems    = problems.Select(p => new ProblemViewModel(p)).ToList();

            IndReadyPlotsCount = plots.Count(p => p.IsCompleted && p.TargetCharacters.Select(c => c.CharacterId).Contains(character.CharacterId));
            IndAllPlotsCount   = plots.Count(p => p.IsActive && p.TargetCharacters.Select(c => c.CharacterId).Contains(character.CharacterId));
            ColReadyPlotsCount = plots.Count(p => p.IsCompleted && !p.TargetCharacters.Select(c => c.CharacterId).Contains(character.CharacterId));
            ColAllPlotsCount   = plots.Count(p => p.IsActive && !p.TargetCharacters.Select(c => c.CharacterId).Contains(character.CharacterId));
            Groups             = new CharacterParentGroupsViewModel(character, character.HasMasterAccess(currentUserId));
        }