/// <summary> /// Create a new instance of a Contact, using string values /// </summary> /// <returns></returns> public static Entity.PimsContactMgrVw CreateContact(string id, bool isDisabled = false, string municipality = null, string firstName = null, string surname = null, string organizationName = null) { var address = new PimsAddress() { MunicipalityName = municipality }; var organization = organizationName != null ? new PimsOrganization() { OrganizationName = organizationName, PimsOrganizationAddresses = new List <PimsOrganizationAddress>() { new PimsOrganizationAddress() { Address = address } } } : null; var person = firstName != null ? new PimsPerson() { FirstName = firstName, Surname = surname, PimsPersonAddresses = new List <PimsPersonAddress>() { new PimsPersonAddress() { Address = address } } } : null; return(CreateContact(id, isDisabled, address, organization, person)); }
public void Address_ToString(PimsAddress address, string expectedResult) { // Arrange // Act // Assert address.ToString().Should().Be(expectedResult); }
public void FormatAddress(PimsAddress address, string expectedResult) { // Arrange // Act var result = address.FormatAddress(); // Assert result.Should().Be(expectedResult); }
public void Address_Constructor_02() { // Arrange var province = EntityHelper.CreateProvince(1, "ON"); var district = EntityHelper.CreateDistrict(1, "district"); // Act var address = new PimsAddress("address1", "address2", "municipality", province, district, "postal"); // Assert address.StreetAddress1.Should().Be("address1"); address.StreetAddress2.Should().Be("address2"); address.MunicipalityName.Should().Be("municipality"); address.ProvinceState.Should().Be(province); address.ProvinceStateId.Should().Be(province.Id); address.DistrictCodeNavigation.Should().Be(district); address.DistrictCode.Should().Be(district.DistrictCode); address.PostalCode.Should().Be("postal"); }
/// <summary> /// Create a new instance of a Lease. /// </summary> /// <returns></returns> public static Entity.PimsLease CreateLease(this PimsContext context, int pid, string lFileNo = null, string tenantFirstName = null, string tenantLastName = null, string motiFirstName = null, string motiLastName = null, PimsAddress address = null, bool addTenant = false, bool addProperty = true) { var programType = context.PimsLeaseProgramTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find lease program type."); var leasePurposeType = context.PimsLeasePurposeTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find lease purpose type."); var leaseStatusType = context.PimsLeaseStatusTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find lease status type."); var leasePayRvblType = context.PimsLeasePayRvblTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find lease rvbl type."); var leaseCategoryType = context.PimsLeaseCategoryTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find lease category type."); var leaseInitiatorType = context.PimsLeaseInitiatorTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find lease initiator type."); var leaseResponsibilityType = context.PimsLeaseResponsibilityTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find lease reponsibility type."); var leaseLicenseType = context.PimsLeaseLicenseTypes.FirstOrDefault() ?? throw new InvalidOperationException("Unable to find lease license type."); var lease = EntityHelper.CreateLease(pid, lFileNo, tenantFirstName, tenantLastName, motiFirstName, motiLastName, address, addTenant, addProperty, programType, leasePurposeType, leaseStatusType, leasePayRvblType, leaseCategoryType, leaseInitiatorType, leaseResponsibilityType, leaseLicenseType); context.PimsLeases.Add(lease); return(lease); }
/// <summary> /// Create a new instance of a Lease. /// </summary> /// <returns></returns> public static Entity.PimsLease CreateLease(int pid, string lFileNo = null, string tenantFirstName = null, string tenantLastName = null, string motiFirstName = null, string motiLastName = null, PimsAddress address = null, bool addTenant = false, bool addProperty = true, PimsLeaseProgramType pimsLeaseProgramType = null, PimsLeasePurposeType pimsLeasePurposeType = null, PimsLeaseStatusType pimsLeaseStatusType = null, PimsLeasePayRvblType pimsLeasePayRvblType = null, PimsLeaseCategoryType pimsLeaseCategoryType = null, PimsLeaseInitiatorType pimsLeaseInitiatorType = null, PimsLeaseResponsibilityType pimsLeaseResponsibilityType = null, PimsLeaseLicenseType pimsLeaseLicenseType = null, PimsRegion region = null) { var lease = new Entity.PimsLease() { LeaseId = pid, LFileNo = lFileNo, ConcurrencyControlNumber = 1, }; var person = new Entity.PimsPerson() { FirstName = tenantFirstName, Surname = tenantLastName }; person.PimsPersonAddresses.Add(new PimsPersonAddress() { Person = person, Address = address }); var organization = new Entity.PimsOrganization(); organization.PimsOrganizationAddresses.Add(new PimsOrganizationAddress() { Organization = organization, Address = address }); if (addProperty) { lease.PimsPropertyLeases.Add(new PimsPropertyLease() { Property = new Entity.PimsProperty() { Pid = pid }, Lease = lease }); } lease.MotiContact = $"{motiFirstName} {motiLastName}"; lease.LeaseProgramTypeCodeNavigation = pimsLeaseProgramType ?? new Entity.PimsLeaseProgramType() { Id = "testProgramType" }; lease.LeasePurposeTypeCodeNavigation = pimsLeasePurposeType ?? new Entity.PimsLeasePurposeType() { Id = "testPurposeType" }; lease.LeaseStatusTypeCodeNavigation = pimsLeaseStatusType ?? new Entity.PimsLeaseStatusType() { Id = "testStatusType" }; lease.LeasePayRvblTypeCodeNavigation = pimsLeasePayRvblType ?? new Entity.PimsLeasePayRvblType() { Id = "testRvblType" }; lease.LeaseCategoryTypeCodeNavigation = pimsLeaseCategoryType ?? new Entity.PimsLeaseCategoryType() { Id = "testCategoryType" }; lease.LeaseInitiatorTypeCodeNavigation = pimsLeaseInitiatorType ?? new Entity.PimsLeaseInitiatorType() { Id = "testInitiatorType" }; lease.LeaseResponsibilityTypeCodeNavigation = pimsLeaseResponsibilityType ?? new Entity.PimsLeaseResponsibilityType() { Id = "testResponsibilityType" }; lease.LeaseLicenseTypeCodeNavigation = pimsLeaseLicenseType ?? new Entity.PimsLeaseLicenseType() { Id = "testType" }; if (region != null) { lease.RegionCodeNavigation = region; } if (addTenant) { lease.PimsLeaseTenants.Add(new PimsLeaseTenant(lease, person, organization, new PimsLessorType("tst"))); } return(lease); }
/// <summary> /// Format address to string. /// </summary> /// <param name="address"></param> /// <returns></returns> public static string FormatAddress(this PimsAddress address) { return(address != null ? $"{address.StreetAddress1} {address.StreetAddress2} {address.StreetAddress3}".Trim() : ""); }
/// <summary> /// Create a new instance of a Contact, using entities /// </summary> /// <returns></returns> public static Entity.PimsContactMgrVw CreateContact(string id, bool isDisabled = false, PimsAddress address = null, PimsOrganization organization = null, PimsPerson person = null) { var contact = new Entity.PimsContactMgrVw() { Id = id, Address = address, FirstName = person?.FirstName ?? "firstName", Surname = person?.Surname ?? "surName", Summary = organization?.OrganizationName ?? person?.GetFullName(), IsDisabled = isDisabled, Organization = organization, Person = person, OrganizationName = organization?.OrganizationName ?? "organization name", MunicipalityName = address.MunicipalityName, }; return(contact); }