public async Task <ActionResult> AuthorisationRequired(Guid pcsId) { using (IWeeeClient client = apiClient()) { SchemeStatus status = await client.SendAsync(User.GetAccessToken(), new GetSchemeStatus(pcsId)); if (status == SchemeStatus.Approved) { return(RedirectToAction("Index", new { pcsId })); } string userIdString = User.GetUserId(); bool showLinkToSelectOrganisation = false; if (userIdString != null) { Guid userId = new Guid(userIdString); int activeUserCompleteOrganisationCount = await cache.FetchUserActiveCompleteOrganisationCount(userId); showLinkToSelectOrganisation = (activeUserCompleteOrganisationCount > 1); } await SetBreadcrumb(pcsId); return(View(new AuthorizationRequiredViewModel { Status = status, ShowLinkToSelectOrganisation = showLinkToSelectOrganisation })); } }
public UpdateSchemeInformation(Guid schemeId, string schemeName, string approvalNumber, string ibisCustomerReference, ObligationType obligationType, Guid competentAuthorityId, SchemeStatus status) { SchemeId = schemeId; SchemeName = schemeName; ApprovalNumber = approvalNumber; IbisCustomerReference = ibisCustomerReference; ObligationType = obligationType; CompetentAuthorityId = competentAuthorityId; Status = status; }
public CreateScheme(Guid organisationId, string schemeName, string approvalNumber, string ibisCustomerReference, ObligationType obligationType, Guid competentAuthorityId, SchemeStatus status) { OrganisationId = organisationId; SchemeName = schemeName; ApprovalNumber = approvalNumber; IbisCustomerReference = ibisCustomerReference; ObligationType = obligationType; CompetentAuthorityId = competentAuthorityId; Status = status; }
private Dictionary <int, string> GetStatuses(SchemeStatus currentSchemeStatus) { var statuses = EnumHelper.GetValues(typeof(SchemeStatus)); if (currentSchemeStatus == SchemeStatus.Pending) { statuses.Remove((int)SchemeStatus.Withdrawn); } if (currentSchemeStatus == SchemeStatus.Approved) { statuses.Remove((int)SchemeStatus.Pending); statuses.Remove((int)SchemeStatus.Rejected); } return(statuses); }
public SetSchemeStatus(Guid pcsId, SchemeStatus status) { PcsId = pcsId; Status = status; }
public async Task <CreateOrUpdateSchemeInformationResult> HandleAsync(CreateScheme message) { authorization.EnsureCanAccessInternalArea(); Scheme scheme = new Scheme(message.OrganisationId); this.dataAccess.AddScheme(scheme); /* * Check the uniqueness of the approval number if the value is being changed. */ if (await dataAccess.CheckSchemeApprovalNumberInUseAsync(message.ApprovalNumber)) { return(new CreateOrUpdateSchemeInformationResult() { Result = CreateOrUpdateSchemeInformationResult.ResultType.ApprovalNumberUniquenessFailure }); } UKCompetentAuthority environmentAgency = await dataAccess.FetchEnvironmentAgencyAsync(); if (environmentAgency.Id == message.CompetentAuthorityId) { // The 1B1S customer reference is mandatory for schemes in the Environmetn Agency. if (string.IsNullOrEmpty(message.IbisCustomerReference)) { return(new CreateOrUpdateSchemeInformationResult() { Result = CreateOrUpdateSchemeInformationResult.ResultType.IbisCustomerReferenceMandatoryForEAFailure, }); } else { /* * The 1B1S customer refernece must be unique across schemes within the Environment Agency. * * Try and find another non-rejected scheme for the Environment Agency with the same * 1B1S customer reference. In production, this should at most only ever return one result. * * As the check for uniqueness has not always existed, it is possible that other * environments may contain multiple schemes with the same 1B1S customer reference * so we are using FirstOrDefault rather than SingleOrDefault. */ List <Scheme> nonRejectedEnvironmentAgencySchemes = await dataAccess.FetchNonRejectedEnvironmentAgencySchemesAsync(); Scheme otherScheme = nonRejectedEnvironmentAgencySchemes .Where(s => s.Id != scheme.Id) .Where(s => s.IbisCustomerReference == message.IbisCustomerReference) .FirstOrDefault(); if (otherScheme != null) { return(new CreateOrUpdateSchemeInformationResult() { Result = CreateOrUpdateSchemeInformationResult.ResultType.IbisCustomerReferenceUniquenessFailure, IbisCustomerReferenceUniquenessFailure = new CreateOrUpdateSchemeInformationResult.IbisCustomerReferenceUniquenessFailureInfo() { IbisCustomerReference = message.IbisCustomerReference, OtherSchemeApprovalNumber = otherScheme.ApprovalNumber, OtherSchemeName = otherScheme.SchemeName } }); } } } Domain.Obligation.ObligationType obligationType = ValueObjectInitializer.GetObligationType(message.ObligationType); scheme.UpdateScheme( message.SchemeName, message.ApprovalNumber, message.IbisCustomerReference, obligationType, message.CompetentAuthorityId); SchemeStatus status = message.Status.ToDomainEnumeration <SchemeStatus>(); scheme.SetStatus(status); await dataAccess.SaveAsync(); Organisation org = await organisationDataAccess.FetchOrganisationAsync(message.OrganisationId); if (org.OrganisationStatus == OrganisationStatus.Incomplete) { org.CompleteRegistration(); await organisationDataAccess.SaveAsync(); } return(new CreateOrUpdateSchemeInformationResult() { Result = CreateOrUpdateSchemeInformationResult.ResultType.Success }); }
private Dictionary<int, string> GetStatuses(SchemeStatus currentSchemeStatus) { var statuses = EnumHelper.GetValues(typeof(SchemeStatus)); if (currentSchemeStatus == SchemeStatus.Pending) { statuses.Remove((int)SchemeStatus.Withdrawn); } if (currentSchemeStatus == SchemeStatus.Approved) { statuses.Remove((int)SchemeStatus.Pending); statuses.Remove((int)SchemeStatus.Rejected); } return statuses; }