public void Submit(Scrap scrap, SubmittedState submittedState)
 {
     scrap.Submit(submittedState,
         vesselDomainService, inventoryOperationNotifier,
         tankDomainService, currencyDomainService,
         goodDomainService, goodUnitDomainService);
 }
 public ScrapWorkflowLog(
     Scrap scrap,
     WorkflowEntities actionEntity,
     DateTime actionDate,
     WorkflowActions? workflowAction,
     long actorUserId,
     string remark, long currentWorkflowStepId, bool active)
     : base(actionEntity, workflowAction, actorUserId, actionDate, remark, currentWorkflowStepId, active)
 {
     Scrap = scrap;
 }
Beispiel #3
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;
        }
Beispiel #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>();
        }
 //================================================================================
 public void Delete(Scrap scrap)
 {
     scrapRepository.Delete(scrap);
 }
        public List<InventoryOperation> NotifySubmittingScrap(Scrap source)
        {
            //var scrapDto = scrapToScrapDtoMapper.MapToModel(source);

            ////TODO: svc.NotifySubmittingScrapDetail must be renamed to NotifySubmittingScrap
            ////TODO: The argument Type must be changed from ScrapDetailDto to ScrapDto.
            //var inventoryOperationDtosResult = svc.NotifySubmittingScrapDetail(scrapDto).ToList();

            //var result = inventoryOperationDtosResult.Select(mapInventoryOperationDtoToInventoryOperation);

            //return result.ToList();

            return null;
        }
        //================================================================================
        public List<InventoryOperation> ManageScrap(Scrap scrap, int userId)
        {
            using (var dbContext = new InventoryDbContext())
            {
                using (var transaction = new TransactionScope())
                {
                    var reference = findInventoryOperationReference(dbContext, InventoryOperationType.Issue, CHARTER_IN_START_RECEIPT, scrap.Id.ToString());

                    //if (reference.OperationId == INVALID_ID)
                    if (reference == null)
                    {

                    }
                    else
                    {
                        var transactionItems = dbContext.TransactionItems.Where(ti => ti.TransactionId == reference.OperationId);

                    }
                }
            }
            return null;
        }
Beispiel #8
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);
        }
Beispiel #9
0
 //================================================================================
 private void validateTankForVesselWithTanks(Tank tank, Scrap scrap)
 {
     if (scrap.VesselInCompany.Tanks.Count > 0 && tank == null)
         throw new BusinessRuleException("", "Tank must be selected.");
 }
Beispiel #10
0
        //================================================================================
        private void validateScrap(Scrap scrap, IScrapDomainService scrapDomainService)
        {
            if (scrap == null)
                throw new InvalidArgument("Scrap");

            if (scrapDomainService.Get(scrap.Id) == null)
                throw new ObjectNotFound("Scrap", scrap.Id);
        }
 public void ValidateMiddleApprove(Scrap scrap)
 {
     scrap.ValidateMiddleApprove(vesselDomainService, tankDomainService, currencyDomainService,
         goodDomainService, goodUnitDomainService);
 }
 public void RejectSubmittedState(Scrap scrap, SubmitRejectedState submitRejectedState)
 {
     scrap.RejectSubmittedState(submitRejectedState);
 }
 public void Close(Scrap scrap, ClosedState closedState)
 {
     scrap.Close(closedState);
 }
 public void Cancel(Scrap scrap, CancelledState cancelledState)
 {
     scrap.Cancel(cancelledState, inventoryOperationNotifier);
 }
Beispiel #15
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));
            }
        }
