public static PropertySummary BuildPropertySummary(Property property)
        {
            Check.If(property).IsNotNull();

            var result = new PropertySummary
            {
                PropertyReference = property.PropertyReference,
                PropertyType = property.PropertyType,
                AddressLine1 = property.AddressLine1,
                AddressLine2 = property.AddressLine2,
                AddressLine3 = property.AddressLine3,
                AddressLine4 = property.AddressLine4,
                Postcode = property.Postcode,
                County = property.County,
                ShortDescription = property.ShortDescription,
                StartDate = property.StartDate,
                EndDate = property.EndDate,
                MonthlyPrice = property.MonthlyPrice,
                NumberOfBedrooms = property.NumberOfBedrooms(),
                NumberOfBathrooms = property.NumberOfBathrooms(),
                NumberOfPhotos = property.NumberOfPhotos(),
                CoverPhotoUrl = property.CoverPhotoUrl(),
            };

            return result;
        }
 private object buildProperty(PropertySummary property)
 {
     return(new
     {
         address = property.ShortAddress.Trim(),
         postcode = property.PostCodeValue.Trim(),
         propertyReference = property.PropertyReference.Trim()
     });
 }
        /// ------------------------------------------------------------------------------------------------
        /// Name        OnSaveClicked
        ///
        /// <summary>	Save image and Dismisses the popup on clicking Save button.
        /// </summary>
        /// <param name="sender"> </param>
        ///    <param name="e"> event arguments</param>
        /// ------------------------------------------------------------------------------------------------
        private async void OnSaveClicked(object sender, EventArgs e)
        {
            try
            {
                if (_isExecute)
                {
                    _isExecute = false;
                    if (Txt_ImageDescription.Text != null && (Txt_ImageName.Text != null))
                    {
                        Btn_Save.TextColor = Styles.MainAccent;
                        Btn_Save.IsEnabled = true;
                        IsSaveEnabled      = true;
                    }
                    if (IsSaveEnabled)
                    {
                        OnSiteDocument doc;
                        FileSystemArgs write;
                        doc = new OnSiteDocument()
                        {
                            Description = Txt_ImageDescription.Text,
                            Extension   = ".png",
                            Id          = Guid.NewGuid().ToString(),
                            MimeType    = "application/png",
                            Name        = Txt_ImageName.Text,
                            Status      = SyncStatus.Changed,
                        };
                        write = await FileSystem.WriteAsync(ImageBytes, doc.FileName);

                        if (write.Error == null)
                        {
                            AppData.PropertyModel.AddDocument(doc);
                            //saving doc to file for preserving it when loggedout
                            PropertySummary.RefreshCount();
                            DocumentAdded?.Invoke(doc);
                            AppContext.AppContext.InspectionCell.RefreshList();
                        }
                        else
                        {
                            await SplitView.DisplayAlert("Saving Failed", write.Error.Message, "OK", null);
                        }

                        SplitView.CenterPopupContent?.DismisPopup();
                    }

                    await Task.Run(() =>
                    {
                        Task.Delay(2000).Wait();
                        _isExecute = true;
                    });
                }
            }
            catch (Exception ex)
            {
                LogTracking.LogTrace(ex.ToString());
            }
        }
Esempio n. 4
0
        public async Task find_properties_returns_a_list_of_properties()
        {
            var mockLogger = new Mock <ILoggerAdapter <PropertyActions> >();
            var request    = new ListByPostCodeRequest();

            var response = new PropertyInfoResponse()
            {
                PropertyList = new PropertySummary[2],
                Success      = true
            };
            var property1 = new PropertySummary()
            {
                ShortAddress      = "Front Office, Robert House, 6 - 15 Florfield Road",
                PostCodeValue     = "E8 1DT",
                PropertyReference = "1/43453543"
            };
            var property2 = new PropertySummary()
            {
                ShortAddress      = "Maurice Bishop House, 17 Reading Lane",
                PostCodeValue     = "E8 1DT",
                PropertyReference = "2/32453245"
            };

            response.PropertyList[0] = property1;
            response.PropertyList[1] = property2;
            var fakeService = new Mock <IHackneyPropertyService>();

            fakeService.Setup(service => service.GetPropertyListByPostCodeAsync(request))
            .ReturnsAsync(response);

            var fakeRequestBuilder = new Mock <IHackneyPropertyServiceRequestBuilder>();

            fakeRequestBuilder.Setup(service => service.BuildListByPostCodeRequest("E8 1DT")).Returns(request);
            PropertyActions propertyActions = new PropertyActions(fakeService.Object, fakeRequestBuilder.Object, mockLogger.Object);
            var             results         = await propertyActions.FindProperty("E8 1DT");

            var outputproperty1 = new {
                address           = "Front Office, Robert House, 6 - 15 Florfield Road",
                postcode          = "E8 1DT",
                propertyReference = "1/43453543"
            };
            var outputproperty2 = new
            {
                address           = "Maurice Bishop House, 17 Reading Lane",
                postcode          = "E8 1DT",
                propertyReference = "2/32453245"
            };
            var properties = new object[2];

            properties[0] = outputproperty1;
            properties[1] = outputproperty2;
            var json = new { results = properties };

            Assert.Equal(JsonConvert.SerializeObject(json), JsonConvert.SerializeObject(results));
        }
