Exemple #1
0
        public EditAgreementGrantAllocationsViewModel(Models.Agreement agreement)
        {
            AgreementId = agreement.AgreementID;
            // Generate GrantAllocationJsons that are ordered descending by first part of GrantNumber
            var grantAllocations = agreement.AgreementGrantAllocations.Select(x => x.GrantAllocation).ToList();

            GrantAllocationJsons = GrantAllocationJson.MakeGrantAllocationJsonsFromGrantAllocations(grantAllocations);
        }
        public static HtmlString GetListOfGrantHrefs(this Models.Agreement agreement)
        {
            var distinctListOfGrants = agreement.AgreementGrantAllocations.Where(x => x != null).Select(x => x.GrantAllocation.GrantModification.Grant).DistinctBy(x => x.GrantNumber).OrderBy(x => x.GrantNumber, StringComparer.InvariantCultureIgnoreCase);

            var distinctListOfGrantHrefs = distinctListOfGrants.Select(x =>
                                                                       UrlTemplate.MakeHrefString(GrantDetailUrlTemplate.ParameterReplace(x.GrantID), x.GrantNumber));

            return(new HtmlString(string.Join(", ", distinctListOfGrantHrefs.Select(x => x.ToHtmlString()))));
        }
Exemple #3
0
        public void UpdateModel(Models.Agreement agreement)
        {
            // Clear out existing Agreement Grant Allocations
            agreement.AgreementGrantAllocations.ToList().ForEach(aga => aga.DeleteFull(HttpRequestStorage.DatabaseEntities));

            // Create all-new Agreement Grant Allocations
            var        allPossibleGrantAllocations   = HttpRequestStorage.DatabaseEntities.GrantAllocations.ToList();
            List <int> allSelectedGrantAllocationIds = GrantAllocationJsons.Select(gaj => gaj.GrantAllocationID).ToList();
            var        allSelectedGrantAllocations   = allPossibleGrantAllocations.Where(ga => allSelectedGrantAllocationIds.Contains(ga.GrantAllocationID)).ToList();

            agreement.AgreementGrantAllocations = allSelectedGrantAllocations.Select(ga => new AgreementGrantAllocation(agreement, ga)).ToList();
        }
 public EditAgreementViewModel(Models.Agreement agreement)
 {
     AgreementID        = agreement.AgreementID;
     AgreementTitle     = agreement.AgreementTitle;
     AgreementNumber    = agreement.AgreementNumber;
     OrganizationID     = agreement.OrganizationID;
     AgreemeentStatusID = agreement.AgreementStatusID;
     AgreementTypeID    = agreement.AgreementTypeID;
     AgreementAmount    = agreement.AgreementAmount;
     AgreementStartDate = agreement.StartDate;
     AgreementEndDate   = agreement.EndDate;
     AgreementNotes     = agreement.Notes;
 }
Exemple #5
0
        public DetailViewData(Person currentPerson, Models.Agreement agreement, bool userHasEditAgreementPermissions)
            : base(currentPerson, null)
        {
            Agreement            = agreement;
            HtmlPageTitle        = agreement.AgreementTitle;
            EntityName           = $"{Models.FieldDefinition.Agreement.GetFieldDefinitionLabel()}";
            EditAgreementUrl     = agreement.GetEditUrl();
            BackToAgreementsText = "Back to all Agreements";
            AgreementsListUrl    = SitkaRoute <AgreementController> .BuildUrlFromExpression(c => c.Index());

            PageTitle       = agreement.AgreementTitle.ToEllipsifiedStringClean(110);
            BreadCrumbTitle = $"{Models.FieldDefinition.Agreement.GetFieldDefinitionLabel()} Detail";
            UserHasEditAgreementPermissions = userHasEditAgreementPermissions;
            // Used for creating file download link, if file available
            ShowDownload = agreement.AgreementFileResource != null;

            ProgramIndices = agreement.ProgramIndices;
            ProjectCodes   = agreement.ProjectCodes;

            AgreementPersonGridSpec = new AgreementPersonGridSpec(currentPerson)
            {
                ObjectNameSingular = "Agreement Contact", ObjectNamePlural = "Agreement Contacts", SaveFiltersInCookie = true
            };

            if (UserHasEditAgreementPermissions)
            {
                var contentUrl = SitkaRoute <AgreementController> .BuildUrlFromExpression(t => t.NewAgreementPerson(agreement.AgreementID));

                AgreementPersonGridSpec.CreateEntityModalDialogForm = new ModalDialogForm(contentUrl, "Create a new Agreement Contact");
                EditAgreementGrantAllocationRelationshipsUrl        = SitkaRoute <AgreementController> .BuildUrlFromExpression(t => t.EditAgreementGrantAllocationRelationships(agreement.AgreementID));
            }

            AgreementPersonGridName    = "agreementPersonGrid";
            AgreementPersonGridDataUrl = SitkaRoute <AgreementController> .BuildUrlFromExpression(ac => ac.AgreementPersonGridJsonData(agreement.AgreementID));

            List <AgreementGrantAllocation> agreementGrantAllocationsList = agreement.AgreementGrantAllocations.ToList();

            CurrentAgreementGrantAllocationsInSortedOrder = AgreementGrantAllocation.OrderAgreementGrantAllocationsByYearPrefixedGrantNumbersThenEverythingElse(agreementGrantAllocationsList);
            AgreementProjectsByGrantAllocations           = ProjectAgreementByGrantAllocation.MakeAgreementProjectsByGrantAllocation(agreementGrantAllocationsList);
        }
 public void UpdateModel(Models.Agreement agreement, Person currentPerson)
 {
     agreement.AgreementTitle    = AgreementTitle;
     agreement.AgreementNumber   = AgreementNumber;
     agreement.OrganizationID    = OrganizationID.Value;
     agreement.AgreementStatusID = AgreemeentStatusID.Value;
     agreement.AgreementTypeID   = AgreementTypeID;
     agreement.AgreementAmount   = AgreementAmount;
     agreement.StartDate         = AgreementStartDate;
     agreement.EndDate           = AgreementEndDate;
     agreement.Notes             = AgreementNotes;
     if (AgreementFileResourceData != null)
     {
         var currentAgreementFileResource = agreement.AgreementFileResource;
         agreement.AgreementFileResource = null;
         // Delete old Agreement file, if present
         if (currentAgreementFileResource != null)
         {
             HttpRequestStorage.DatabaseEntities.SaveChanges();
             HttpRequestStorage.DatabaseEntities.FileResources.DeleteFileResource(currentAgreementFileResource);
         }
         agreement.AgreementFileResource = FileResource.CreateNewFromHttpPostedFileAndSave(AgreementFileResourceData, currentPerson);
     }
 }