Beispiel #16
0
 //================================================================================
 private void validateGoodToBeUniqueInDetails(Good good, Scrap scrap)
 {
     if (scrap.ScrapDetails.Count(sd => sd.Good.Id == good.Id && sd.Id != this.Id) != 0)
         throw new BusinessRuleException("", string.Format("The Good '{0}' has other records in Scrap Details.", good.Name));
 }
        public List<InventoryOperation> NotifySubmittingScrap(Scrap source)
        {
            var scrapDto = scrapToScrapDtoMapper.MapToModel(source);

            ////TODO: svc.NotifySubmittingScrapDetail must be renamed to NotifySubmittingScrap
            ////TODO: The argument Type must be changed from ScrapDetailDto to ScrapDto.
            //var inventoryOperationDtosResult = svc.NotifySubmittingScrapDetail(scrapDto).ToList();

            //var result = inventoryOperationDtosResult.Select(mapInventoryOperationDtoToInventoryOperation);

            //return result.ToList();

            var syncEvent = new AutoResetEvent(false);

            List<InventoryOperation> callResult = null;
            Exception callException = null;

            ClientHelper.Post<List<FuelReportInventoryOperationDto>, ScrapDto>
                //(new Uri("http://localhost:65234/api/fuelevents", UriKind.Absolute),
                //(new Uri("http://evaluation-srv:9090/api/fuelevents", UriKind.Absolute),
                (MessageBrokerApiUri, (result, exp) =>
                {
                    callException = exp;
                    if (result != null)
                        callResult = result.Select(mapInventoryOperationDtoToInventoryOperation).ToList();

                    syncEvent.Set();
                },
                scrapDto, ClientHelper.MessageFormat.Json, new Dictionary<string, string>(), "ScrapDto");

            syncEvent.WaitOne();

            if (callException != null)
                throw callException;

            return callResult;
        }
Beispiel #18
0
        //================================================================================
        private void validateTank(Tank tank, Scrap scrap, ITankDomainService tankDomainService)
        {
            this.validateTankExistance(tank, tankDomainService);

            validateTankForVesselWithTanks(tank, scrap);

            validateTankForVesselWithoutTanks(tank, scrap);

            validateTankToBeInVesselTanks(tank, scrap);
        }
 //================================================================================
 public bool IsScrapDetailDeletePermitted(Scrap scrap)
 {
     return isScrapOpen.IsSatisfiedBy(scrap);
 }
Beispiel #20
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.");
 }
 //================================================================================
 public bool IsScrapDetailEditPermitted(Scrap scrap)
 {
     return isScrapOpen.IsSatisfiedBy(scrap) || isScrapSubmitRejected.IsSatisfiedBy(scrap);
 }
Beispiel #22
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.");
 }
 //================================================================================
 public bool IsScrapEditPermitted(Scrap scrap)
 {
     return isScrapOpen.IsSatisfiedBy(scrap);
 }
 //================================================================================
 public bool IsTankEditable(Scrap scrap)
 {
     return isScrapOpen.IsSatisfiedBy(scrap);
 }
 //================================================================================
 public void SetInventoryResults(InventoryResultCommand resultCommand, Scrap scrap)
 {
 }
 public List<InventoryOperation> NotifySubmittingScrap(Scrap source)
 {
     return new List<InventoryOperation>(new InventoryOperation[]
             {
              new InventoryOperation(
                  312,
              "INV# - " +DateTime.Now.Ticks,
                 DateTime.Now,
                 InventoryActionType.Issue,
                 (long? )null,
                 (long? )null)});
 }
        //================================================================================
        private void setEditProperties(Scrap scrap, ScrapDto scrapDto)
        {
            scrapDto.IsScrapEditPermitted = scrapDomainService.IsScrapEditPermitted(scrap);
            scrapDto.IsScrapDeletePermitted = scrapDomainService.IsScrapDeletePermitted(scrap);

            scrapDto.IsScrapAddDetailPermitted = scrapDomainService.IsScrapDetailAddPermitted(scrap);
            scrapDto.IsScrapEditDetailPermitted = scrapDomainService.IsScrapDetailEditPermitted(scrap);
            scrapDto.IsScrapDeleteDetailPermitted = scrapDomainService.IsScrapDetailDeletePermitted(scrap);

            scrapDto.IsGoodEditable = scrapDomainService.IsGoodEditable(scrap);
            scrapDto.IsTankEditable = scrapDomainService.IsTankEditable(scrap);
        }