Esempio n. 5
0
        public Task <PropertyInfoResponse> GetPropertyListByPostCodeAsync(ListByPostCodeRequest request)
        {
            var response = new PropertyInfoResponse()
            {
                PropertyList = new PropertySummary[2],
                Success      = true
            };
            var property1 = new PropertySummary()
            {
                ShortAddress      = "Back Office, Robert House, 6 - 15 Florfield Road",
                PostCodeValue     = "E8 1DT",
                PropertyReference = "1/525252525"
            };
            var property2 = new PropertySummary()
            {
                ShortAddress      = "Meeting room, Maurice Bishop House, 17 Reading Lane",
                PostCodeValue     = "E8 1DT",
                PropertyReference = "6/32453245   "
            };

            response.PropertyList[0] = property1;
            response.PropertyList[1] = property2;
            switch (request.PostCode)
            {
            case "E8 1DT":
                return(Task.Run(() => response));

            case "E8 2LT":
                return(Task.Run(() => new PropertyInfoResponse
                {
                    Success = false,
                    ErrorCode = 9903,
                    ErrorMessage = "Master Password is Invalid.",
                    PropertyList = null
                }));

            default:
                return(Task.Run(() => new PropertyInfoResponse
                {
                    PropertyList = new PropertySummary[0],
                    Success = true
                }));
            }
        }
Esempio n. 6
0
        public async Task Logs_information_When_Calling_PropertyActions_FindProperty()
        {
            var response = new PropertyInfoResponse()
            {
                PropertyList = new PropertySummary[2],
                Success      = true
            };
            var property1 = new PropertySummary()
            {
                ShortAddress      = "Front Office, Robert House, 6 - 15 Florfield Road",
                PostCodeValue     = "E8 1DT",
                PropertyReference = "1/43453543"
            };
            var property2 = new PropertySummary()
            {
                ShortAddress      = "Maurice Bishop House, 17 Reading Lane",
                PostCodeValue     = "E8 1DT",
                PropertyReference = "2/32453245"
            };

            response.PropertyList[0] = property1;
            response.PropertyList[1] = property2;
            var mockLogger = new Mock <ILoggerAdapter <PropertyActions> >();

            var fakeService = new Mock <IHackneyPropertyService>();

            fakeService.Setup(service => service.GetPropertyListByPostCodeAsync(It.IsAny <ListByPostCodeRequest>()))
            .ReturnsAsync(response);

            var fakeRequestBuilder = new Mock <IHackneyPropertyServiceRequestBuilder>();

            fakeRequestBuilder.Setup(service => service.BuildListByPostCodeRequest("E8 1DT")).Returns(new ListByPostCodeRequest());
            PropertyActions propertyActions = new PropertyActions(fakeService.Object, fakeRequestBuilder.Object, mockLogger.Object);

            var result = await propertyActions.FindProperty("E8 1DT");

            mockLogger.Verify(l => l.LogInformation(It.IsAny <string>()));
        }
