Ejemplo n.º 1
0
        public ClaimListItemViewModel([NotNull] Claim claim, int currentUserId)
        {
            if (claim == null)
            {
                throw new ArgumentNullException(nameof(claim));
            }
            var lastComment = claim.Comments.Where(c => c.IsVisibleToPlayer).OrderByDescending(c => c.CommentId).FirstOrDefault();

            ClaimId     = claim.ClaimId;
            ClaimStatus = (ClaimStatusView)claim.ClaimStatus;
            Name        = claim.Name;
            Player      = claim.Player;

            UpdateDate          = lastComment?.LastEditTime ?? claim.CreateDate;
            CreateDate          = claim.CreateDate;
            Responsible         = claim.ResponsibleMasterUser;
            LastModifiedBy      = lastComment?.Author ?? claim.Player;
            UnreadCommentsCount =
                claim.Comments.Count(comment => (comment.IsVisibleToPlayer || claim.HasMasterAccess(currentUserId)) &&
                                     !comment.IsReadByUser(currentUserId));

            ProjectId   = claim.ProjectId;
            ProjectName = claim.Project.ProjectName;
            Fields      = new CustomFieldsViewModel(currentUserId, claim);
            FeePaid     = claim.ClaimBalance();
            FeeDue      = claim.ClaimFeeDue();
        }
Ejemplo n.º 2
0
        public ClaimListItemViewModel([NotNull]
                                      Claim claim,
                                      int currentUserId)
        {
            if (claim == null)
            {
                throw new ArgumentNullException(nameof(claim));
            }
            var lastComment = claim.CommentDiscussion.Comments.Where(c => c.IsVisibleToPlayer)
                              .OrderByDescending(c => c.CommentId).FirstOrDefault();

            ClaimId = claim.ClaimId;

            ClaimFullStatusView = new ClaimFullStatusView(claim, new AccessArguments(claim, currentUserId));
            Name   = claim.Name;
            Player = claim.Player;

            UpdateDate          = lastComment?.LastEditTime ?? claim.CreateDate;
            CreateDate          = claim.CreateDate;
            Responsible         = claim.ResponsibleMasterUser;
            LastModifiedBy      = lastComment?.Author ?? claim.Player;
            UnreadCommentsCount = claim.CommentDiscussion.GetUnreadCount(currentUserId);

            ProjectId   = claim.ProjectId;
            ProjectName = claim.Project.ProjectName;
            Fields      = claim.GetFields();
            FeePaid     = claim.ClaimBalance();
            FeeDue      = claim.ClaimFeeDue();

            PreferentialFeeUser = claim.PreferentialFeeUser;


            AccomodationType = claim.AccommodationRequest?.AccommodationType.Name;
            RoomName         = claim.AccommodationRequest?.Accommodation?.Name;
        }
Ejemplo n.º 3
0
 public ClaimFeeViewModel(Claim claim, int currentUserId)
 {
     CurrentTotalFee = claim.ClaimTotalFee();
     CurrentBalance  = claim.ClaimBalance();
     CurrentFee      = claim.ClaimCurrentFee();
     IsFeeAdmin      = claim.HasMasterAccess(currentUserId, acl => acl.CanManageMoney);
     ClaimId         = claim.ClaimId;
     ProjectId       = claim.ProjectId;
     FeeVariants     = claim.Project.ProjectFeeSettings.Select(f => f.Fee).Union(CurrentFee).OrderBy(x => x).ToList();
 }
Ejemplo n.º 4
0
 private static bool ClaimPaidInFull(this Claim claim, DateTime operationDate)
 => claim.ClaimBalance() >= claim.ClaimTotalFee(operationDate.AddDays(-1), null);
Ejemplo n.º 5
0
 public static bool ClaimPaidInFull(this Claim claim)
 => claim.ClaimBalance() >= claim.ClaimTotalFee();
Ejemplo n.º 6
0
 /// <summary>
 /// Returns how many money left to pay
 /// </summary>
 public static int ClaimFeeDue(this Claim claim)
 => claim.ClaimTotalFee() - claim.ClaimBalance();
Ejemplo n.º 7
0
 /// <summary>
 /// Returns claim payment status from claim' data
 /// </summary>
 public static ClaimPaymentStatus PaymentStatus(this Claim claim)
 => GetClaimPaymentStatus(claim.ClaimTotalFee(), claim.ClaimBalance());