public PropertyInfoModel CreatePropertyInfoModel(Compilation compilation)
	    {
		    PropertyInfoModel propertyInfoModel = new PropertyInfoModel
		    {
				Name = Name.Name,
			    IsOptional = Optional,
			    IsArray = Type is TsArray,
				Type = GetPropertyTypeEnum(this)
				
		    };

		    //Optional

		    //Validators
		    foreach (AttributeData attributeData in Symbol.GetAttributes())
		    {
			    if (DefaultPropertyValueAttribute.IsDefaultValueAttribute(compilation, attributeData, out object defaultValue))
			    {
				    propertyInfoModel.DefaultValue = defaultValue;
			    }
				else if (DateTimePropertyValueAttribute.IsDefaultValueAttribute(compilation, attributeData,
				    out DateTimeValidatorModel validatorModel))
			    {
				    propertyInfoModel.Add(validatorModel);

				}
		    }

			return propertyInfoModel;
	    }
Esempio n. 2
0
        public void Ctor_InitializesProperties(object value, PropertyInfoModel propertyInfo)
        {
            var navigationParameterModel = new NavigationParameterModel(value, propertyInfo);

            Assert.Equal(value, navigationParameterModel.Value);
            Assert.Equal(propertyInfo, navigationParameterModel.PropertyInfo);
        }
        public void Ctor_WithNullPropertyInfo_InitializesPropertiesToEmptyStrings()
        {
            var model = new PropertyInfoModel(null);

            Assert.Empty(model.PropertyName);
            Assert.Empty(model.AssemblyQualifiedTypeName);
        }
        public void ToPropertyInfo_WithInvalidPropertyName_ThrowsCorrectException(
            string propertyName,
            string typeName)
        {
            var model = new PropertyInfoModel(propertyName, typeName);

            Assert.Throws <PropertyNotFoundException>(() => model.ToPropertyInfo());
        }
        public void ToPropertyInfo_WithValidData_ReturnsValidProperty(
            PropertyInfo result,
            string propertyName,
            string typeName)
        {
            var model = new PropertyInfoModel(propertyName, typeName);

            var propertyInfo = model.ToPropertyInfo();

            Assert.Equal(result, propertyInfo);
        }
        public void Ctor_WithPropertyAndTypeNames_InitializesProperties(
            [CombinatorialValues(null, "", "a", "abc")] string propertyName,
            [CombinatorialValues(null, "", "a", "abc")] string typeName)
        {
            var model = new PropertyInfoModel(propertyName, typeName);

            Assert.NotNull(model.PropertyName);
            Assert.NotNull(model.AssemblyQualifiedTypeName);

            Assert.Equal(propertyName ?? string.Empty, model.PropertyName);
            Assert.Equal(typeName ?? string.Empty, model.AssemblyQualifiedTypeName);
        }
        public void Ctor_WithPropertyInfo_InitializesProperties(
            PropertyInfo propertyInfo,
            string propertyName,
            string typeName)
        {
            var model = new PropertyInfoModel(propertyInfo);

            Assert.NotNull(model.PropertyName);
            Assert.NotNull(model.AssemblyQualifiedTypeName);

            Assert.Equal(propertyName, model.PropertyName);
            Assert.Equal(typeName, model.AssemblyQualifiedTypeName);
        }
Esempio n. 8
0
        public void FillPropertyInfo(PropertyInfoModel propertyInfo)
        {
            var account = RootRepository.AccountRepository.GetCurrentLoggedInAccount();
            var hotel   = account.Hotels.FirstOrDefault();

            if (hotel == null || hotel.HotelDetail == null)
            {
                return;
            }

            propertyInfo.FKHotel  = hotel.PKID;
            propertyInfo.Name     = hotel.Name;
            propertyInfo.Phone    = hotel.HotelDetail.Phone;
            propertyInfo.Location = new LocationModel
            {
                Address        = hotel.HotelDetail.Address,
                City           = hotel.HotelDetail.City,
                ISOStateCode   = hotel.HotelDetail.State,
                PostalCode     = hotel.HotelDetail.Zip,
                ISOCountryCode = hotel.HotelDetail.ISOCountryCode,
            };
        }
Esempio n. 9
0
        public SetupModel GetSetupModel()
        {
            //TODO BUILD OUT
            //var summaryItems = RootRepository.SalesForceRepository.GetSummaryItems();
            //var solutionSummary = new SolutionSummaryModel();

            //RootRepository.SalesForceRepository.FillBillingInfo(solutionSummary);

            //solutionSummary.HasDelivery = summaryItems.Any(x => x.Delivery);
            //solutionSummary.SummaryItems = summaryItems;

            var propertyInfo = new PropertyInfoModel();

            RootRepository.HotelRepository.FillPropertyInfo(propertyInfo);

            var account = RootRepository.SecurityRepository.GetLoggedInUser().Account;

            return(new SetupModel
            {
                CurrentStep = 0,                 //BitwiseUtils.HasFlag(account.StatusFlags, (int)AccountStatusFlags.BillingCompleted) ? 1 : 0,
                //SolutionSummary = solutionSummary,
                PropertyInfo = propertyInfo
            });
        }