Exemple #7
0
        /// <summary>
        /// Preparing objects of type <see cref="ServiceWSDL.Person" /> and invokes method <c>DoImport()</c> from <see cref="ServiceWSDL" /> for each of them.
        /// </summary>
        /// <param name="repository">Received database data.</param>
        public void DoImport(IFullInfoRepository repository)
        {
            ImportServiceClient client = new ImportServiceClient();

            foreach (var p in repository.PersonRepository.PersonList)
            {
                Models.Address        currentAddress        = repository.AddressRepository.AddressList.First(a => a.Id == p.AddressId);
                Models.Agreement      currentAgreement      = repository.AgreementRepository.AgreementList.First(a => a.PersonId == p.Id);
                Models.FinancialState currentFinancialState = repository.FinancialStateRepository.FinancialStateList.First(a => a.Id == currentAgreement.FinancialStateId);

                client.DoImport(new Person()
                {
                    Name      = p.FirstName,
                    Surname   = p.Surname,
                    Addresses = new Address[]
                    {
                        new Address()
                        {
                            AddressType = "Main",
                            City        = currentAddress.PostOfficeCity,
                            Street      = currentAddress.StreetName,
                            HouseNo     = currentAddress.StreetNumber,
                            LocaleNo    = currentAddress.FlatNumber,
                            PostalCode  = currentAddress.PostCode
                        },
                        new Address()
                        {
                            AddressType = "Correspondence",
                            City        = currentAddress.CorrespondencePostOfficeCity,
                            Street      = currentAddress.CorrespondenceStreetName,
                            HouseNo     = currentAddress.CorrespondenceStreetNumber,
                            LocaleNo    = currentAddress.CorrespondenceFlatNumber,
                            PostalCode  = currentAddress.CorrespondencePostCode
                        }
                    },
                    FinancialState = new FinancialState()
                    {
                        Capital                       = currentFinancialState.OutstandingLiabilities,
                        Interest                      = currentFinancialState.Interests,
                        PenaltyInterest               = currentFinancialState.PenaltyInterests,
                        Fees                          = currentFinancialState.Fees == null ? 0 : (decimal)currentFinancialState.Fees,
                        CourtFees                     = currentFinancialState.CourtFees,
                        CourtRepresentationFees       = currentFinancialState.RepresentationCourtFees == null ? 0 : (decimal)currentFinancialState.RepresentationCourtFees,
                        EnforcementFees               = currentFinancialState.VindicationCosts == null ? 0 : (decimal)currentFinancialState.VindicationCosts,
                        EnforcementRepresentationFees = currentFinancialState.RepresentationVindicationCosts == null ? 0 : (decimal)currentFinancialState.RepresentationVindicationCosts
                    },
                    NationalIdentificationNumber = p.NationalIdentificationNumber,
                    Phones = new Phone[]
                    {
                        //There is no properties to write in, for ServiceWSDL.Phone
                        new Phone()
                        {
                            //Phone 1
                        },
                        new Phone()
                        {
                            //Phone 2
                        }
                    },
                    IdentityDocuments = new IdentityDocument[]
                    {
                        new IdentityDocument()
                        {
                            Type           = "PESEL",
                            ExpirationDate = new DateTime(),
                            Number         = p.NationalIdentificationNumber
                        }
                    }
                });
            }
        }