public ActionResult ConsumerLegalDeclineReason(int consumerProviderRegistrationId) { LegalApprovalModel model = new LegalApprovalModel() { ConsumerProviderRegistrationID = consumerProviderRegistrationId, IsProvider = false }; return(PartialView("_DeclineReason", model)); }
public LegalApprovalModel GetLegalApprovalModel(int consumerProviderRegistrationId, LoggedInUserDetails user) { _security.CheckBasicAccess(user); var providerRegistration = _consumerProviderRegistration.FirstOrDefault(p => p.ID == consumerProviderRegistrationId); // Get license var license = _licenseService.FirstOrDefault(p => p.ID == providerRegistration.OrganizationLicenseID); // Get license type whether it is custom or default. var licenseType = license.CustomLicenseID != null ? OrganisationLicenseType.Custom : OrganisationLicenseType.FromTemplate; var result = string.Empty; // Get organisation details var organization = _organisations.FirstOrDefault(i => i.ID == user.Organization.ID); switch (licenseType) { case OrganisationLicenseType.FromTemplate: { // Get schema file var schemaFile = _schemaFiles.FirstOrDefault(i => i.DataSchemaID == license.DataSchemaID); // Setup url to schema var urlToSchema = _urls.ToDownloadSchema(schemaFile.ID); // Get content for license var licenseDocument = _licenseContent.GetLicenseContent(organizationLicenseId: license.ID); // Setup license content with details _licenseContent.InsertLicenseDetails(licenseDocument, urlToSchema, _config.DataLinkerHost, organization.ID, license.ProviderEndpointID != 0); result = licenseDocument.OuterXml; break; } case OrganisationLicenseType.Custom: { // Get content for license var urlToDownloadLicese = _urls.ToDownloadLicense(license.ApplicationID, license.DataSchemaID, license.ID); result = urlToDownloadLicese; break; } } var consumerLegalApprovalModel = new LegalApprovalModel { ConsumerProviderRegistrationID = consumerProviderRegistrationId, LicenseContent = result, Type = licenseType }; return(consumerLegalApprovalModel); }
public ActionResult ProviderLegalApprovalView(int consumerProviderRegistrationId, string token) { var legalApprovalModel = new LegalApprovalModel(); if (string.IsNullOrEmpty(token)) { legalApprovalModel = _registrationService.GetLegalApprovalModel(consumerProviderRegistrationId, LoggedInUser); } else { legalApprovalModel = _registrationService.GetLegalApprovalModel(token, LoggedInUser); } if (legalApprovalModel.Type == OrganisationLicenseType.FromTemplate) { return(View("ProviderLegalApprovalTemplateView", legalApprovalModel)); } return(View("ProviderLegalApprovalCustomView", legalApprovalModel)); }
public LegalApprovalModel GetLegalApprovalModel(string token, LoggedInUserDetails user) { _security.CheckBasicAccess(user); var tokenInfo = _tokens.ParseConsumerProviderRegistrationToken(token); // Get request var request = _verificationRequests.FirstOrDefault(i => i.Token == tokenInfo.Token); if (request == null) { throw new BaseException("Access denied. Request token does not exist."); } if (request.SentTo != user.ID.Value) { throw new BaseException("Access denied. Invalid user."); } // Check whether token expired if (request.ExpiresAt != tokenInfo.TokenExpire || request.ExpiresAt < DateTime.Now) { throw new BaseException("Approval link is expired."); } if (!IsLegalOfficer(user)) { throw new BaseException("Access denied. Not a legal officer."); } // Check whether organisation is active if (!user.Organization.IsActive) { throw new BaseException("Your organization is inactive. Please check if your organization has approved Legal Officer. For more details contact DataLinker team."); } // Get license var license = _licenseService.FirstOrDefault(p => p.ID == tokenInfo.ID.Value); // Get license type whether it is custom or default. var licenseType = license.CustomLicenseID != null ? OrganisationLicenseType.Custom : OrganisationLicenseType.FromTemplate; var result = string.Empty; // Get organisation details var organization = _organisations.FirstOrDefault(i => i.ID == user.Organization.ID); switch (licenseType) { case OrganisationLicenseType.FromTemplate: { // Get schema file var schemaFile = _schemaFiles.FirstOrDefault(i => i.DataSchemaID == license.DataSchemaID); // Setup url to schema var urlToSchema = _urls.ToDownloadSchema(schemaFile.ID); // Get content for license var licenseDocument = _licenseContent.GetLicenseContent(organizationLicenseId: license.ID); // Setup license content with details _licenseContent.InsertLicenseDetails(licenseDocument, urlToSchema, _config.DataLinkerHost, organization.ID, license.ProviderEndpointID != 0); result = licenseDocument.OuterXml; break; } case OrganisationLicenseType.Custom: { // Get content for license var urlToDownloadLicese = _urls.ToDownloadLicense(license.ApplicationID, license.DataSchemaID, license.ID); result = urlToDownloadLicese; break; } } // Always expire request if (request != null) { request.ExpiresAt = DateTime.UtcNow; _verificationRequests.Update(request); } var legalApprovalModel = new LegalApprovalModel { ConsumerProviderRegistrationID = tokenInfo.ConsumerProviderRegistrationId.Value, LicenseContent = result, Type = licenseType }; return(legalApprovalModel); }