Esempio n. 7
0
        public override void Input()
        {
            if (!ModalActive)
            {
                return;
            }
            IInputMap inputMap = Woofer.Controller.InputManager.ActiveInputMap;

            Vector2D movement = inputMap.Movement;

            if (movement.Magnitude > 1e-5 && Editor.MoveTimeframe.Execute())
            {
                if (movement.Y > 0)
                {
                    if (SelectedIndex - 1 >= 0)
                    {
                        SelectedIndex--;
                    }
                }
                else if (movement.Y < 0)
                {
                    if (SelectedIndex + 1 <= 5)
                    {
                        SelectedIndex++;
                    }
                }
            }

            if (inputMap.Jump.Consume())
            {
                switch (SelectedIndex)
                {
                case 0:
                {
                    PropertySummary property = new PropertySummary(Owner, typeof(Scene).GetProperty("Name"), Owner);
                    property.TriggerEdit(inputMap.Interact.Pressed);
                    ModalActive = false;
                    break;
                }

                case 1:
                {
                    WooferSaveOperation save = new WooferSaveOperation(Owner, Owner.Name, Woofer.Controller.CurrentSave.DirectoryName);
                    save.Save();
                    SavedTimer = 3;
                    break;
                }

                case 2:
                {
                    Owner.Events.InvokeEvent(new ForceModalChangeEvent("entity_list", null));
                    ModalActive  = false;
                    ModalVisible = false;
                    break;
                }

                case 3:
                {
                    Owner.Events.InvokeEvent(new ForceModalChangeEvent("system_list", null));
                    ModalActive  = false;
                    ModalVisible = false;
                    break;
                }

                case 4:
                {
                    Owner.Events.InvokeEvent(new StartObjectEditEvent(Woofer.Controller.CurrentSave.Data, "Edit Save Data", "editor_menu"));
                    Owner.Events.InvokeEvent(new ForceModalChangeEvent("object_editor", null));
                    ModalActive  = false;
                    ModalVisible = false;
                    break;
                }

                case 5:
                {
                    Woofer.Controller.CommandFired(new InternalSceneChangeCommand(new MainMenuScene()));
                    Woofer.Controller.Paused = false;
                    break;
                }
                }
            }
        }
        /// ------------------------------------------------------------------------------------------------
        /// Name		OnSaveClicked
        ///
        /// <summary>	Save audio and Dismisses the popup on clicking Save button.
        /// </summary>
        /// <param name="sender"> </param>
        ///    <param name="e"> event arguments</param>
        /// ------------------------------------------------------------------------------------------------
        private async void OnSaveClicked(object sender, EventArgs e)
        {
            try
            {
                if (!_isRecording)
                {
                    if (_isExecute)
                    {
                        _isExecute = false;
                        if (Txt_AudioDescription.Text != null && (Txt_AudioName.Text != null))
                        {
                            Btn_Save.TextColor = Styles.MainAccent;
                            Btn_Save.IsEnabled = true;
                            IsSaveEnabled      = true;
                        }
                        if (IsSaveEnabled)
                        {
                            var audio = await DependencyService.Get <IRecorder>().AudioByte();

                            if (audio != null)
                            {
                                var doc = new OnSiteDocument()
                                {
                                    Description = Txt_AudioDescription.Text,
                                    Extension   = (Device.OS == TargetPlatform.iOS) ? ".wav" : ".mp3",
                                    Id          = Guid.NewGuid().ToString(),
                                    MimeType    = (Device.OS == TargetPlatform.iOS) ? "application/wav" : "application/mp3",
                                    Name        = Txt_AudioName.Text,
                                    Status      = SyncStatus.Changed,
                                };
                                var write = await FileSystem.WriteAsync(audio, doc.FileName);

                                if (write.Error == null)
                                {
                                    AppData.PropertyModel.AddDocument(doc);
                                    //saving doc to file for preserving it when loggedout
                                    PropertySummary.RefreshCount();
                                    AddNewImageView.DocumentAdded?.Invoke(doc);
                                    AppContext.AppContext.InspectionCell.RefreshList();
                                }
                                else
                                {
                                    await SplitView.DisplayAlert("Saving Failed", write.Error.Message, "OK", null);
                                }

                                DependencyService.Get <IRecorder>().ClearAudioFiles();
                                Cancel();
                            }
                            else
                            {
                                if (Device.OS == TargetPlatform.iOS)
                                {
                                    DependencyService.Get <IDisplayAlertPopup>().NoAudioAlert();
                                }
                                else
                                {
                                    await
                                    SplitView.DisplayAlert("No Audio Recorded", "Please give the audio input", "OK", null);
                                }
                            }
                        }

                        await Task.Run(() =>
                        {
                            Task.Delay(2000).Wait();
                            _isExecute = true;
                        });
                    }
                }
                else
                {
                    if (Device.OS == TargetPlatform.iOS)
                    {
                        DependencyService.Get <IDisplayAlertPopup>().AudioIsRecording();
                    }
                    else
                    {
                        await SplitView.DisplayAlert("Warning", "You can not save the Audio while recording", "OK", null);
                    }
                }
            }
            catch (Exception ex)
            {
                LogTracking.LogTrace(ex.ToString());
                // ignored
            }
        }