public static ClientBuildingAndBuildingPackage GetClientBuildingAndBuildingPackage(this ClientBuilding clientBuilding)
 {
     ClientBuildingAndBuildingPackage result = new ClientBuildingAndBuildingPackage();
       if (clientBuilding != null)
       {
     result.ClientBuilding = clientBuilding.GetPrimitive();
     if (clientBuilding.Building != null)
     {
       result.Building = clientBuilding.Building.GetPrimitive();
     }
       }
       return result;
 }
        public static ClientBuildingAndBuildingPackage GetBuildingAndContractorPackage(this Building building)
        {
            ClientBuildingAndBuildingPackage result = new ClientBuildingAndBuildingPackage();

              if (building != null)
              {
            result.Building = building.GetPrimitive();
            //if (building.Contractor != null)
            //{
            //  result.Contractor = building.Contractor.GetPrimitive();
            //}
              }
              return result;
        }
        public static ClientBuildingAndBuildingPackage GetPackageCopy(this ClientBuildingAndBuildingPackage source)
        {
            if (source == null)
            return null;

              ClientBuildingAndBuildingPackage package = new ClientBuildingAndBuildingPackage();
              if (source.ClientBuilding != null)
              {
            package.ClientBuilding = source.ClientBuilding.GetPrimitiveCopy();

              }
              //package.Client = source.Client.GetPrimitiveCopy();
              if (source.Building != null)
              {
            package.Building = source.Building.GetPrimitiveCopy();
              }
              return package;
        }
 public ClientBuildingAndBuildingPackage SelectBuildingAndContractorPackage(IModalDialogService modalDialogService,
     IServiceFactory serviceFactory)
 {
     var viewModel = new ManageClientsViewModel(modalDialogService, serviceFactory);
       viewModel.DialogMode = DialogMode.ChoseSubItem;
       ModalDialogHelper<ManageClients>.ShowDialog(viewModel);
       if (!viewModel.IsCanceled)
       {
     var result = new ClientBuildingAndBuildingPackage();
     result.Building = viewModel.SelectedBuilding;
     result.Client = viewModel.SelectableClient.SelectedItem.Client;
     return result;
       }
       return null;
 }
 public ClientBuildingAndBuildingPackage EditBuilding(IModalDialogService modalDialogService, IServiceFactory serviceFactory,
     ClientBuildingAndBuildingPackage buildingAndClientPackage)
 {
     var viewModel = new UpdateBuildingViewModel(modalDialogService, serviceFactory);
       viewModel.BuildingAndClient = buildingAndClientPackage;
       viewModel.DialogMode = DialogMode.Update;
       ModalDialogHelper<UpdateBuilding>.ShowDialog(viewModel);
       return viewModel.BuildingAndClient;
 }
 public DeliveryNotePackage CreateDeliveryNote(IModalDialogService modalDialogService, IServiceFactory serviceFactory,
     ClientBuildingAndBuildingPackage buildingAndContractorPackage)
 {
     var viewModel = new UpdateDeliveryNoteViewModel(modalDialogService, serviceFactory);
       viewModel.DialogMode = DialogMode.Create;
       viewModel.DeliveryNotePackage = new DeliveryNotePackage();
       viewModel.DeliveryNotePackage.DeliveryNote = new DeliveryNotePrimitive();
       viewModel.DeliveryNotePackage.DeliveryNote.DateDrawing = DateTime.Now;
       viewModel.DeliveryNotePackage.DeliveryNote.DateOfArrival = DateTime.Now;
       viewModel.DeliveryNotePackage.BuildingAndContractor = buildingAndContractorPackage;
       ModalDialogHelper<UpdateDeliveryNote>.ShowDialog(viewModel);
       if (!viewModel.IsCanceled)
       {
     return viewModel.DeliveryNotePackage;
       }
       return null;
 }
 /// <summary>
 /// Executes  <see cref="ChoseBuildingCommand"/>.
 /// </summary>
 /// <remarks>
 /// Closes modal dialog.
 /// </remarks>
 private void CreateDeliveryNote()
 {
     string errorCaption = "Tworzenie WZ'tki!";
       try
       {
     var buildingAndClientPackage = new ClientBuildingAndBuildingPackage();
     buildingAndClientPackage.Building = SelectedBuilding;
     buildingAndClientPackage.Client = SelectableClient.SelectedItem.Client;
     ModalDialogService.CreateDeliveryNote(ModalDialogService, ServiceFactory, buildingAndClientPackage);
       }
       catch (FaultException<ExceptionDetail> f)
       {
     ShowError(errorCaption, f);
     Cancel();
       }
       catch (CommunicationException c)
       {
     ShowError(errorCaption, c);
     Cancel();
       }
       catch (Exception e)
       {
     ShowError(errorCaption, e);
     Cancel();
       }
 }