Esempio n. 10
0
        public void UpdatePropertyInfo(PropertyInfoModel model)
        {
            var account = RootRepository.AccountRepository.GetCurrentLoggedInAccount();
            var hotel   = account.Hotels.FirstOrDefault();

            //TODO: JD: Throw Error
            if (hotel == null || hotel.HotelDetail == null)
            {
                return;
            }

            var nameHasChanges  = !string.Equals(hotel.Name, model.Name);
            var phoneHasChanges = !string.Equals(hotel.HotelDetail.Phone, model.Phone);

            hotel.Name = model.Name;
            hotel.HotelDetail.Phone = model.Phone;

            var locationHasChanges = false;

            if (model.Location != null)
            {
                locationHasChanges = hotel.HotelDetail.LocationIsDifferent(model.Location);

                if (locationHasChanges)
                {
                    hotel.HotelDetail.Address        = model.Location.Address;
                    hotel.HotelDetail.City           = model.Location.City;
                    hotel.HotelDetail.State          = model.Location.State != null ? model.Location.State.ISOStateCode : null;
                    hotel.HotelDetail.Zip            = model.Location.PostalCode;
                    hotel.HotelDetail.ISOCountryCode = model.Location.Country != null
                                                ? model.Location.Country.ISOCountryCode
                                                : null;

                    // Update the hotel's lat/long
                    try
                    {
                        var geoCodeResult = MonsciergeServiceUtilities.VendorServices.Geocode.DoGeocode(model.Location.FullAddress, "", true);
                        if (geoCodeResult != null && geoCodeResult.Any())
                        {
                            var result = geoCodeResult[0];
                            if (result != null)
                            {
                                hotel.HotelDetail.Latitude  = ( float )(result.Latitude.HasValue ? result.Latitude.Value : 0);
                                hotel.HotelDetail.Longitude = ( float )(result.Longitude.HasValue ? result.Longitude.Value : 0);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogError(ex.ToString());
                    }
                }
            }

            Context.LogValidationFailSaveChanges(RootRepository.SecurityRepository.AuditLogUserId);

            // If there were any changes to the property info, SalesForce needs to be updated as well.
            var hasChanges = (nameHasChanges || phoneHasChanges || locationHasChanges);

            if (!hasChanges)
            {
                return;
            }

            var contactUser = RootRepository.SecurityRepository.GetLoggedInUser();
            var sfWrapper   = new MonsciergeSFWrapper.SFWrapper();

            try
            {
                sfWrapper.Connect();
                var existingLead = sfWrapper.GetLeadByEmail(contactUser.Email);
                if (existingLead != null && string.Equals(existingLead.LeadSource, "signup.monscierge.com"))
                {
                    var lead = new Lead
                    {
                        Id = existingLead.Id,
                    };

                    var isSelectPlan = string.Equals(existingLead.connect_product__c, "Select", StringComparison.OrdinalIgnoreCase);

                    if (nameHasChanges)
                    {
                        lead.property_name__c = model.Name;

                        if (isSelectPlan)
                        {
                            lead.billing_company_name__c = model.Name;
                            lead.Company = model.Name;
                        }
                    }

                    if (phoneHasChanges)
                    {
                        lead.Phone = model.Phone;
                        if (isSelectPlan)
                        {
                            lead.billing_phone__c = model.Phone;
                        }
                    }

                    if (model.Location != null && locationHasChanges)
                    {
                        lead.address_1__c     = model.Location.Address1;
                        lead.address_2__c     = model.Location.Address2;
                        lead.hotel_city__c    = model.Location.City;
                        lead.hotel_state__c   = model.Location.State == null ? "" : model.Location.State.ISOStateCode;
                        lead.hotel_zip__c     = model.Location.PostalCode;
                        lead.hotel_country__c = model.Location.Country == null ? "" : model.Location.Country.ISOCountryCode;

                        if (isSelectPlan)
                        {
                            lead.billing_address__c     = model.Location.Address1;
                            lead.billing_address_2__c   = model.Location.Address2;
                            lead.billing_city__c        = model.Location.City;
                            lead.billing_state__c       = model.Location.State == null ? "" : model.Location.State.ISOStateCode;
                            lead.billing_postal_code__c = model.Location.PostalCode;
                            lead.billing_country__c     = model.Location.Country == null ? "" : model.Location.Country.ISOCountryCode;
                        }
                    }

                    var result = sfWrapper.UpdateLead(lead);
                    if (result.errors == null)
                    {
                        return;
                    }

                    result.errors.ForEach(e => Logger.LogInfo(e.message));
                    throw new Exception(
                              "Unable to update SalesForce lead record. Review preceding info messages for additional details.");
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.ToString());
            }
            finally
            {
                sfWrapper.Disconnect();
            }
        }
Esempio n. 11
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="NavigationParameterModel"/> class.
 /// </summary>
 /// <param name="value">Parameter value.</param>
 /// <param name="propertyInfo">
 ///     Model representing information about
 ///     a property that should store <paramref name="value"/>.
 /// </param>
 public NavigationParameterModel(object?value, PropertyInfoModel propertyInfo)
 {
     Value        = value;
     PropertyInfo = propertyInfo;
 }