//================================================================================
        public OffhireDto Add(OffhireDto dto)
        {
            var command = convertDtoToCommand(dto);

            var updatedEntity = offhireApplicationService.AddOffhire(command);

            var result = offhireDtoMapper.MapToModel(updatedEntity, this.setEditProperties);

            setModelPricingValues(result);

            return result;
        }
        public OffhireDto MapToModel(OffhirePreparedData entity)
        {
            var result = new OffhireDto()
                         {
                             Id = -1,
                             ReferenceNumber = entity.ReferenceNumber,
                             StartDateTime = entity.StartDateTime,
                             EndDateTime = entity.EndDateTime,
                             Introducer = companyDtoMapper.MapToModel(entity.Introducer),
                             Vessel = vesselDtoMapper.MapToModel(entity.VesselInCompany),
                             Voyage = entity.Voyage == null ? null : voyageDtoMapper.MapToModel(entity.Voyage),
                             OffhireLocation = activityLocationDtoMapper.MapToModel(entity.Location),
                             OffhireDetails = new ObservableCollection<OffhireDetailDto>(this.offhirePreparedDetailDtoMapper.MapToModel(entity.OffhireDetails)),
                             IsOffhireEditPermitted = true,
                             IsOffhireDeletePermitted = false
                         };

            return result;
        }
        //================================================================================
        private void setModelPricingValues(OffhireDto result)
        {
            result.PricingValuesInMainCurrency = GetOffhirePricingValuesInMainCurrency(result.Introducer.Id, result.Vessel.Id, result.StartDateTime);

            result.OffhireDetails.ToList().ForEach(
                                    od =>
                                    {
                                        var relevantGoodPricing = result.PricingValuesInMainCurrency.FirstOrDefault(pv => pv.Good.Id == od.Good.Id);

                                        if (relevantGoodPricing != null)
                                        {
                                            var feeInMainCurrency = relevantGoodPricing.Fee;

                                            if (feeInMainCurrency.HasValue)
                                                od.FeeInMainCurrency = feeInMainCurrency;

                                            od.IsFeeInVoucherCurrencyReadOnly = feeInMainCurrency.HasValue;
                                        }
                                    });
        }
 //================================================================================
 private void setEditProperties(Offhire offhire, OffhireDto offhireDto)
 {
     offhireDto.IsOffhireEditPermitted = offhireDomainService.IsOffhireEditPermitted(offhire);
     offhireDto.IsOffhireDeletePermitted = offhireDomainService.IsOffhireDeletePermitted(offhire);
 }
        private OffhireCommand convertDtoToCommand(OffhireDto dto)
        {
            var command = new OffhireCommand()
            {
                Id = dto.Id,
                ReferenceNumber = dto.ReferenceNumber,
                OffhireLocationId = dto.OffhireLocation.Id,
                StartDateTime = dto.StartDateTime,
                EndDateTime = dto.EndDateTime,
                IntroducerId = dto.Introducer.Id,
                VesselInCompanyId = dto.Vessel.Id,
                VoyageId = dto.Voyage != null ? (long?)dto.Voyage.Id : null,
                VoucherCurrencyId = dto.VoucherCurrency == null ? -1 : dto.VoucherCurrency.Id,
                VoucherDate = dto.VoucherDate == null ? DateTime.MinValue : dto.VoucherDate.Value,
                OffhireDetails = dto.OffhireDetails.Select(od => new OffhireCommandDetail()
                {
                    Id = od.Id,
                    GoodId = od.Good.Id,
                    Quantity = od.Quantity,
                    UnitId = od.Unit.Id,
                    TankId = od.Tank != null ? (long?)od.Tank.Id : null,
                    FeeInMainCurrency = od.FeeInMainCurrency,
                    FeeInVoucherCurrency = od.FeeInVoucherCurrency
                }).ToList()
            };

            return command;
        }
        //================================================================================
        public void AddOffhire(Action<OffhireDto, Exception> action, OffhireDto dto)
        {
            var url = string.Format(this.offhireAddressFormatString, string.Empty);

            WebClientHelper.Post(ApiServiceAddressHelper.BuildUri(url), action, dto, WebClientHelper.MessageFormat.Json,ApiConfig.Headers);
        }
 public OffhireDto RemapModel(OffhireDto model)
 {
     throw new System.NotImplementedException();
 }
 public OffhirePreparedData MapToEntity(OffhireDto model)
 {
     throw new System.NotImplementedException();
 }
 public void EditOffhireDetail(OffhireDto offhireDto, OffhireDetailDto offhireDetailDto)
 {
     var view = this.ViewManager.ShowInDialog<IOffhireDetailView>();
     (view.ViewModel as OffhireDetailVM).Edit(offhireDto, offhireDetailDto);
 }
Beispiel #10
0
        //================================================================================
        private void initialize(OffhireDto offhire, OffhireDetailDto offhireDetailDto)
        {
            this.Offhire = offhire;

            this.Entity = offhireDetailDto;

            //loadGoods();

            //loadCurrencies();
        }
Beispiel #11
0
 //================================================================================
 public void Load(OffhireDto offhire)
 {
     this.IsInEditMode = false;
     initialize(offhire, new OffhireDetailDto());
 }
Beispiel #12
0
 //================================================================================
 public void Edit(OffhireDto offhire, OffhireDetailDto offhireDetailDto)
 {
     this.IsInEditMode = true;
     initialize(offhire, offhireDetailDto);
 }