internal Offhire( long referenceNumber, DateTime startDateTime, DateTime endDateTime, Company introducer, VesselInCompany vesselInCompany, Voyage voyage, ActivityLocation offhireLocation, DateTime voucherDate, Currency voucherCurrency, //string pricingReferenceNumber, //OffHirePricingType pricingReferenceType, IOffhireDomainService offhireDomainService, IOffhireManagementSystemDomainService offhireManagementSystemDomainService, IVesselInCompanyDomainService vesselDomainService, IVoyageDomainService voyageDomainService, ICompanyDomainService companyDomainService, IActivityLocationDomainService activityLocationDomainService, ICurrencyDomainService currencyDomainService) : this() { //var pricingReference = new OffhirePricingReference() { Type = pricingReferenceType, Number = pricingReferenceNumber }; this.validateCreation( referenceNumber, startDateTime, endDateTime, introducer, vesselInCompany, voyage, offhireLocation, voucherDate, voucherCurrency, //pricingReference, offhireDomainService, offhireManagementSystemDomainService, vesselDomainService, voyageDomainService, companyDomainService, activityLocationDomainService, currencyDomainService); this.ReferenceNumber = referenceNumber; this.StartDateTime = startDateTime; this.EndDateTime = endDateTime; this.IntroducerType = offhireDomainService.GetCharteringPartyType(vesselInCompany); this.Introducer = introducer; this.VesselInCompany = vesselInCompany; this.Voyage = voyage; this.OffhireLocation = offhireLocation; this.VoucherDate = voucherDate; this.VoucherCurrencyId = voucherCurrency.Id; this.VoucherCurrency = voucherCurrency; this.PricingReference = this.createPricingReference(introducer, vesselInCompany, this.IntroducerType, voyage, startDateTime, offhireDomainService); }
public ActivityLocationDto MapToModel(ActivityLocation entity) { var result = new ActivityLocationDto { Id = entity.Id, Abbreviation = entity.Abbreviation, Name = entity.Name, Code = entity.Code, Latitude = entity.Latitude, Longititude = entity.Longitude, CountryName = entity.CountryName }; return result; }
//================================================================================ private Offhire( long referenceNumber, DateTime startDateTime, DateTime endDateTime, CharteringPartyType introducerType, Company introducer, VesselInCompany vesselInCompany, Voyage voyage, ActivityLocation offhireLocation, DateTime voucherDate, Currency voucherCurrency, string pricingReferenceNumber, OffHirePricingType pricingReferenceType, List<OffhireDetail> offhireDetails) { //This is used to create instances by reflection to Insert Seed Data into DB. this.ReferenceNumber = referenceNumber; this.StartDateTime = startDateTime; this.EndDateTime = endDateTime; this.IntroducerType = introducerType; this.Introducer = introducer; this.VesselInCompany = vesselInCompany; this.Voyage = voyage; this.OffhireLocation = offhireLocation; this.VoucherDate = voucherDate; this.VoucherCurrencyId = voucherCurrency.Id; this.VoucherCurrency = voucherCurrency; this.PricingReference = new OffhirePricingReference() { Type = pricingReferenceType, Number = pricingReferenceNumber }; this.OffhireDetails = offhireDetails; this.ApproveWorkflows = new List<OffhireWorkflowLog>(); }
//================================================================================ private void validateCreation( long referenceNumber, DateTime startDateTime, DateTime endDateTime, Company introducer, VesselInCompany vesselInCompany, Voyage voyage, ActivityLocation offhireLocation, DateTime voucherDate, Currency voucherCurrency, //OffhirePricingReference pricingReference, IOffhireDomainService offhireDomainService, IOffhireManagementSystemDomainService offhireManagementSystemDomainService, IVesselInCompanyDomainService vesselDomainService, IVoyageDomainService voyageDomainService, ICompanyDomainService companyDomainService, IActivityLocationDomainService activityLocationDomainService, ICurrencyDomainService currencyDomainService) { this.validateCompanyExistance(introducer, companyDomainService); this.validateOffhireReference(referenceNumber, introducer, offhireManagementSystemDomainService); this.validateOffhireUniquenessInFuelManagementDomain(referenceNumber, introducer, offhireDomainService); this.validateCurrency(voucherCurrency, currencyDomainService); this.validateVoucherDate(voucherDate); this.validateVesselExistance(vesselInCompany, vesselDomainService); this.validateVesselInCompanyExistance(vesselInCompany, introducer, companyDomainService); this.validateVoyageExistance(voyage, voyageDomainService); this.validateVoyageInVesselOfCompanyExistance(voyage, vesselInCompany); this.validateOffhireDurationInVoyage(startDateTime, endDateTime, voyage); this.validateActivityLocation(offhireLocation, activityLocationDomainService); CharteringPartyType charteringPartyType = offhireDomainService.GetCharteringPartyType(vesselInCompany); var offhirePricingType = offhireDomainService.GetPricingType(introducer, vesselInCompany, startDateTime); this.validateOffhirePricingType(introducer, vesselInCompany, voyage, startDateTime, charteringPartyType, offhirePricingType, offhireDomainService); }
//================================================================================ private void validateActivityLocation(ActivityLocation offhireLocation, IActivityLocationDomainService activityLocationDomainService) { if (offhireLocation == null) throw new BusinessRuleException("", "Offhire Location is empty."); if (activityLocationDomainService.Get(offhireLocation.Id) == null) throw new ObjectNotFound("OffhireLocation"); }