Exemple #1
0
 //public void SetVoyages(ObservableCollection<VoyageDto> voyages)
 //{
 //    this.Voyages = voyages;
 //}
 //private void GetVoyages()
 //{
 //    this.Voyages = new ObservableCollection<VoyageDto>();
 //    this.voyageServiceWrapper.GetByFilter(
 //                                          (res, exp) =>
 //                                          {
 //                                              this.mainController.BeginInvokeOnDispatcher(() =>
 //                                                                                          {
 //                                                                                              if (exp == null)
 //                                                                                              {
 //                                                                                                  this.Voyages.Clear();
 //                                                                                                  foreach (VoyageDto voyage in res)
 //                                                                                                  {
 //                                                                                                      this.Voyages.Add(voyage);
 //                                                                                                  }
 //                                                                                              }
 //                                                                                              else
 //                                                                                              {
 //                                                                                                  this.mainController.HandleException(exp);
 //                                                                                              }
 //                                                                                          });
 //                                          }, this.Entity.Company.Id, this.Entity.Id);
 //}
 public void SetEntity(VoyageDto entity)
 {
     this.Entity = entity;
     //this.GetVoyages();
 }
        //================================================================================
        private void populateVoyageFuelReports(VoyageDto voyageDto)
        {
            var endOfVoyageFuelReport = voyageDomainService.GetVoyageValidEndOfVoyageFuelReport(voyageDto.Id);

            if (endOfVoyageFuelReport != null)
            {
                voyageDto.EndOfVoyageFuelReport = this.fuelReportDtoMapper.MapToModel(endOfVoyageFuelReport);
            }
        }
        //================================================================================
        private void populateVoyageInventoryOperations(VoyageDto voyageDto)
        {
            var endOfVoyageFuelReport = voyageDomainService.GetVoyageValidEndOfVoyageFuelReport(voyageDto.Id);

            if (endOfVoyageFuelReport != null)
            {
                var inventoryOperationsDtos = endOfVoyageFuelReport.FuelReportDetails.SelectMany(frd =>
                {
                    var fuelReportDetailInventoryOperations = inventoryOperationDomainService.GetFuelReportDetailInventoryOperations(frd.FuelReportId, frd.Id);
                    var invDtos = this.inventoryOperationDtoMapper.MapToModel(fuelReportDetailInventoryOperations).ToList();
                    invDtos.ForEach(invDto => invDto.Good = goodDtoMapper.MapToModel(frd.Good));
                    return invDtos;
                });

                voyageDto.EndOfVoyageInventoryOperations = new ObservableCollection<FuelReportInventoryOperationDto>(inventoryOperationsDtos);

                //var inventoryOperations = endOfVoyageFuelReport.FuelReportDetails.SelectMany(frd => fuelReportFacadeService.GetInventoryOperations(frd.FuelReportId, frd.Id));
                //voyageDto.EndOfVoyageInventoryOperations = new ObservableCollection<FuelReportInventoryOperationDto>(inventoryOperations);
            }
        }
        //================================================================================
        private void populateData(VoyageDto voyageDto, bool includeFuelReports, bool includeInventoryOperations)
        {
            if (includeFuelReports)
                populateVoyageFuelReports(voyageDto);

            if (includeInventoryOperations)
                populateVoyageInventoryOperations(voyageDto);
        }