Esempio n. 1
0
        private void setEntity(FuelReportDetailDto dto)
        {
            this.Entity = dto;
            this.Entity.PropertyChanged += Entity_PropertyChanged;

            CheckEnable();

            setTransferReferences();
        }
Esempio n. 2
0
        public void Load(FuelReportDetailDto fuelReportDetailDto)
        {
            GetCurrency();
            SetCollection();

            ShowBusyIndicator("در حا دریافت جزئیات گزارش");
            this.serviceWrapper.GetById((res, exp) =>
                mainController.BeginInvokeOnDispatcher(() =>
                {
                    if (exp == null)
                    {
                        setEntity(res.FuelReportDetail.SingleOrDefault(c => c.Id == fuelReportDetailDto.Id));
                        ReceiveId = (int)Entity.ReceiveType;
                        TransferId = (int)Entity.TransferType;
                        CorrectionId = (int)Entity.CorrectionType;
                        //ReceiveValue =
                        //    Entity.Recieve.Value;
                        //TransferValue =
                        //    Entity.
                        //        Transfer.
                        //        Value;
                        //CorrectionValue =
                        //    Entity.
                        //        Correction
                        //        .Value;
                        IsFinalApprove = res.IsNextActionFinalApprove;
                        CheckEnable();
                    }
                    else
                    {
                        mainController.HandleException(exp);
                    }

                    HideBusyIndicator();

                }), fuelReportDetailDto.FuelReportId);
        }
        public void UpdateFuelReportDetail(Action<FuelReportDetailDto, Exception> action, FuelReportDetailDto ent)
        {
            var url = string.Format(fuelReportDetailAddressFormatString, ent.FuelReportId, ent.Id);

            WebClientHelper.Put<FuelReportDetailDto, FuelReportDetailDto>(new Uri(url, UriKind.Absolute),
                                                                          (res, exp) => action(res, exp), ent,
                                                                          WebClientHelper.MessageFormat.Json,ApiConfig.Headers);
        }
        //================================================================================
        private void populateFuelReportDetailDtoReferencesLookup(FuelReportDetail fuelReportDetail, FuelReportDetailDto fuelReportDetailDto)
        {
            var correctionReferences = fuelReportDomainService.GetFuelReportDetailCorrectionReferences(fuelReportDetail);
            var transferReferences = fuelReportDomainService.GetFuelReportDetailTransferReferences(fuelReportDetail);
            var receiveReferences = fuelReportDomainService.GetFuelReportDetailReceiveReferences(fuelReportDetail);
            var rejectedReferences = fuelReportDomainService.GetFuelReportDetailRejectedTransferReferences(fuelReportDetail);

            fuelReportDetailDto.FuelReportCorrectionReferenceNoDtos = new List<FuelReportCorrectionReferenceNoDto>();

            if (correctionReferences != null)
            {
                fuelReportDetailDto.FuelReportCorrectionReferenceNoDtos.AddRange(
                    correctionReferences.Select(r => new FuelReportCorrectionReferenceNoDto()
                        {
                            Id = r.ReferenceId.Value,
                            Code = r.Code,
                            ReferenceType = (ReferenceTypeEnum)(int)r.ReferenceType.Value
                        }));
            }

            fuelReportDetailDto.FuelReportTransferReferenceNoDtos = new List<FuelReportTransferReferenceNoDto>();

            if (transferReferences != null)
            {
                fuelReportDetailDto.FuelReportTransferReferenceNoDtos.AddRange(transferReferences.Select(r => new FuelReportTransferReferenceNoDto()
                {
                    Id = r.ReferenceId.Value,
                    Code = r.Code,
                    ReferenceType = (ReferenceTypeEnum)(int)r.ReferenceType.Value
                }));
            }

            fuelReportDetailDto.FuelReportReciveReferenceNoDtos = new List<FuelReportReciveReferenceNoDto>();

            if (receiveReferences != null)
            {
                fuelReportDetailDto.FuelReportReciveReferenceNoDtos.AddRange(receiveReferences.Select(r => new FuelReportReciveReferenceNoDto()
                {
                    Id = r.ReferenceId.Value,
                    Code = r.Code,
                    ReferenceType = (ReferenceTypeEnum)(int)r.ReferenceType.Value
                }));
            }

            fuelReportDetailDto.RejectedTransferReferenceNoDtos = new List<FuelReportTransferReferenceNoDto>();

            if (rejectedReferences != null)
            {
                fuelReportDetailDto.RejectedTransferReferenceNoDtos.AddRange(rejectedReferences.Select(r => new FuelReportTransferReferenceNoDto()
                {
                    Id = r.ReferenceId.Value,
                    Code = r.Code,
                    ReferenceType = (ReferenceTypeEnum)(int)r.ReferenceType.Value
                }));
            }
        }
        //================================================================================
        public FuelReportDetailDto UpdateFuelReportDetail(long fuelReportId, FuelReportDetailDto fuelReportDetailDto)
        {
            var transferReference = Reference.Empty;
            var receiveReference = Reference.Empty;
            var correctionReference = Reference.Empty;

            if (fuelReportDetailDto.FuelReportTransferReferenceNoDto != null)
            {
                transferReference = new Reference()
                                    {
                                        Code = fuelReportDetailDto.FuelReportTransferReferenceNoDto.Code,
                                        ReferenceType = (ReferenceType)fuelReportDetailDto.FuelReportTransferReferenceNoDto.ReferenceType,
                                        ReferenceId = fuelReportDetailDto.FuelReportTransferReferenceNoDto.Id
                                    };
            }

            if (fuelReportDetailDto.FuelReportReciveReferenceNoDto != null)
            {
                receiveReference = new Reference()
                {
                    Code = fuelReportDetailDto.FuelReportReciveReferenceNoDto.Code,
                    ReferenceType = (ReferenceType)fuelReportDetailDto.FuelReportReciveReferenceNoDto.ReferenceType,
                    ReferenceId = fuelReportDetailDto.FuelReportReciveReferenceNoDto.Id
                };
            }

            if (fuelReportDetailDto.FuelReportCorrectionReferenceNoDto != null)
            {
                correctionReference = new Reference()
                {
                    Code = fuelReportDetailDto.FuelReportCorrectionReferenceNoDto.Code,
                    ReferenceType = (ReferenceType)fuelReportDetailDto.FuelReportCorrectionReferenceNoDto.ReferenceType,
                    ReferenceId = fuelReportDetailDto.FuelReportCorrectionReferenceNoDto.Id
                };
            }

            var updatedEntity = this.appService.UpdateFuelReportDetail(
                fuelReportDetailDto.FuelReportId,
                fuelReportDetailDto.Id,
                fuelReportDetailDto.ROB,
                fuelReportDetailDto.Consumption.HasValue ? fuelReportDetailDto.Consumption.Value : 0,
                fuelReportDetailDto.Recieve,
                this.fuelReportDetailToFuelReportDetailDtoMapper.MapDtoReceiveTypeTypeToEntityReceiveTypeType(fuelReportDetailDto.ReceiveType),
                fuelReportDetailDto.Transfer,
                this.fuelReportDetailToFuelReportDetailDtoMapper.MapDtoTransferTypeTypeToEntityTransferTypeType(fuelReportDetailDto.TransferType),
                fuelReportDetailDto.Correction,
                this.fuelReportDetailToFuelReportDetailDtoMapper.MapDtoCorrectionTypeToEntityCorrectionType(fuelReportDetailDto.CorrectionType),
                fuelReportDetailDto.CorrectionPrice.HasValue ? (decimal?) new decimal(fuelReportDetailDto.CorrectionPrice.Value) : null,
                fuelReportDetailDto.CurrencyDto == null ? null : (long?)fuelReportDetailDto.CurrencyDto.Id,
                transferReference,
                receiveReference,
                correctionReference);

            var dto = fuelReportDetailToFuelReportDetailDtoMapper.MapToModel(updatedEntity);

            populateFuelReportDetailDtoReferencesLookup(updatedEntity, dto);

            return dto;
        }
 public void Update(FuelReportDetailDto dto)
 {
     var view = this.ViewManager.ShowInDialog<IFuelReportDetailView>();
     (view.ViewModel as FuelReportDetailVM).Load(dto);
 }