Example #1
0
        internal OffhireDetail(decimal quantity, decimal feeInVoucherCurrency, decimal feeInMainCurrency, Good good, GoodUnit unit, Tank tank, Offhire offhire,
            IOffhireDomainService offhireDomainService, ITankDomainService tankDomainService, ICurrencyDomainService currencyDomainService,
            IGoodDomainService goodDomainService, IGoodUnitDomainService goodUnitDomainService)
            : this()
        {
            this.validateOffhire(offhire, offhireDomainService);

            this.validateValues(quantity, feeInVoucherCurrency, feeInMainCurrency, good, unit, tank, offhire, offhireDomainService,
                tankDomainService, currencyDomainService, goodDomainService, goodUnitDomainService);

            this.Quantity = quantity;
            this.FeeInVoucherCurrency = feeInVoucherCurrency;
            this.FeeInMainCurrency = feeInMainCurrency;
            this.Good = good;
            this.Unit = unit;
            this.Tank = tank;
            this.Offhire = offhire;
        }
Example #2
0
        internal ScrapDetail(double rob, double price, Currency currency, Good good, GoodUnit unit, Tank tank, Scrap scrap,
            IScrapDomainService scrapDomainService, ITankDomainService tankDomainService, ICurrencyDomainService currencyDomainService,
            IGoodDomainService goodDomainService, IGoodUnitDomainService goodUnitDomainService)
            : this()
        {
            this.validateScrap(scrap, scrapDomainService);

            this.validateValues(rob, price, currency, good, unit, tank, scrap,
                tankDomainService, currencyDomainService, goodDomainService, goodUnitDomainService);

            this.ROB = rob;
            this.Price = price;
            this.Currency = currency;
            this.Good = good;
            this.Unit = unit;
            this.Tank = tank;
            this.Scrap = scrap;
        }
Example #3
0
 //================================================================================
 private OffhireDetail(
     decimal quantity,
     decimal feeInVoucherCurrency,
     decimal feeInMainCurrency,
     Good good,
     GoodUnit unit,
     Tank tank,
     Offhire offhire)
     : this()
 {
     //This constructor added to be used for insert into DB.
     this.Quantity = quantity;
     this.FeeInVoucherCurrency = feeInVoucherCurrency;
     this.FeeInMainCurrency = feeInMainCurrency;
     this.Good = good;
     this.Unit = unit;
     this.Tank = tank;
     this.Offhire = offhire;
 }
Example #4
0
        //================================================================================
        private ScrapDetail(
            double rob,
            double price,
            Currency currency,
            Good good,
            GoodUnit unit,
            Tank tank,
            Scrap scrap)
        {
            //This constructor added to be used for insert into DB.
            this.ROB = rob;
            this.Price = price;
            this.Currency = currency;
            this.Good = good;
            this.Unit = unit;
            this.Tank = tank;
            this.Scrap = scrap;

            this.isScrapSubmitRejected = new IsScrapSubmitRejected();

            //this.InventoryOperations = new List<InventoryOperation>();
        }
Example #5
0
        //================================================================================
        private void validateValues(double rob, double price, Currency currency, Good good, GoodUnit unit, Tank tank, Scrap scrap, ITankDomainService tankDomainService, ICurrencyDomainService currencyDomainService, IGoodDomainService goodDomainService, IGoodUnitDomainService goodUnitDomainService)
        {
            this.validateTank(tank, scrap, tankDomainService);

            this.validateGood(good, goodDomainService);
            this.validateGoodInTank(tank, good, scrap);
            this.validateGoodToBeUniqueInDetails(good, scrap);

            this.validateROB(rob);
            this.validatePrice(price);
            this.validateCurrency(currency, currencyDomainService);

            this.validateUnit(unit, goodUnitDomainService);
            this.validateGoodUnitInCompany(scrap.VesselInCompany.Company, good, unit);
        }
Example #6
0
 //================================================================================
 private void validateTankToBeInVesselTanks(Tank tank, Scrap scrap)
 {
     if (scrap.VesselInCompany.Tanks.Count > 0 && tank != null && scrap.VesselInCompany.Tanks.Count(t => t.Id == tank.Id) == 0)
         throw new BusinessRuleException("", "Selected Tank is not defined for Vessel.");
 }
Example #7
0
 //================================================================================
 private void validateTankForVesselWithTanks(Tank tank, Scrap scrap)
 {
     if (scrap.VesselInCompany.Tanks.Count > 0 && tank == null)
         throw new BusinessRuleException("", "Tank must be selected.");
 }
Example #8
0
 //================================================================================
 private void validateTankForVesselWithoutTanks(Tank tank, Scrap scrap)
 {
     if (scrap.VesselInCompany.Tanks.Count == 0 && tank != null)
         throw new BusinessRuleException("", "Tank should not be selected for Vessel.");
 }
