Ejemplo n.º 1
0
        public async Task LoadRealEstates(int page = 1)
        {
            if (!String.IsNullOrEmpty(SearchTerm))
            {
                TotalPagesQuantity = (int)Math.Ceiling((decimal)await RealEstateServices.GetTotalPagesSearch(SearchTerm) / QuantityPerPage);
            }
            else
            {
                TotalPagesQuantity = TotalPagesAllRealEstates;
            }
            var result = (await RealEstateServices.GetRealEstates(page, QuantityPerPage, SearchTerm));

            if (result.error)
            {
                Error = result.error;
            }

            else
            {
                Error       = result.error;
                RealEstates = result.realEstates.ToList();
                if (RealEstates.Count == 0)
                {
                    EstatesFound = false;
                }
                else
                {
                    EstatesFound = true;
                }
            }
        }
        public async Task EditRealEstateShouldReturnTrue()
        {
            var mapper = this.GetMapper();

            var realEstateToEdit = this.TestData.FirstOrDefault();
            var mappedRealEstate = mapper.Map <RealEstateEditServiceModel>(realEstateToEdit);

            double  newArea  = 666;
            decimal newPrice = 999999m;

            mappedRealEstate.Area  = newArea;
            mappedRealEstate.Price = newPrice;

            var serviceInstance = new RealEstateServices(context,
                                                         realEstateTypeServices.Object,
                                                         citiesServices.Object,
                                                         neighbourhoodServices.Object,
                                                         addressServices.Object,
                                                         villageServices.Object,
                                                         buildingTypeServices.Object,
                                                         heatingSystemServices.Object,
                                                         mapper);

            var actualResult = await serviceInstance.EditRealEstateAsync(mappedRealEstate);

            Assert.IsTrue(actualResult);
            Assert.That(realEstateToEdit.Area == newArea);
        }
        public void CreateRealEstateShoulThrowsExceptionUponInvalidParameters()
        {
            string  expectedId   = "myNewCoolId";
            decimal invalidPrice = -1m;
            var     mapper       = this.GetMapper();

            var serviceInstance = new RealEstateServices(context,
                                                         realEstateTypeServices.Object,
                                                         citiesServices.Object,
                                                         neighbourhoodServices.Object,
                                                         addressServices.Object,
                                                         villageServices.Object,
                                                         buildingTypeServices.Object,
                                                         heatingSystemServices.Object,
                                                         mapper);

            var realEstateModel = new RealEstateCreateServiceModel()
            {
                Id                  = expectedId,
                Area                = 100,
                RealEstateType      = "Мезонет",
                Price               = invalidPrice,
                FloorNumber         = "4",
                BuildingTotalFloors = 5,
                City                = "София",
                BuildingType        = "Тухла",
            };

            Assert.ThrowsAsync <ArgumentNullException>(async() => await serviceInstance.CreateRealEstateAsync(realEstateModel), InvalidAddressExceptionMessage);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Handles the data
        /// </summary>
        /// <returns></returns>
        public async Task Register()
        {
            Errors = new List <string>();
            ShowRegistrationErros = false;

            PropertyForRegistration = ConvertToValidPropertysForRegistration(PropertyForRegistration);

            //Forwards the data to repository to post to the API
            var result = await RealEstateServices.PostANewRealEstate(PropertyForRegistration);

            if (!result.IsSuccessfulRegistration)
            {
                //Handles the event of a non sucessfull post to the api
                foreach (var error in result.Errors)
                {
                    Errors.Add(error.Value[0]);
                }

                ShowRegistrationErros = true;
            }
            else
            {
                //Redirects to the realEstateDetails page for that newly created RealEstate
                NavigationManager.NavigateTo($"/RealEstate/{result.Id}");
            }
        }
        public void GetRealEstateIDByOfferIdShouldThrowException(string offerId)
        {
            var serviceInstance = new RealEstateServices(context,
                                                         realEstateTypeServices.Object,
                                                         citiesServices.Object,
                                                         neighbourhoodServices.Object,
                                                         addressServices.Object,
                                                         villageServices.Object,
                                                         buildingTypeServices.Object,
                                                         heatingSystemServices.Object,
                                                         mapper);

            Assert.ThrowsAsync <ArgumentNullException>(async() => await serviceInstance.GetRealEstateIdByOfferId(offerId), NonExistingRealEstateMessage);
        }
        public void GetRealEstateDetailsShouldThrowAnExceptionIfNoSuchRealEstate()
        {
            var mapper = this.GetMapper();

            var invalidId = "reallyInvalidId";

            var serviceInstance = new RealEstateServices(context,
                                                         realEstateTypeServices.Object,
                                                         citiesServices.Object,
                                                         neighbourhoodServices.Object,
                                                         addressServices.Object,
                                                         villageServices.Object,
                                                         buildingTypeServices.Object,
                                                         heatingSystemServices.Object,
                                                         mapper);

            Assert.ThrowsAsync <ArgumentNullException>(async() => await serviceInstance.GetDetailsAsync(invalidId), NonExistingRealEstateMessage);
        }
        public void EditRealEstateShouldThrowAnExceptionIfNoSuchRealEstate()
        {
            var mapper = this.GetMapper();

            var nonExistingRealEstate = new RealEstateEditServiceModel
            {
                Id    = "Agent007",
                Price = 7500m,
                Area  = 7,
            };

            var serviceInstance = new RealEstateServices(context,
                                                         realEstateTypeServices.Object,
                                                         citiesServices.Object,
                                                         neighbourhoodServices.Object,
                                                         addressServices.Object,
                                                         villageServices.Object,
                                                         buildingTypeServices.Object,
                                                         heatingSystemServices.Object,
                                                         mapper);

            Assert.ThrowsAsync <ArgumentNullException>(async() => await serviceInstance.EditRealEstateAsync(nonExistingRealEstate), NonExistingRealEstateMessage);
        }
Ejemplo n.º 8
0
 public async void TryAgain()
 {
     TotalPagesAllRealEstates = (int)Math.Ceiling((decimal)await RealEstateServices.GetTotalPages() / QuantityPerPage);
     await LoadRealEstates(CurrentPage);
 }
Ejemplo n.º 9
0
 protected override async Task OnInitializedAsync()
 {
     TotalPagesAllRealEstates = (int)Math.Ceiling((decimal)await RealEstateServices.GetTotalPages() / QuantityPerPage);
     TotalPagesQuantity       = TotalPagesAllRealEstates;
     await LoadRealEstates();
 }