public PropertyModel Get(int id) { var entity =_propertyService.GetPropertyById(id); var model = new PropertyModel { Id = entity.Id, PropertyName = entity.PropertyName, Adduser = new UserModel { Id = entity.Adduser.Id, UserName = entity.Adduser.UserName }, Addtime = entity.Addtime, UpdUser = new UserModel { Id = entity.UpdUser.Id, UserName = entity.UpdUser.UserName }, UpdTime = entity.UpdTime, // Value = entity.Value, Category = new CategoryModel() { Id = entity.Category.Id} }; return model; }
/// <summary>ѕроизводит соответствующую статусу свойства модель представлени¤ его значений</summary> /// <param name="Property">ћодель свойства</param> /// <returns>ћодель представлени¤ значений свойства, соответствующа¤ его статусу </returns> public PropertyValuesViewModel GetViewModel(PropertyModel Property) { switch (Property.Status) { case PropertyValueStatus.Match: return new MatchedPropertyValuesViewModel(GetString(Property.TargetValue, Property.StringFormat, Property.DictionaryValues)); case PropertyValueStatus.Corrupted: return new MismatchedPropertyValuesViewModel("Error", GetString(Property.TargetValue, Property.StringFormat, Property.DictionaryValues)); case PropertyValueStatus.Mismatch: return new MismatchedPropertyValuesViewModel(GetString(Property.CurrentValue, Property.StringFormat, Property.DictionaryValues), GetString(Property.TargetValue, Property.StringFormat, Property.DictionaryValues)); case PropertyValueStatus.NotDescribed: return new UnknownPropertyValuesViewModel(GetString(Property.CurrentValue, Property.StringFormat, Property.DictionaryValues)); case PropertyValueStatus.Unset: return new UnsetPropertyValuesViewModel(GetString(Property.TargetValue, Property.StringFormat, Property.DictionaryValues)); case PropertyValueStatus.Unreaded: return new UnreadedPropertyValuesViewModel(GetString(Property.TargetValue, Property.StringFormat, Property.DictionaryValues)); case PropertyValueStatus.Dummy: return new DummyPropertyValuesViewModel(); default: Debug.Fail("Ќеизвестный тип состо¤ни¤ значений свойства", string.Format("ƒл¤ свойства {0} указано состо¤ние {1}, не поддерживаемое фабрикой моделей представлений значений свойств.", Property.Name, Property.Status)); // ReSharper disable once HeuristicUnreachableCode return new MismatchedPropertyValuesViewModel(GetString(Property.CurrentValue, Property.StringFormat, Property.DictionaryValues), GetString(Property.TargetValue, Property.StringFormat, Property.DictionaryValues)); } }
public PropertyModel GetModel(Property property) { PropertyModel model = new PropertyModel(); model.Name = property.Name; model.Value = property.Value; return model; }
public void GetMetadataForPropertiesCreatesMetadataForAllPropertiesOnModelWithPropertyValues() { // Arrange PropertyModel model = new PropertyModel { LocalAttributes = 42, MetadataAttributes = "hello", MixedAttributes = 21.12 }; TestableAssociatedMetadataProvider provider = new TestableAssociatedMetadataProvider(); // Act provider.GetMetadataForProperties(model, typeof(PropertyModel)).ToList(); // Call ToList() to force the lazy evaluation to evaluate // Assert CreateMetadataParams local = provider.CreateMetadataLog.Single(m => m.ContainerType == typeof(PropertyModel) && m.PropertyName == "LocalAttributes"); Assert.AreEqual(typeof(int), local.ModelType); Assert.AreEqual(42, local.Model); Assert.IsTrue(local.Attributes.Any(a => a is RequiredAttribute)); CreateMetadataParams metadata = provider.CreateMetadataLog.Single(m => m.ContainerType == typeof(PropertyModel) && m.PropertyName == "MetadataAttributes"); Assert.AreEqual(typeof(string), metadata.ModelType); Assert.AreEqual("hello", metadata.Model); Assert.IsTrue(metadata.Attributes.Any(a => a is RangeAttribute)); CreateMetadataParams mixed = provider.CreateMetadataLog.Single(m => m.ContainerType == typeof(PropertyModel) && m.PropertyName == "MixedAttributes"); Assert.AreEqual(typeof(double), mixed.ModelType); Assert.AreEqual(21.12, mixed.Model); Assert.IsTrue(mixed.Attributes.Any(a => a is RequiredAttribute)); Assert.IsTrue(mixed.Attributes.Any(a => a is RangeAttribute)); }
public ConfigurationViewModel() { // Data UserName = new PropertyModel<string>(); Sites = new ObservableCollection<ConfigurationSiteViewModel>(); SelectedItem = new PropertyModel<ConfigurationSiteViewModel>(); SelectedItemScrollTo = new PropertyReadonlyModel<ConfigurationSiteViewModel>(); // helper to influence grid selection GeneratedForSite = new PropertyReadonlyModel<string>(); GeneratedPassword = new PropertyReadonlyModel<string>(); CurrentMasterPassword = new PropertyModel<SecureString>(); ResetMasterPassword = new PropertyReadonlyModel<bool>(); LastClipboardAction = new PropertyReadonlyModel<string>(); CurrentMasterPassword.PropertyChanged += delegate { ResetMasterPassword.SetValue(false); }; // Commands Add = new DelegateCommand(() => PerformAdd()); RemoveSelected = new DelegateCommand(() => { if (CanRemove(SelectedItem.Value)) Sites.Remove(SelectedItem.Value); }, () => SelectedItem.Value != null); GeneratePassword = new DelegateCommand(DoGeneratePassword, () => CurrentMasterPassword.Value != null && SelectedItem.Value != null); CopyToClipBoard = new DelegateCommand(DoCopyPassToClipboard, () => !string.IsNullOrEmpty(GeneratedPassword.Value) && CurrentMasterPassword.Value != null); CopyLoginToClipBoard = new DelegateCommand(DoCopyLoginToClipboard, () => SelectedItem.Value != null); // Change detection DetectChanges = new GenericChangeDetection(); DetectChanges.AddINotifyPropertyChanged(UserName); DetectChanges.AddCollectionOfIDetectChanges(Sites, item => item.DetectChanges); }
/// <summary>The default string formatter for converting a property value to a display string.</summary> /// <param name="property">The property to format.</param> /// <returns>A string representation of the property's current value.</returns> public static string FormatValueToString(PropertyModel property) { // Setup initial conditions. var value = property.Value; var type = property.Definition.PropertyType; var typeFullName = type.FullName; var typeName = type.Name; // Retrieve the value, and check for Null. if (value == null) return NullLabel; // Check if an explicit text-value has been defined on the attribute. var attr = property.PropertyGridAttribute; if (attr != null && attr.Value.AsNullWhenEmpty() != null) return attr.Value; // Check if the object is a color. if (IsColor(property.Definition.PropertyType)) { var color = ToColor(value); return string.Format("R:{0}, G:{1}, B:{2}, A:{3}", color.R, color.G, color.B, color.A); } // Convert the value to a string. var textValue = value.ToString(); if (textValue == typeFullName || property.Definition.PropertyType.IsAssignableFrom(typeof(Stream))) { // If the value emitted a full type-name, shorten it. textValue = string.Format("[{0}]", typeName); } return textValue; }
public EnumEditorViewModel(PropertyModel model) : base(model) { EnumValues = EnumValue.GetValues(model.Definition.PropertyType); var currentValue = Value; var selectedValue = EnumValues.FirstOrDefault(item => Equals(currentValue, item.Value)); SelectedIndex = EnumValues.IndexOf(selectedValue); }
public void CopyConstructor_CopiesAllProperties() { // Arrange var propertyModel = new PropertyModel(typeof(TestController).GetProperty("Property"), new List<object>() { new FromBodyAttribute() }); propertyModel.Controller = new ControllerModel(typeof(TestController).GetTypeInfo(), new List<object>()); propertyModel.BindingInfo = BindingInfo.GetBindingInfo(propertyModel.Attributes); propertyModel.PropertyName = "Property"; propertyModel.Properties.Add(new KeyValuePair<object, object>("test key", "test value")); // Act var propertyModel2 = new PropertyModel(propertyModel); // Assert foreach (var property in typeof(PropertyModel).GetProperties()) { if (property.Name.Equals("BindingInfo")) { // This test excludes other mutable objects on purpose because we deep copy them. continue; } var value1 = property.GetValue(propertyModel); var value2 = property.GetValue(propertyModel2); if (typeof(IEnumerable<object>).IsAssignableFrom(property.PropertyType)) { Assert.Equal<object>((IEnumerable<object>)value1, (IEnumerable<object>)value2); // Ensure non-default value Assert.NotEmpty((IEnumerable<object>)value1); } else if (typeof(IDictionary<object, object>).IsAssignableFrom(property.PropertyType)) { Assert.Equal(value1, value2); // Ensure non-default value Assert.NotEmpty((IDictionary<object, object>)value1); } else if (property.PropertyType.GetTypeInfo().IsValueType || Nullable.GetUnderlyingType(property.PropertyType) != null) { Assert.Equal(value1, value2); // Ensure non-default value Assert.NotEqual(value1, Activator.CreateInstance(property.PropertyType)); } else { Assert.Same(value1, value2); // Ensure non-default value Assert.NotNull(value1); } } }
public PropertyViewModel(PropertyModel model) { // Setup initial conditions. this.model = model; typeFullName = model.Definition.PropertyType.FullName; IsEditable = model.Definition.CanWrite; // Wire up events. if (model.ParentInstance is INotifyPropertyChanged) ((INotifyPropertyChanged)model.ParentInstance).PropertyChanged += HandleInstancePropertyChanged; }
public PropertyViewModel(PropertyModel Property, IPropertyValuesViewModelFactory PropertyValuesViewModelFactory) { _propertyValuesViewModelFactory = PropertyValuesViewModelFactory; Name = Property.Name; GroupName = Property.GroupName; DisplayIndex = Property.DisplayIndex; Values = _propertyValuesViewModelFactory.GetViewModel(Property); Status = Property.Status; Property.CurrentValueChanged += PropertyOnSomeValueChanged; Property.TargetValueChanged += PropertyOnSomeValueChanged; }
public ConfigurationSiteViewModel() { SiteName = new PropertyModel<string>(); Login = new PropertyModel<string>(); Counter = new PropertyModel<int>(1); // default should be 1? TypeOfPassword = new PropertyModel<PasswordType>(); DetectChanges = new GenericChangeDetection(); DetectChanges.AddINotifyPropertyChanged(SiteName); DetectChanges.AddINotifyPropertyChanged(Login); DetectChanges.AddINotifyPropertyChanged(Counter); DetectChanges.AddINotifyPropertyChanged(TypeOfPassword); }
/// <summary>Parses a string representation of a value converting it to it's native type.</summary> /// <param name="textValue">The text display version of the value to parse.</param> /// <param name="property">The definition of the property the value pertains to.</param> /// <param name="error">An error to return if parsing was not successful (null if parsed successfully).</param> /// <returns>The parsed value in it's native type/</returns> public static object ParseValue(string textValue, PropertyModel property, out Exception error) { // Setup initial conditions. var propType = property.Definition.PropertyType; error = null; // Retrieve the appropriate value converter. var converter = TypeConverterHelper.GetConverter(propType); // Attempt to perform the value conversion. try { return converter != null ? converter.ConvertFrom(textValue) : null; } catch (Exception e) { error = e; return null; } }
public void CanSaveAndReloadProject() { doc.LoadXml(NUnitProjectXml.NormalProject); doc.Save(xmlfile); Assert.IsTrue(File.Exists(xmlfile)); ProjectModel doc2 = new ProjectModel(xmlfile); doc2.Load(); PropertyModel project2 = new PropertyModel(doc2); Assert.AreEqual(2, project2.Configs.Count); Assert.AreEqual(2, project2.Configs[0].Assemblies.Count); Assert.AreEqual("assembly1.dll", project2.Configs[0].Assemblies[0]); Assert.AreEqual("assembly2.dll", project2.Configs[0].Assemblies[1]); Assert.AreEqual(2, project2.Configs[1].Assemblies.Count); Assert.AreEqual("assembly1.dll", project2.Configs[1].Assemblies[0]); Assert.AreEqual("assembly2.dll", project2.Configs[1].Assemblies[1]); }
protected Expression <Func <T, bool> > GetExpression(PropertyModel item) { Expression <Func <T, bool> > func = null; switch (item.OperationType) { case OperationType.Equal: func = expression.Equal(item.PropertyName, item.PropertyValue); break; case OperationType.NotEqual: func = expression.NotEqual(item.PropertyName, item.PropertyValue); break; case OperationType.GreaterThan: func = expression.GreaterThan(item.PropertyName, item.PropertyValue); break; case OperationType.GreaterThanOrEqual: func = expression.GreaterThanOrEqual(item.PropertyName, item.PropertyValue); break; case OperationType.LessThan: func = expression.LessThan(item.PropertyName, item.PropertyValue); break; case OperationType.LessThanOrEqual: func = expression.LessThanOrEqual(item.PropertyName, item.PropertyValue); break; case OperationType.Contains: func = expression.Contains(item.PropertyName, item.PropertyValue); break; default: func = expression.True(); break; } return(func); }
public async Task PropertyApi_UpdatePropertyInfoAsync_IntegrationTest() { var property = new PropertyModel { UserId = Guid.Parse("10445DB1-C5B0-478A-89F6-613450414ED4"), PropertyId = Guid.Parse("BCEDAB95-5E70-4A0B-83DC-0053D28A7D8F"), Name = "SYBU Dorm", Address = "1st St. La Guardia, Lahug", City = "Cebu City", ContactNo = "(032)2567890", Owner = "Marlyn", TotalRooms = 0 }; try { var token = await GenerateTokenAsync(); client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}"); var payload = new StringContent( JsonConvert.SerializeObject(property), Encoding.UTF8, "application/json" ); var request = await client.PutAsync($"api/v1/Property", payload); var response = await request.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject <ResponseModel>(response); Assert.IsTrue(result.Status, "Error updating property info."); } catch (Exception ex) { logService.Log($"API Endpoint: Update Property {property.Name} - {property.PropertyId} Info", ex.InnerException.Message, ex.Message, ex.StackTrace); Assert.Fail(ex.Message); } }
public MapWebViewPage(PropertyModel items) { var vm = new MapViewModel(items); BindingContext = vm; InitializeComponent(); var position = new Position(vm.PropertyModel.Latitude, vm.PropertyModel.Longitude); // Latitude, Longitude var pin = new Pin { Type = PinType.Place, Position = position, Label = vm.PropertyModel.BuildingNumber + (vm.PropertyModel.BuildingNumber.Length == 0 ? "" : (vm.PropertyModel.BuildingName.Length == 0 ? "" : ", ")) + vm.PropertyModel.BuildingName, Address = vm.PropertyModel.PrincipalStreet + (vm.PropertyModel.PrincipalStreet.Length == 0 ? "" : (Convert.ToString(vm.PropertyModel.Postcode).Length == 0 ? "" : ", ")) + vm.PropertyModel.Postcode }; // webMap.Source = string.Format("bingmaps:?where={0}", position); //https://www.google.com/maps/embed/v1/directions?key=AIzaSyBDeLLKSqV4q8cKyMIZfPq2_FBnIqfepxk&origin=47.4242683,8.5542138&destination=47.2572183,8.60678729999995 //https://www.google.com/maps/embed/v1/view?key=AIzaSyBDeLLKSqV4q8cKyMIZfPq2_FBnIqfepxk¢er=-33.8569,151.2152&zoom=18&maptype=satellite // webMap.Source = string.Format("https://www.google.com/maps/embed/v1/view?key=AIzaSyA5Kp3TdfKsWYGDc8n_Sia4FdMNnwoXUNg¢er=-33.8569,151.2152&zoom=18&maptype=satellite"); // webMap.Source = string.Format("https://www.bing.com/maps?cp={0}~{1}&lvl=18&style=r", vm.PropertyModel.Latitude, vm.PropertyModel.Longitude); Device.OpenUri(new Uri(string.Format("bingmaps:?where={0}", Uri.EscapeDataString(position.ToString())))); }
public ActionResult Create(PropertyModel propertyModel) { IEnumerable <PropertyType> propertyTypes = propertyBL.GetPropertyType(); ViewBag.propertyId = new SelectList(propertyTypes, "PropertyTypeID", "Type"); Property property = new Property(); if (ModelState.IsValid) { property = AutoMapper.Mapper.Map <PropertyModel, Property>(propertyModel); if (propertyBL.Create(property) > 0) { TempData["TypeId"] = property; return(RedirectToAction("AddFeature", "PropertyFeature")); } else { ViewBag.Message = "failed"; } } return(View()); }
protected virtual void EmitPropertyGetterMethod( CompositeCodeGenerationInfo codeGenerationInfo, PropertyModel propertyModel, CompositeTypeGenerationInfo publicCompositeGenInfo, CompositeTypeGenerationInfo thisGenerationInfo, CILField propertyField, CILTypeBase propertyType, CompositeMethodGenerationInfo methodGenInfo, Action <CILField, MethodIL> readAction ) { // Code for getting properties: // public <property type> Property<idx>Getter( ) // { // CompositeInstance instance = this._instance; // <check application active> // var result = <read property field>; // <check constraints> // return result; // } var il = methodGenInfo.IL; il.EmitLoadThisField(thisGenerationInfo.CompositeField) .EmitStoreLocal(methodGenInfo.GetOrCreateLocal(LB_C_INSTANCE, codeGenerationInfo.CompositeInstanceFieldType.NewWrapper(this.ctx))); this.EmitThrowIfApplicationNotActive(methodGenInfo); var resultB = methodGenInfo.GetOrCreateLocal(LB_RESULT, methodGenInfo.ReturnType); readAction(propertyField, il); il.EmitStoreLocal(resultB); this.EmitProcessParameters(codeGenerationInfo, propertyModel.GetterMethod, false, publicCompositeGenInfo, thisGenerationInfo, methodGenInfo); this.EmitProcessResult(codeGenerationInfo, propertyModel.GetterMethod, publicCompositeGenInfo, thisGenerationInfo, methodGenInfo); this.EmitThrowIfViolations(thisGenerationInfo, methodGenInfo, propertyModel.GetterMethod); il.EmitLoadLocal(resultB) .EmitReturn(); }
protected virtual void EmitPropertyExchangeMethod( PropertyModel propertyModel, CompositeTypeGenerationInfo thisGenerationInfo, CILField propertyField, CILTypeBase fieldType, CILTypeBase propertyType, CILMethod propertySetter, CompositeMethodGenerationInfo methodGenInfo, Action <CILField, MethodIL> exchangeAction ) { var il = methodGenInfo.IL; this.EmitThrowIfApplicationNotActiveWithoutLocalVariable(thisGenerationInfo, il); this.EmitCheckPropertyImmutability(propertyModel, thisGenerationInfo, il); exchangeAction(propertyField, il); il .EmitCastToType(fieldType, propertyType) .EmitReturn(); }
private PropertyModel GetProperty(PropertyInfo propertyInfo) { var model = new PropertyModel(propertyInfo) { HeaderAttribute = Get <HeaderAttribute>(), PathAttribute = Get <PathAttribute>(), QueryAttribute = Get <QueryAttribute>(), HttpRequestMessagePropertyAttribute = Get <HttpRequestMessagePropertyAttribute>(), IsRequester = propertyInfo.PropertyType == typeof(IRequester), HasGetter = propertyInfo.CanRead, HasSetter = propertyInfo.CanWrite, }; return(model); AttributeModel <T>?Get <T>() where T : Attribute { var attribute = propertyInfo.GetCustomAttribute <T>(); return(attribute == null ? null : AttributeModel.Create(attribute, propertyInfo)); } }
public void LoadProperty(string propertyId, Action <PropertyModel> cb = null) { var queryString = "SELECT * FROM property_data WHERE PropertyID = @id"; MySQL.execute(queryString, new Dictionary <string, dynamic> { { "@id", propertyId } }, new Action <List <dynamic> >(propertyData => { PropertyModel property = null; if (propertyData.ElementAtOrDefault(0) != null) { property = databaseDataToProperty(propertyData[0]); Log.Verbose($"Loaded property {property.PropertyId} from the database"); AddProperty(property); } cb?.Invoke(property); })); }
private static PropertyModel GeneratePropertyModel(BaseParam param, bool isQueryParam) { PropertyModel result = new PropertyModel { Comment = param.Description }; result.Attributes.Add($"RequestParameter(\"{param.Name}\")"); string type; switch (param.Type) { case "integer": type = "long"; break; case "string": type = "string"; break; case "array": type = "string[]"; break; case "boolean": type = "bool"; break; default: throw new NotImplementedException(); } result.Type = type; result.IsNullable = param.Required; result.Name = param.Name.CleanForCode(); return(result); }
public void GetMetadataForPropertiesContainerTest() { // Arrange PropertyModel model = new PropertyModel { LocalAttributes = 42, MetadataAttributes = "hello", MixedAttributes = 21.12 }; EmptyModelMetadataProvider provider = new EmptyModelMetadataProvider(); // Act List <ModelMetadata> metadata = provider .GetMetadataForProperties(model, typeof(PropertyModel)) .ToList(); // Assert Assert.Equal(3, metadata.Count()); Assert.Same(model, metadata[0].Container); Assert.Same(model, metadata[1].Container); Assert.Same(model, metadata[2].Container); }
/// <summary> /// set value /// </summary> /// <param name="model"></param> /// <param name="dynSet"></param> /// <param name="dr"></param> /// <param name="info"></param> /// <param name="config"></param> /// <returns></returns> private static Object SetValue(Object item, DbDataReader dr, PropertyModel info, ConfigModel config) { try { var colName = config.DbType == DataDbType.Oracle ? info.Name.ToUpper() : info.Name; var id = dr.GetOrdinal(colName); if (DataDbType.Oracle == config.DbType) { ReadOracle(item, dr, id, info); } else if (!dr.IsDBNull(id)) { BaseEmit.Set(item, info.Name, dr.GetValue(id)); } return(item); } catch { return(item); } }
public static string GetUniqueFieldName(this TypeModel typeModel, PropertyModel propertyModel) { var propBackingFieldName = propertyModel.Name.ToBackingField(); var classModel = typeModel as ClassModel; if (classModel == null) { return(propBackingFieldName); } var i = 0; foreach (var prop in classModel.Properties) { if (!classModel.EnableDataBinding && !(prop.Type is SimpleModel)) { continue; } if (propertyModel == prop) { i += 1; break; } var backingFieldName = prop.Name.ToBackingField(); if (backingFieldName == propBackingFieldName) { i += 1; } } if (i <= 1) { return(propBackingFieldName); } return(string.Format("{0}{1}", propBackingFieldName, i)); }
public async Task AddProperty(PropertyModel model) { // New instance of Property Entity var property = new Property { Id = Guid.NewGuid().ToString(), Title = model.Title, ImageUrl = model.ImageUrl, Price = model.Price, Description = model.Description, NumberOfRooms = model.NumberOfRooms, NumberOfBaths = model.NumberOfBaths, NumberOfToilets = model.NumberOfToilets, Address = model.Address, ContactPhoneNumber = model.ContactPhoneNumber }; // Save to DB await _dbContext.AddAsync(property); await _dbContext.SaveChangesAsync(); }
public void RemovePropertyTenant(PropertyModel property, int tenantId, bool silent = false) { MySQL.execute("DELETE FROM property_tenants WHERE PropertyID = @id AND TenantCharacterID = @charid", new Dictionary <string, dynamic> { { "@id", property.PropertyId }, { "@charid", tenantId } }, new Action <dynamic>(rows => { Log.Info($"Successfully removed character id {tenantId} as a tenant of property {property.PropertyId}"); var ownerSession = Sessions.GetPlayerByCharID(property.OwnerCharacterId); var tenantSession = Sessions.GetPlayerByCharID(tenantId); if (!silent) { ownerSession.Message("[Property]", $"You just revoked {(tenantSession == null ? tenantId.ToString() : tenantSession.FirstName + " " + tenantSession.LastName)} persistent access to this property"); tenantSession?.Message("[Property]", $"Your keys for {property.Address} were just taken off you"); } if (property.PropertyCharacterAccess.Contains(tenantId)) { property.PropertyCharacterAccess.Remove(tenantId); } if (property.TemporaryCharacterAccess.Contains(tenantId)) { property.TemporaryCharacterAccess.Remove(tenantId); } MySQL.execute("UPDATE vehicle_data SET Garage = 'Public1' WHERE Garage = ? AND CharID = ?", new List <dynamic> { $"home-{property.PropertyId}", tenantId }, new Action <dynamic>(data => { Log.Verbose($"Reset garages for vehicles in property {property.PropertyId} to Public1 due to the property being deleted"); })); property.DesyncPropertyForPlayer(tenantId); property.ResyncProperty(); })); }
public async Task <ActionResult> Update(PropertyViewModel viewModel, List <HttpPostedFileBase> upload) { List <PropertyImageModel> list = new List <PropertyImageModel>(); foreach (var m in upload) { var imageModel = new PropertyImageModel { filePath = "~/UploadedFiles/" + m.FileName }; var InputFileName = Path.GetFileName(m.FileName); var ServerSavePath = Path.Combine(Server.MapPath("~/UploadedFiles/") + InputFileName); //Save file to server folder m.SaveAs(ServerSavePath); list.Add(imageModel); } PropertyModel model = new PropertyModel { Address = viewModel.Address, Amenities = viewModel.Amenities, City = viewModel.City, Details = viewModel.Details, PropertyName = viewModel.PropertyName, University = viewModel.University, State = viewModel.State, LastChanged = DateTime.Now, Id = viewModel.Id, Images = list }; string errorMessage = await _updateProperty.Update(model); return(RedirectToAction("GetAllProperty")); //return PartialView("_UpdateUserProperty"); }
/// <summary> /// Creates a <see cref="PropertyModel"/> for the given <see cref="PropertyInfo"/>. /// </summary> /// <param name="propertyInfo">The <see cref="PropertyInfo"/>.</param> /// <returns>A <see cref="PropertyModel"/> for the given <see cref="PropertyInfo"/>.</returns> protected virtual PropertyModel CreatePropertyModel(PropertyInfo propertyInfo) { if (propertyInfo == null) { throw new ArgumentNullException(nameof(propertyInfo)); } var attributes = propertyInfo.GetCustomAttributes(inherit: true); // BindingInfo for properties can be either specified by decorating the property with binding specific attributes. // ModelMetadata also adds information from the property's type and any configured IBindingMetadataProvider. var modelMetadata = _modelMetadataProvider.GetMetadataForProperty(propertyInfo.DeclaringType, propertyInfo.Name); var bindingInfo = BindingInfo.GetBindingInfo(attributes, modelMetadata); if (bindingInfo == null) { // Look for BindPropertiesAttribute on the handler type if no BindingInfo was inferred for the property. // This allows a user to enable model binding on properties by decorating the controller type with BindPropertiesAttribute. var declaringType = propertyInfo.DeclaringType; var bindPropertiesAttribute = declaringType.GetCustomAttribute <BindPropertiesAttribute>(inherit: true); if (bindPropertiesAttribute != null) { var requestPredicate = bindPropertiesAttribute.SupportsGet ? _supportsAllRequests : _supportsNonGetRequests; bindingInfo = new BindingInfo { RequestPredicate = requestPredicate, }; } } var propertyModel = new PropertyModel(propertyInfo, attributes) { PropertyName = propertyInfo.Name, BindingInfo = bindingInfo, }; return(propertyModel); }
public static List <PropertyModel> GetPropertyInfo(object model, bool IsCache = true) { var config = DataConfig.Get(); var list = new List <PropertyModel>(); var key = string.Format("{0}.{1}", model.GetType().Namespace, model.GetType().Name); if (IsCache) { if (DbCache.Exists(config.CacheType, key)) { return(DbCache.Get <List <PropertyModel> >(config.CacheType, key)); } else { model.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).ToList().ForEach(a => { var temp = new PropertyModel(); temp.Name = a.Name; temp.PropertyType = a.PropertyType; list.Add(temp); }); DbCache.Set <List <PropertyModel> >(config.CacheType, key, list); } } else { model.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).ToList().ForEach(a => { var temp = new PropertyModel(); temp.Name = a.Name; temp.PropertyType = a.PropertyType; list.Add(temp); }); } return(list); }
public void DeleteProperty(PropertyModel property) { Log.Verbose($"Deleting property {property.PropertyId}"); property.DesyncProperty(); property.OwnerCharacterId = -1; property.PropertyCharacterAccess.Clear(); property.TemporaryCharacterAccess.Clear(); MySQL.execute("DELETE FROM property_data WHERE PropertyID = ?", new List <string> { property.PropertyId }, new Action <dynamic>(data => { Log.Verbose($"Removed property {property.PropertyId} from property_data"); })); MySQL.execute("DELETE FROM property_finance WHERE PropertyID = ?", new List <string> { property.PropertyId }, new Action <dynamic>(data => { Log.Verbose($"Removed property {property.PropertyId} from property_finance"); })); MySQL.execute("DELETE FROM property_tenants WHERE PropertyID = ?", new List <string> { property.PropertyId }, new Action <dynamic>(data => { Log.Verbose($"Removed property {property.PropertyId} from property_tenants"); })); MySQL.execute("UPDATE vehicle_data SET Garage = 'Public1' WHERE Garage = ?", new List <string> { $"home-{property.PropertyId}" }, new Action <dynamic>(data => { Log.Verbose($"Reset garages for vehicles in property {property.PropertyId} to Public1 due to the property being deleted"); })); RemoveProperty(property); }
public async Task <IActionResult> Add(PropertyModel model) { // throw new NotImplementedException(); // Validate model if (!ModelState.IsValid) { return(View()); } try { await _propertyService.AddProperty(model); return(RedirectToAction(nameof(Index))); } catch (Exception e) { // Return an error message to accounts page ModelState.AddModelError("", e.Message); return(RedirectToAction(nameof(Index))); } }
/// <summary> /// add new property /// </summary> /// <param name="property"></param> /// <returns></returns> public Result <int> SaveProperty(PropertyModel property) { var response = new Result <int>(); try { dbModel.spAddProperty(property.PropertyID, property.PropertyName , property.Address , property.City , property.State , property.Zip , property.OwnerName , property.UserID); response.Success = true; } catch (Exception ex) { response.Message = ex.Message; response.Success = false; } return(response); }
private PropertyModel GetProperty(IPropertySymbol propertySymbol) { var attributes = this.attributeInstantiator.Instantiate(propertySymbol, this.diagnosticReporter).ToList(); var model = new PropertyModel(propertySymbol) { HeaderAttribute = Get <HeaderAttribute>(), PathAttribute = Get <PathAttribute>(), QueryAttribute = Get <QueryAttribute>(), HttpRequestMessagePropertyAttribute = Get <HttpRequestMessagePropertyAttribute>(), IsRequester = SymbolEqualityComparer.Default.Equals(propertySymbol.Type, this.wellKnownSymbols.IRequester), HasGetter = propertySymbol.GetMethod != null, HasSetter = propertySymbol.SetMethod != null, }; return(model); AttributeModel <T>?Get <T>() where T : Attribute { var(attribute, attributeData, type) = attributes.FirstOrDefault(x => x.attribute is T); return(attribute == null ? null : AttributeModel.Create((T)attribute, attributeData, type)); } }
private void OnSpinChanged(PropertyChangedFromTextBoxEventArgs property) { PropertyModel p = property.Property; TextWorldControl c = (TextWorldControl)property.PrintControl; int flag = (int)p.Value; RotateTransform r = (RotateTransform)c.RenderTransform; if (r != null) { if (flag < 5) { r.CenterX = 0; r.CenterY = c.Height / 2; r.Angle = (flag - 1) * 90; } else { r.CenterX = c.Width / 2; r.CenterY = c.Height / 2; r.Angle = (flag - 5) * 90; } } }
public bool CreateProperty(int ownerId, PropertyModel property, IEnumerable <int> features) { var propDb = new Property { Address = property.Address, Bathrooms = property.Bathrooms, Bedrooms = property.Bedrooms, Description = property.Description, OwnerId = ownerId, PropertyStatusId = property.PropertyStatusId, Size = property.Size }; if (features.Any()) { propDb.Features = this.Entities.Features.Where(f => features.Contains(f.FeatureId)).ToList(); } this.Entities.Properties.Add(propDb); this.Entities.SaveChanges(); return(true); }
/// <summary> /// CheckBox /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void ckCheckBox_Checked(object sender, RoutedEventArgs e) { CheckBox tb = sender as CheckBox; if (tb == null) { return; } PropertyModel p = tb.Tag as PropertyModel; if (p == null) { return; } if (tb.IsChecked == true) { p.Value = 1; } else { p.Value = 0; } }
private void DealWithSpecialPrintControl(ContentControlBase c, PropertyModel p, TextBox textBox = null) { if (p.Name == "pX") { Canvas.SetLeft(c, (double)Convert.ChangeType(p.Value, typeof(double))); return; } if (p.Name == "pY") { Canvas.SetTop(c, (double)Convert.ChangeType(p.Value, typeof(double))); return; } if (p.PropertyChanged != null) { PropertyChangedFromTextBoxEventArgs proerty = new PropertyChangedFromTextBoxEventArgs() { PrintControl = c, TextBox = textBox, Property = p }; p.PropertyChanged(proerty); } }
private void AddTextProperty() { var obj = TextProperty; if (obj == null) { obj = TextProperty = new TextBox(); obj.Style = TC.TextPropertyStyle; obj.KeyDown += TC.TextProperty_KeyDown; obj.LostFocus += TC.TextProperty_LostFocus; obj.GotFocus += TC.TextProperty_GotFocus; obj.DataContext = this; } var txt = PropertyModel.GetTextValue(TC.TCM.Root); obj.Text = txt ?? string.Empty; obj.Tag = obj.Text; obj.IsReadOnly = (Model is PropertyModel pm) && pm.IsReadOnly; StackPanel.Children.Add(obj); }
/// <summary> ///添加属性数据 /// </summary> /// <param name="property"></param> /// <returns></returns> public bool InsertProperty(PropertyModel property) { StringBuilder strInsertSql = new StringBuilder(); strInsertSql.Append(" INSERT INTO PROPERTY( "); strInsertSql.Append(" BOID,GATHERID,NS,MD,MDSOURCE)"); strInsertSql.Append(" VALUES (:BOID,:GATHERID,:NS,:MD,:MDSOURCE)"); OracleParameter[] parameters = { new OracleParameter("BOID", OracleDbType.Varchar2, 36), new OracleParameter("GATHERID", OracleDbType.Varchar2, 50), new OracleParameter("NS", OracleDbType.Varchar2, 50), new OracleParameter("MD", OracleDbType.XmlType), new OracleParameter("MDSOURCE", OracleDbType.Varchar2, 50) }; parameters[0].Value = property.BOID; parameters[1].Value = property.GATHERID; parameters[2].Value = property.NS; parameters[2].Value = property.MD; parameters[4].Value = property.MDSOURCE; return(OracleDBHelper.OracleHelper.ExecuteSql(strInsertSql.ToString(), parameters) > 0 ? true : false); }
/// <summary> /// 修改属性数据 /// </summary> /// <param name="property"></param> /// <returns></returns> public bool UpdateProperty(PropertyModel property) { StringBuilder strUpdateSql = new StringBuilder(); strUpdateSql.Append(" UPDATE PROPERTY SET "); strUpdateSql.Append(" GATHERID=@GATHERID, MD=@MD ,MDSOURCE=@MDSOURCE "); strUpdateSql.Append(" WHERE BOID=@BOID AND NS=@NS"); SqlParameter[] parameters = { new SqlParameter("GATHERID", SqlDbType.VarChar, 36), new SqlParameter("MD", SqlDbType.Xml), new SqlParameter("MDSOURCE", SqlDbType.VarChar, 50), new SqlParameter("BOID", SqlDbType.VarChar, 36), new SqlParameter("NS", SqlDbType.VarChar, 50) }; parameters[0].Value = property.GATHERID; parameters[1].Value = property.MD; parameters[2].Value = property.MDSOURCE; parameters[3].Value = property.BOID; parameters[4].Value = property.NS; return(DBUtility.SqlServerDBHelper.ExecuteCommand(strUpdateSql.ToString(), parameters) > 0 ? true : false); }
public async Task <ActionResult> DeleteProperty(PropertyModel model) { if (!_permissionService.IsAllowed(new ActionRequestInfo(HttpContext, _implementations, null, ActionTypeEnum.ManageMetadata))) { return(Unauthorized()); } var validationMessage = await MetadataValidationLogic.DeletePropertyValidation(model, _dbContext); if (!string.IsNullOrEmpty(validationMessage)) { return(StatusCode(400, validationMessage)); } var property = await _dbContext.Properties.FindAsync(model.Id); var localFacets = await _dbContext.PropertyFacetValues.Where(x => x.PropertyId == model.Id).ToListAsync(); _dbContext.PropertyFacetValues.RemoveRange(localFacets); _dbContext.Properties.Remove(property); await _dbContext.SaveChangesAsync(); ((RequestLogModel)HttpContext.Items["RequestLog"]).PropertyId = property.Id; return(Ok()); }
/// <summary> ///添加属性数据 /// </summary> /// <param name="property"></param> /// <returns></returns> public bool InsertProperty(PropertyModel property) { StringBuilder strInsertSql = new StringBuilder(); strInsertSql.Append(" INSERT INTO PROPERTY( "); strInsertSql.Append(" BOID,GATHERID,NS,MD,MDSOURCE)"); strInsertSql.Append(" VALUES (@BOID,@GATHERID,@NS,@MD,@MDSOURCE)"); SqlParameter[] parameters = { new SqlParameter("BOID", SqlDbType.VarChar, 36), new SqlParameter("GATHERID", SqlDbType.VarChar, 50), new SqlParameter("NS", SqlDbType.VarChar, 50), new SqlParameter("MD", SqlDbType.Xml), new SqlParameter("MDSOURCE", SqlDbType.VarChar, 50) }; parameters[0].Value = property.BOID; parameters[1].Value = property.GATHERID; parameters[2].Value = property.NS; parameters[2].Value = property.MD; parameters[4].Value = property.MDSOURCE; return(DBUtility.SqlServerDBHelper.ExecuteCommand(strInsertSql.ToString(), parameters) > 0 ? true : false); }
public void SetUp() { doc = new ProjectModel(); project = new PropertyModel(doc); doc.CreateNewProject(); }
private void LoadCollection() { // Setup initial conditions. if (SelectedObject == null) return; var list = new List<CategoryProperties>(); // Load new categories. foreach (var propInfo in GetPropertiesInternal()) { var propertyModel = new PropertyModel(SelectedObject, propInfo); var category = GetCategoryProperties(propertyModel, list); category.Properties.Add(propertyModel); } // Update the collection. ClearCollection(); if (list.Count == 1) { singleCategoryProperties.AddRange(list[0].Properties); } else { Categories.AddRange(list.OrderBy(item => item.CategoryName)); } }
private CategoryProperties GetCategoryProperties(PropertyModel property, ICollection<CategoryProperties> list) { // Setup initial conditions. var categoryName = GetCategory(property); if (categoryName == null) categoryName = LabelMiscellaneous; // Retrieve the category object if it exists, and if not found create it. var category = list.FirstOrDefault(item => item.CategoryName == categoryName); if (category == null) { category = new CategoryProperties {CategoryName = categoryName}; list.Add(category); } // Finish up. return category; }
private bool IsDeclaredOn(PropertyModel property) { return declaredPropertiesOnSelectedObject.FirstOrDefault(item => item.Name == property.Definition.Name) != null; }
public StringEditorViewModel(PropertyModel model) : base(model) { UpdateOnKeyPress = false; }
public PropertyInstance(CompositePropertyInfo info, object initialValue, PropertyModel model) { this.info = info; this.Value = initialValue; this.model = model; }
public void Initialize() { ProjectModel doc = new ProjectModel(); doc.LoadXml(NUnitProjectXml.NormalProject); model = new PropertyModel(doc); view = Substitute.For<IConfigurationEditorDialog>(); editor = new ConfigurationEditor(model, view); }
public StreamEditorViewModel(PropertyModel model) : base(model) { }
public void SetUp() { doc = new ProjectModel(xmlfile); project = new PropertyModel(doc); }
/// <summary>Создаёт модель представления свойства для указанной модели свойства</summary> /// <param name="PropertyModel">Модель свойства, для которой требуется создать модель представления</param> public PropertyViewModel GetViewModel(PropertyModel PropertyModel) { return new PropertyViewModel(PropertyModel, _propertyValuesViewModelFactory); }
/// <summary> /// Creates the property model. /// </summary> /// <param name="priority">The priority.</param> /// <param name="property">The property.</param> /// <param name="value">The value.</param> /// <param name="item">The item.</param> /// <returns>PropertyModel.</returns> /// <exception cref="System.ArgumentNullException">property</exception> public static PropertyModel CreatePropertyModel(int priority, Property property, PropertyValueBase value, StorageEntity item) { if (property == null) { throw new ArgumentNullException("property"); } var model = new PropertyModel { Priority = priority }; model.InjectFrom<CloneInjection>(property); model.Values = new[] { CreatePropertyValueModel(value, property) }; model.CatalogItem = item; return model; }
public PropertyValuesViewModel GetViewModel(PropertyModel Property) { throw new Exception("Предполагалось, что этот метод никогда не будет вызван"); }
public PropertyAddedEventArgs(PropertyModel Property) { this.Property = Property; }
private string GetCategory(PropertyModel property) { if (SelectedObject == null || !SelectedObject.GetType().IsA(typeof(UIElement))) { return PropertyGridViewModel.GetCategoryDefault(property); } else { if (CommonControlProperties.Contains(property.Definition.Name)) return "Common"; if (IsDeclaredOn(property)) return string.Format("Declared on '{0}'", SelectedObject.GetType().Name); return "Misc"; } }
public ColorEditorViewModel(PropertyModel model) : base(model) { }
public void SetUp() { doc = new ProjectModel(); doc.CreateNewProject(); project = new PropertyModel(doc); doc.Changed += OnProjectChange; gotChangeNotice = false; }
public PropMapping(PropertyModel property, LambdaExpression expression) { Property = property; Expression = expression; }