예제 #1
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}");
            }
        }
예제 #2
0
        /// <summary>
        /// Converts from the PropertysForRegistration to regular Propertys model.
        /// </summary>
        /// <param name="propertyForRegistration"></param>
        /// <returns></returns>
        private PropertysForRegistration ConvertToValidPropertysForRegistration(PropertysForRegistration propertyForRegistration)
        {
            propertyForRegistration.Type = (int)propertyForRegistration.RealEstateType;
            propertyForRegistration.Urls = ImageURL;


            if (propertyForRegistration.CanBeSold)
            {
                propertyForRegistration.CanBeSold    = true;
                propertyForRegistration.CanBeRented  = false;
                propertyForRegistration.SellingPrice = propertyForRegistration.RentSalePrice;
                propertyForRegistration.RentingPrice = null;
            }
            else
            {
                propertyForRegistration.CanBeSold    = false;
                propertyForRegistration.CanBeRented  = true;
                propertyForRegistration.RentingPrice = propertyForRegistration.RentSalePrice;
                propertyForRegistration.SellingPrice = null;
            }

            return(propertyForRegistration);
        }
예제 #3
0
 /// <summary>
 /// Clears the form if a user wants to start over
 /// </summary>
 public void ClearForm()
 {
     PropertyForRegistration = new PropertysForRegistration();
 }