コード例 #1
0
 public JobItem GetById(Guid id)
 {
     if (!CurrentUser.HasRole(UserRole.Member))
     {
         throw new DomainValidationException(Messages.InsufficientSecurityClearance);
     }
     return(_jobItemRepository.GetById(id));
 }
コード例 #2
0
ファイル: CertificateService.cs プロジェクト: mazj/JobSystem
        private JobItem GetJobItem(Guid jobItemId)
        {
            var jobItem = _jobItemRepository.GetById(jobItemId);

            if (jobItem == null)
            {
                throw new ArgumentException("A valid job item ID must be supplied for the certificate");
            }
            return(jobItem);
        }
コード例 #3
0
        public ConsignmentItem Create(Guid id, Guid jobItemId, Guid consignmentId, string instructions)
        {
            if (!CurrentUser.HasRole(UserRole.Member))
            {
                throw new DomainValidationException(Messages.InsufficientSecurityClearance);
            }
            if (id == Guid.Empty)
            {
                throw new ArgumentException("An ID must be supplied for the consignment item.");
            }
            var jobItem = _jobItemRepository.GetById(jobItemId);

            if (jobItem == null)
            {
                throw new ArgumentException("A valid ID must be supplied for the job item.");
            }
            if (jobItem.Job.IsPending)
            {
                throw new DomainValidationException(Messages.PendingJob);
            }
            var consignment = _consignmentRepository.GetById(consignmentId);

            if (consignment == null)
            {
                throw new ArgumentException("A valid ID must be supplied for the parent consignment.");
            }
            var consignmentItem = new ConsignmentItem
            {
                Id           = id,
                Consignment  = consignment,
                ItemNo       = _consignmentRepository.GetConsignmentItemCount(consignmentId) + 1,
                JobItem      = jobItem,
                Instructions = instructions
            };

            jobItem.Status = _listItemRepository.GetByType(ListItemType.StatusConsigned);
            ValidateAnnotatedObjectThrowOnFailure(consignmentItem);
            _jobItemRepository.EmitItemHistory(CurrentUser, jobItemId, 0, 0, String.Format("Item consigned on {0}", consignment.ConsignmentNo), ListItemType.StatusConsigned, ListItemType.WorkTypeAdministration);
            _consignmentItemRepository.Create(consignmentItem);
            _jobItemRepository.Update(jobItem);
            return(consignmentItem);
        }
コード例 #4
0
ファイル: OrderItemService.cs プロジェクト: mazj/JobSystem
        private JobItem GetJobItem(Guid jobItemId)
        {
            var jobItem = _jobItemRepository.GetById(jobItemId);

            if (jobItem == null)
            {
                throw new ArgumentException("A valid ID must be supplied for the job item");
            }
            if (jobItem.Job.IsPending)
            {
                throw new DomainValidationException(OrderItemMessages.JobPending, "JobItem");
            }
            return(jobItem);
        }