Exemple #1
0
        public async Task <IActionResult> PutApproverType([FromRoute] int id, [FromBody] ApproverType approverType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != approverType.Id)
            {
                return(BadRequest());
            }

            _context.Entry(approverType).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ApproverTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(_context.ApproverTypes.Find(id)));
        }
Exemple #2
0
        /// <summary>
        /// Signs the CDA Package and creates the signature document.
        /// </summary>
        /// <param name="package">A CDAPackageBase instance containing the root document to sign.</param>
        /// <param name="signingCert">The certificate used to sign the root document.</param>
        /// <returns>Signature of the root document.</returns>
        private static byte[] CreateSignature(CDAPackage package, X509Certificate2 signingCert)
        {
            package.SigningTime = DateTime.Now.ToUniversalTime();

            byte[] rootDocumentContent = package.CDADocumentRoot.FileContent;

            byte[] hash = CalculateSHA1(rootDocumentContent);

            var manifest = new ManifestType();

            manifest.Reference = new ReferenceType[]
            {
                new ReferenceType()
                {
                    URI          = package.CDADocumentRoot.FileName,
                    DigestMethod = new DigestMethodType()
                    {
                        Algorithm = SignedXml.XmlDsigSHA1Url
                    },
                    DigestValue = hash
                }
            };

            var approver = new ApproverType();

            approver.personId              = package.Approver.PersonId.ToString();
            approver.personName            = new PersonNameType();
            approver.personName.familyName = package.Approver.PersonFamilyName;
            if (package.Approver.PersonTitles != null)
            {
                approver.personName.nameTitle = package.Approver.PersonTitles.ToArray();
            }
            if (package.Approver.PersonGivenNames != null)
            {
                approver.personName.givenName = package.Approver.PersonGivenNames.ToArray();
            }
            if (package.Approver.PersonNameSuffixes != null)
            {
                approver.personName.nameSuffix = package.Approver.PersonNameSuffixes.ToArray();
            }

            var eSignature = new eSignatureType();

            eSignature.Manifest    = manifest;
            eSignature.approver    = approver;
            eSignature.signingTime = package.SigningTime.Value;

            XmlDocument eSignatureXml = eSignature.SerializeToXml();

            ISignedContainerProfileService signedContainerService = XspFactory.Instance.GetSignedContainerProfileService(XspVersion.V_2010);

            XmlDocument signedDoc = signedContainerService.Create(eSignatureXml, signingCert);

            var ms = new MemoryStream();

            signedDoc.Save(ms);

            return(ms.ToArray());
        }
Exemple #3
0
        public async Task <IActionResult> PostApproverType([FromBody] ApproverType approverType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.ApproverTypes.Add(approverType);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetApproverType", new { id = approverType.Id }, approverType));
        }
Exemple #4
0
 public bool AddApproverForDepartment(int idEmployee, int idDepartment, ApproverType approverType)
 {
     throw new NotImplementedException();
 }
Exemple #5
0
 public IEnumerable <ApproveDepartment> GetDepartmentApprover(int idDepartment, ApproverType approverType = null)
 {
     throw new NotImplementedException();
 }
Exemple #6
0
 public bool Allowed(ApproverType approverType)
 {
     return(DtoApproverDepartments.Any(a => a.ApproveNumber == (int)approverType));
 }
Exemple #7
0
        public async Task <IActionResult> GetCouponUser([FromRoute] int id, [FromRoute] string approverTypeCode)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var couponUser = await _context
                             .CouponUsers
                             .Include(x => x.ApproverType)
                             .Where(x => x.UserId == id)
                             .FirstOrDefaultAsync();

            if (couponUser == null)
            {
                return(NotFound());
            }

            // Get approver type
            ApproverType approverType = couponUser.ApproverType;

            // Get coupon user with approvers
            List <CouponUserWithApprover> couponUserWithApprovers = await _context
                                                                    .CouponUserWithApprovers
                                                                    .Where(x => x.ApplicantUserId == couponUser.Id)
                                                                    .Where(x => x.Status == Enumerations.Status.Active)
                                                                    .ToListAsync();

            // Verify wheteher coupon user with approvers was not found
            if (!couponUserWithApprovers.Any())
            {
                return(NotFound());
            }

            // Build query parameters
            List <QueryParameter> parameters = new List <QueryParameter>();

            parameters.Add(new QueryParameter {
                key = "{approverTypeCode}", value = approverType.Code
            });
            parameters.Add(new QueryParameter {
                key = "{couponUserIds}", value = $"'{couponUserWithApprovers.FirstOrDefault().ApplicantUserId}'"
            });

            // Load coupon user by approver type
            CouponUserByApproverType couponUserByApproverType = _context
                                                                .CouponUserByApproverTypes
                                                                .FromSql(QueryBuilder.Build("GetCouponUsersByIdsAndApproverTypeCode.txt", parameters))
                                                                .ToList()
                                                                .FirstOrDefault();

            // Verify whether coupon user by approver type is not null
            if (couponUserByApproverType == null)
            {
                return(NotFound());
            }

            // Get approver ids
            List <int> approverIds = couponUserWithApprovers
                                     .Select(x => x.ApproverUserId)
                                     .ToList();

            // Update parameters
            parameters.First().value = approverTypeCode;
            parameters.Last().value  = $"'{string.Join("','", approverIds)}'";

            // Assign proper approvers with its dependencies
            couponUserByApproverType.Approvers = _context
                                                 .CouponUserByApproverTypes
                                                 .FromSql(QueryBuilder.Build("GetCouponUsersByIdsAndApproverTypeCode.txt", parameters))
                                                 .ToList();

            return(Ok(couponUserByApproverType));
        }
        private void InitializeScenario(ComputerRoleType role, string computerName, IntelEmployeeStatus requesterStatus = IntelEmployeeStatus.A, ApproverType approverType = ApproverType.ApproverIsSubmitter)
        {
            this.requestDto = new CreateComputerRequestDto();
            this.requestDto.ComputerRole   = role;
            this.requestDto.ComputerName   = computerName;
            this.requestDto.ComputerDomain = computerDomain;
            switch (requesterStatus)
            {
            case IntelEmployeeStatus.A:
            case IntelEmployeeStatus.H:
                this.requestDto.RequesterWwid = StubCdisEmployees.BBActiveRequesterUserWwid;
                break;

            case IntelEmployeeStatus.T:
                this.requestDto.RequesterWwid = StubCdisEmployees.BBInactiveRequesterUserWwid;
                break;

            default:
                this.requestDto.RequesterWwid = StubCdisEmployees.NonStatus;
                break;
            }
            this.requestDto.ManagerWwid   = StubCdisEmployees.BBActiveManagerUserWwid;
            this.requestDto.SubmitterWwid = StubCdisEmployees.BBActiveSubmitterUserWwid;
            switch (approverType)
            {
            case ApproverType.ApproverIsInactive:
                this.requestDto.ApproverWwid = StubCdisEmployees.BBInactiveApproverUserWwid;
                break;

            case ApproverType.ApproverIsSubmitter:
                this.requestDto.ApproverWwid = this.requestDto.SubmitterWwid;
                break;

            case ApproverType.AuthoritySignature:
                this.requestDto.ApproverWwid = StubCdisEmployees.BBActiveManagerWithSig;
                break;

            case ApproverType.IsInManagementChain:
                this.requestDto.ApproverWwid = StubCdisEmployees.BBActiveSecondManager;
                break;
            }
            this.request = (CreateComputerRequest)this.factory.GetRequestFromDto(this.requestDto);
        }