예제 #1
0
        public PartakerReqViewModel CreatePartakerReq(Guid taskId, Guid requestorStaffId, PartakerKinds kind)
        {

            var task = TaskExistsResult.Check(m_TaskManager, taskId).ThrowIfFailed().Task;
            var staff = StaffExistsResult.Check(m_StaffManager, requestorStaffId).ThrowIfFailed().Staff;

            //申请人应当为当前用户
            if (staff.Account.Id != this.AccountId)
            {
                throw new FineWorkException("员工不属于当前登录用户.");
            }
            //任务与员工应当属于同一组织
            if (task.Creator.Org.Id != staff.Org.Id)
            {
                throw new FineWorkException("任务与员工分属不同的组织.");
            }
            //申请人不能已经是任务的参与者
            PartakerNotExistsResult.CheckStaff(task, requestorStaffId).ThrowIfFailed();
            //任务必须开放申请的权限
            PartakerReqIsEnabledResult.Check(task, kind).ThrowIfFailed();

            var req = m_PartakerReqManager.CreatePartakerReq(task, staff, kind);

            return req.ToViewModel();
        }
예제 #2
0
        public virtual void AssignFrom(PartakerEntity entity)
        {
            if (entity == null) throw new ArgumentNullException(nameof(entity));

            this.Id = entity.Id;
            this.TaskId = entity.Task.Id;
            this.StaffId = entity.Staff.Id;
            this.Kind = entity.Kind;
        }
예제 #3
0
        public static PartakerInvExistsResult CheckPending(IPartakerInvManager partakerInvManager, TaskEntity task, StaffEntity staff,
            PartakerKinds partakerKind)
        {
            if (partakerInvManager == null) throw new ArgumentNullException(nameof(partakerInvManager));
            if (task == null) throw new ArgumentNullException(nameof(task));
            if (staff == null) throw new ArgumentNullException(nameof(staff));

            var pendingInvs = partakerInvManager.FetchPendingPartakerInvs(task.Id, staff.Id);
            var existed = pendingInvs.FirstOrDefault(p => p.PartakerKind == partakerKind);

            if (existed == null)
            {
                return new PartakerInvExistsResult(false, "不存在对应的角色邀请.", null);
            }
            return new PartakerInvExistsResult(true, null, existed);
        }