コード例 #1
0
ファイル: OffhireDetail.cs プロジェクト: hatefi-arman/Modules
        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;
        }
コード例 #2
0
ファイル: ScrapDetail.cs プロジェクト: hatefi-arman/Modules
        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;
        }
コード例 #3
0
ファイル: OffhireDetail.cs プロジェクト: hatefi-arman/Modules
 //================================================================================
 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;
 }
コード例 #4
0
ファイル: ScrapDetail.cs プロジェクト: hatefi-arman/Modules
        //================================================================================
        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>();
        }
コード例 #5
0
ファイル: ScrapDetail.cs プロジェクト: hatefi-arman/Modules
        //================================================================================
        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);
        }
コード例 #6
0
ファイル: ScrapDetail.cs プロジェクト: hatefi-arman/Modules
 //================================================================================
 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.");
 }
コード例 #7
0
ファイル: ScrapDetail.cs プロジェクト: hatefi-arman/Modules
 //================================================================================
 private void validateTankForVesselWithTanks(Tank tank, Scrap scrap)
 {
     if (scrap.VesselInCompany.Tanks.Count > 0 && tank == null)
         throw new BusinessRuleException("", "Tank must be selected.");
 }
コード例 #8
0
ファイル: ScrapDetail.cs プロジェクト: hatefi-arman/Modules
 //================================================================================
 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.");
 }
コード例 #9
0
ファイル: ScrapDetail.cs プロジェクト: hatefi-arman/Modules
 //================================================================================
 private void validateTankExistance(Tank tank, ITankDomainService tankDomainService)
 {
     if (tank != null && tankDomainService.Get(tank.Id) == null)
         throw new ObjectNotFound("Tank", tank.Id);
 }
コード例 #10
0
ファイル: ScrapDetail.cs プロジェクト: hatefi-arman/Modules
        //================================================================================
        private void validateTank(Tank tank, Scrap scrap, ITankDomainService tankDomainService)
        {
            this.validateTankExistance(tank, tankDomainService);

            validateTankForVesselWithTanks(tank, scrap);

            validateTankForVesselWithoutTanks(tank, scrap);

            validateTankToBeInVesselTanks(tank, scrap);
        }
コード例 #11
0
ファイル: ScrapDetail.cs プロジェクト: hatefi-arman/Modules
        //================================================================================
        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));
            }
        }
コード例 #12
0
ファイル: ScrapDetail.cs プロジェクト: hatefi-arman/Modules
        //================================================================================
        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;
            }
        }
コード例 #13
0
ファイル: Scrap.cs プロジェクト: hatefi-arman/Modules
        //================================================================================
        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;
        }
コード例 #14
0
ファイル: OffhireDetail.cs プロジェクト: hatefi-arman/Modules
        //================================================================================
        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);
        }
コード例 #15
0
ファイル: OffhireDetail.cs プロジェクト: hatefi-arman/Modules
        //================================================================================
        private void validateTank(Tank tank, Offhire offhire, ITankDomainService tankDomainService)
        {
            this.validateTankExistance(tank, tankDomainService);

            //validateTankForVesselWithTanks(tank, offhire);

            //validateTankForVesselWithoutTanks(tank, offhire);

            //validateTankToBeInVesselTanks(tank, offhire);
        }
コード例 #16
0
ファイル: OffhireDetail.cs プロジェクト: hatefi-arman/Modules
        //================================================================================
        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));
            }
        }