Example #9
0
 //================================================================================
 private void validateTankExistance(Tank tank, ITankDomainService tankDomainService)
 {
     if (tank != null && tankDomainService.Get(tank.Id) == null)
         throw new ObjectNotFound("Tank", tank.Id);
 }
Example #10
0
        //================================================================================
        private void validateTank(Tank tank, Scrap scrap, ITankDomainService tankDomainService)
        {
            this.validateTankExistance(tank, tankDomainService);

            validateTankForVesselWithTanks(tank, scrap);

            validateTankForVesselWithoutTanks(tank, scrap);

            validateTankToBeInVesselTanks(tank, scrap);
        }
Example #11
0
        //================================================================================
        private void validateGoodInTank(Tank tank, Good good, Scrap scrap)
        {
            if (good == null)
                throw new InvalidArgument("Good");

            if (tank != null)
            {
                var registeredTanksForGoodCount = scrap.ScrapDetails.Count(sd => sd.Id != this.Id && sd.Tank != null && sd.Tank.Id == tank.Id && sd.Good.Id == good.Id);

                if (registeredTanksForGoodCount > 0)
                    throw new BusinessRuleException("", string.Format("The same Good '{0}' in Tank is already defined.", good.Name));
            }
        }
Example #12
0
        //================================================================================
        internal void Update(double rob, double price, Currency currency, Good good, GoodUnit unit, Tank tank,
            ITankDomainService tankDomainService, ICurrencyDomainService currencyDomainService,
            IGoodDomainService goodDomainService, IGoodUnitDomainService goodUnitDomainService)
        {
            this.validateValues(rob, price, currency, good, unit, tank, this.Scrap,
                 tankDomainService, currencyDomainService, goodDomainService, goodUnitDomainService);

            this.ROB = rob;
            this.Price = price;
            this.Currency = currency;
            this.Unit = unit;

            if (!this.isScrapSubmitRejected.IsSatisfiedBy(this.Scrap))
            {
                this.Good = good;
                this.Tank = tank;
            }
        }
Example #13
0
        //================================================================================
        public ScrapDetail UpdateDetail(long scrapDetailId, double rob, double price, Currency currency, Good good, GoodUnit unit, Tank tank,
            ITankDomainService tankDomainService, ICurrencyDomainService currencyDomainService,
            IGoodDomainService goodDomainService, IGoodUnitDomainService goodUnitDomainService)
        {
            var scrapDetailToUpdate = this.findDetail(scrapDetailId);

            scrapDetailToUpdate.Update(rob, price, currency, good, unit, tank,
                 tankDomainService, currencyDomainService, goodDomainService, goodUnitDomainService);

            return scrapDetailToUpdate;
        }
Example #14
0
        //================================================================================
        private void validateValues(decimal quantity, decimal feeInVoucherCurrency, decimal feeInMainCurrency, Good good, GoodUnit unit, Tank tank, Offhire offhire,
            IOffhireDomainService offhireDomainService, ITankDomainService tankDomainService, ICurrencyDomainService currencyDomainService,
            IGoodDomainService goodDomainService, IGoodUnitDomainService goodUnitDomainService)
        {
            this.validateTank(tank, offhire, tankDomainService);

            this.validateGood(good, goodDomainService);
            this.validateGoodInTank(tank, good, offhire);
            this.validateGoodToBeUniqueInDetails(good, offhire);

            this.validateQuantity(quantity);

            this.validateFeeInMainCurrency(feeInMainCurrency);

            this.validateUnit(unit, goodUnitDomainService);
            this.validateGoodUnitInCompany(offhire.Introducer, good, unit);

            this.validateFeeInVoucherCurrency(feeInVoucherCurrency, offhire, good, offhireDomainService, currencyDomainService);
        }
Example #15
0
        //================================================================================
        private void validateTank(Tank tank, Offhire offhire, ITankDomainService tankDomainService)
        {
            this.validateTankExistance(tank, tankDomainService);

            //validateTankForVesselWithTanks(tank, offhire);

            //validateTankForVesselWithoutTanks(tank, offhire);

            //validateTankToBeInVesselTanks(tank, offhire);
        }
Example #16
0
        //================================================================================
        private void validateGoodInTank(Tank tank, Good good, Offhire offhire)
        {
            if (good == null)
                throw new InvalidArgument("Good");

            if (tank != null)
            {
                var registeredTanksForGoodCount = offhire.OffhireDetails.Count(od =>
                    (od.Id != this.Id || (od.Id == NOT_REGISTERED_ID && this.Id == NOT_REGISTERED_ID)) &&
                    od.Tank != null && od.Tank.Id == tank.Id && od.Good.Id == good.Id);

                if (registeredTanksForGoodCount > 0)
                    throw new BusinessRuleException("", string.Format("The same Good '{0}' in Tank is already defined.", good.Name));
            }
        }