public override void Initialize(PropertiesModel.Property property) { base.Initialize(property); m_info = property.EditorAdditionalData<CurveInfo>(); if (m_info != null && m_info.Curves != null && m_info.Curves.Length > 0) { PlayCanvas.CurveSet curveSet = PropertyModel.Data<PlayCanvas.CurveSet>(); if (curveSet == null) curveSet = new PlayCanvas.CurveSet(); if (curveSet.CurvesList.Count < m_info.Curves.Length) for (int i = curveSet.CurvesList.Count; i < m_info.Curves.Length; ++i) curveSet.CurvesList.Add(new PlayCanvas.Curve(new float[] { 0.0f, 0.0f })); PropertyModel.Data<PlayCanvas.CurveSet>(curveSet); } m_curvePictureBox = new PictureBox(); m_curvePictureBox.Cursor = Cursors.Hand; m_curvePictureBox.Width = 0; m_curvePictureBox.Height = 48; m_curvePictureBox.BackColor = Color.FromArgb(255, 64, 64, 64); m_curvePictureBox.Dock = DockStyle.Top; m_curvePictureBox.Click += m_curvePictureBox_Click; m_curvePictureBox.Resize += m_curvePictureBox_Resize; m_curvePictureBox.Paint += m_curvePictureBox_Paint; Content.Controls.Add(m_curvePictureBox); UpdateEditor(); }
public async Task OnPostAsync_InvalidModel() { // Arrange var databaseName = $"{DatabaseNamePrefix}.{nameof(OnPostAsync)}"; var options = new DbContextOptionsBuilder <OidcDbContext>() .UseInMemoryDatabase(databaseName) .Options; IActionResult post; var client = new Client { Id = Random.Next() }; using (var context = new OidcDbContext(options)) { context.Add(client); await context.SaveChangesAsync().ConfigureAwait(false); } // Act using (var context = new OidcDbContext(options)) { var properties = new PropertiesModel(context) { Client = new Client { Id = Random.Next() } }; post = await properties.OnPostAsync().ConfigureAwait(false); } // Assert Assert.IsType <PageResult>(post); }
public void TestCreateProperties() { //Arrange manager.DatabaseConnection(); property.SetDatabase(manager.GetDatabase()); KeyId.SetKey(); //Gerar uma chave única; string id = KeyId.GetKey(); //Obter a chave única gerada automaticamente; PropertiesModel model1 = new PropertiesModel() { ID = id, Size = 40, Value = "80", Maxlength = 50, Required = false }; //PropertiesModel model2 = null; //Se não existir um modelo de dados //Act string result = property.CreateProperties(model1); if (Convert.ToInt32(result) == 201) { Assert.Pass("Result: Properties Model with id = " + id + ", was created with success"); } if (Convert.ToInt32(result) == 400) { Assert.Pass("Result: Properties Model with id = " + id + ", was not created"); } Assert.Fail(); }
public override void Initialize(PropertiesModel.Property property) { base.Initialize(property); Resize += PlayCanvas_Vector_PropertyEditor_Resize; m_xTextBox = new MetroTextBox(); MetroSkinManager.ApplyMetroStyle(m_xTextBox); m_xTextBox.Width = 0; m_xTextBox.TextChanged += m_xTextBox_TextChanged; m_xTextBox.CustomPaintForeground += m_xTextBox_CustomPaintForeground; m_xTextBox.Leave += m_textBox_Leave; Content.Controls.Add(m_xTextBox); m_yTextBox = new MetroTextBox(); MetroSkinManager.ApplyMetroStyle(m_yTextBox); m_yTextBox.Width = 0; m_yTextBox.TextChanged += m_yTextBox_TextChanged; m_yTextBox.CustomPaintForeground += m_yTextBox_CustomPaintForeground; m_yTextBox.Leave += m_textBox_Leave; Content.Controls.Add(m_yTextBox); m_zTextBox = new MetroTextBox(); MetroSkinManager.ApplyMetroStyle(m_zTextBox); m_zTextBox.Width = 0; m_zTextBox.TextChanged += m_zTextBox_TextChanged; m_zTextBox.CustomPaintForeground += m_zTextBox_CustomPaintForeground; m_zTextBox.Leave += m_textBox_Leave; Content.Controls.Add(m_zTextBox); UpdateEditor(); m_xTextBox.Refresh(); m_yTextBox.Refresh(); m_zTextBox.Refresh(); }
public ActionResult SaveEmployeesDevelopmentAudit(ICollection <string> EmployeesDevelopment) { //Save Exteriors Audit Data here. //Need to check current user and Hotel ID to save for. int userID = Int32.Parse(Session["UserID"].ToString()); PropertiesModel properties = new PropertiesModel(); var res = properties.Properties.Where(a => a.UserId.Equals(userID)).FirstOrDefault(); var hotelID = res.Id; if (EmployeesDevelopment != null && EmployeesDevelopment.Count != 0) { var json = JsonConvert.SerializeObject(EmployeesDevelopment); var auditor = new AuditsModel(); var check = auditor.Audits.Where(a => a.PropertyId.Equals(hotelID)).FirstOrDefault(); if (check != null) { check.HotelEmployeesDevelopment = json; auditor.SaveChanges(); return(RedirectToAction("AuditReport", "Hotel", new { area = "" })); } else { Audit auditObject = new Audit(); auditObject.PropertyId = hotelID; auditObject.HotelEmployeesDevelopment = json; auditor.Audits.Add(auditObject); auditor.SaveChanges(); return(RedirectToAction("AuditReport", "Hotel", new { area = "" })); } } return(RedirectToAction("AuditReport", "Hotel", new { area = "" })); }
public ActionResult EmployeesDevelopment(int PropertyId) { PropertiesModel properties = new PropertiesModel(); var res = properties.Properties.Where(a => a.Id.Equals(PropertyId)).FirstOrDefault(); if (res != null) { var PID = res.Id; var auditor = new AuditsModel(); var result = auditor.Audits.Where(a => a.PropertyId.Equals(PID)).FirstOrDefault(); if (result != null) { var answersJson = result.AtddEmployeesDevelopment; if (answersJson.ToString().Equals("")) { ViewBag.Answers = new List <string>(); } else { List <string> ansArray = JsonConvert.DeserializeObject <List <string> >(answersJson); ViewBag.Answers = ansArray; } } else { ViewBag.Answers = new List <string>(); } } ViewBag.PropertyId = PropertyId; return(View("~/Views/HotelAudit/EmployeesDevelopment.cshtml")); }
internal PropertiesModel CastStockData(PropertiesObject blobData) { try { PropertiesModel property = new PropertiesModel { Id = blobData.Id, YearBuilt = blobData.Physical.YearBuilt, ListPrice = blobData.Financial != null?string.Format("{0:F2}", blobData.Financial.ListPrice) : "0", MonthlyRent = blobData.Financial != null?string.Format("{0:F2}", blobData.Financial.MonthlyRent) : "0", GrossYield = string.Format("{0:F2}", (blobData.Financial != null ? Convert.ToDecimal(blobData.Financial.MonthlyRent) : 0 * 12) / (blobData.Financial != null ? Convert.ToDecimal(blobData.Financial.ListPrice) : 1)), MainImageUrl = blobData.MainImageUrl, Address1 = blobData.Address.Address1, Address2 = blobData.Address.Address2, City = blobData.Address.City, Country = blobData.Address.Country, County = blobData.Address.County, District = blobData.Address.District, State = blobData.Address.State, ZipCode = blobData.Address.ZipCode, ZipPlusFour = blobData.Address.ZipPlusFour, Resources = blobData.Resources, Bathrooms = blobData.Physical.Bathrooms, BedRooms = blobData.Physical.BedRooms, squareFeet = blobData.Physical.squareFeet }; return(property); } catch (Exception ex) { _logger.Error($"An error has occured casting the properties {ex.Message}", ex); throw; } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Description,ShortDescription,Image,CategoryId")] PropertiesModel propertiesModel, IFormFile imageFile) { if (id != propertiesModel.Id) { return(NotFound()); } if (imageFile != null) { propertiesModel.Image = ImageHelper.AddImage(_appEnvironment, imageFile); } if (ModelState.IsValid) { try { _context.Update(propertiesModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PropertiesModelExists(propertiesModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Title", propertiesModel.CategoryId); return(View(propertiesModel)); }
public async Task OnPostAsync_InvalidModel() { // Arrange var databaseName = $"{DatabaseNamePrefix}.{nameof(OnPostAsync)}"; var options = new DbContextOptionsBuilder <IdentityServerDbContext>() .UseInMemoryDatabase(databaseName) .Options; IActionResult post; var identityResource = new IdentityResource { Id = Random.Next() }; using (var context = new IdentityServerDbContext(options, _configurationStoreOptions.Object, _operationalStoreOptions.Object)) { context.Add(identityResource); await context.SaveChangesAsync().ConfigureAwait(false); } // Act using (var context = new IdentityServerDbContext(options, _configurationStoreOptions.Object, _operationalStoreOptions.Object)) { var properties = new PropertiesModel(context) { IdentityResource = new IdentityResource { Id = Random.Next() } }; post = await properties.OnPostAsync().ConfigureAwait(false); } // Assert Assert.IsType <PageResult>(post); }
public async Task OnPostAsync_AllRemoved() { // Arrange var databaseName = $"{DatabaseNamePrefix}.{nameof(OnPostAsync_AllRemoved)}"; var options = new DbContextOptionsBuilder <IdentityServerDbContext>() .UseInMemoryDatabase(databaseName) .Options; PropertiesModel properties; IActionResult post; var identityResourceId = Random.Next(); var identityResource = new IdentityResource { Id = identityResourceId, Properties = new List <IdentityResourceProperty> { new IdentityResourceProperty { Id = Random.Next() } } }; using (var context = new IdentityServerDbContext(options, _configurationStoreOptions.Object, _operationalStoreOptions.Object)) { context.Add(identityResource); await context.SaveChangesAsync().ConfigureAwait(false); } // Act using (var context = new IdentityServerDbContext(options, _configurationStoreOptions.Object, _operationalStoreOptions.Object)) { properties = new PropertiesModel(context) { IdentityResource = new IdentityResource { Id = identityResourceId } }; post = await properties.OnPostAsync().ConfigureAwait(false); } // Assert using (var context = new IdentityServerDbContext(options, _configurationStoreOptions.Object, _operationalStoreOptions.Object)) { identityResource = await context.IdentityResources .Include(x => x.Properties) .SingleOrDefaultAsync(x => x.Id.Equals(identityResourceId)) .ConfigureAwait(false); Assert.Empty(identityResource.Properties); } var result = Assert.IsType <RedirectToPageResult>(post); Assert.Equal("../Details/Properties", result.PageName); Assert.Collection(result.RouteValues, routeValue => { var(key, value) = routeValue; Assert.Equal(nameof(IdentityResource.Id), key); Assert.Equal(properties.IdentityResource.Id, value); }); }
public async Task OnPostAsync_AllRemoved() { // Arrange var databaseName = $"{DatabaseNamePrefix}.{nameof(OnPostAsync_AllRemoved)}"; var options = new DbContextOptionsBuilder <OidcDbContext>() .UseInMemoryDatabase(databaseName) .Options; PropertiesModel properties; IActionResult post; var client = new Client { Id = Random.Next(), Properties = new List <ClientProperty> { new ClientProperty { Id = Random.Next() } } }; using (var context = new OidcDbContext(options)) { context.Add(client); await context.SaveChangesAsync().ConfigureAwait(false); } // Act using (var context = new OidcDbContext(options)) { properties = new PropertiesModel(context) { Client = new Client { Id = client.Id } }; post = await properties.OnPostAsync().ConfigureAwait(false); } // Assert using (var context = new OidcDbContext(options)) { client = await context.Clients .Include(x => x.Properties) .SingleOrDefaultAsync(x => x.Id.Equals(client.Id)) .ConfigureAwait(false); Assert.Empty(client.Properties); } var result = Assert.IsType <RedirectToPageResult>(post); Assert.Equal("../Details/Properties", result.PageName); Assert.Collection(result.RouteValues, routeValue => { var(key, value) = routeValue; Assert.Equal(nameof(Client.Id), key); Assert.Equal(properties.Client.Id, value); }); }
public JsonResult Index(int id) { var customer = this.customerRepository.Get(id); var builder = new PropertiesModelBuilder(this.context); PropertiesModel data = builder.Create(customer); return(Json(data, JsonRequestBehavior.AllowGet)); }
public IActionResult Properties(int id) { var api = _configurationDbContext.ApiResources .Include(x => x.Properties) .FirstOrDefault(x => x.Id == id); return(View(PropertiesModel.FromEntity(api))); }
public IActionResult Properties(int id) { var client = _configurationDbContext.Clients .Include(x => x.Properties) .FirstOrDefault(x => x.Id == id); return(View(PropertiesModel.FromEntity(client))); }
public ActionResult PropertyAudit() { PropertiesModel properties = new PropertiesModel(); List <Property> propertyList = properties.Properties.ToList(); ViewBag.Properties = propertyList; ViewBag.Current = "propertyaudit"; return(View()); }
public ActionResult Property() { int userID = Int32.Parse(Session["UserID"].ToString()); PropertiesModel properties = new PropertiesModel(); var res = properties.Properties.Where(a => a.UserId.Equals(userID)).FirstOrDefault(); ViewBag.Property = res; ViewBag.Current = "propertylisting"; return(View()); }
public string CreateProperties(PropertiesModel model) { if (model != null) { var collection = _Database.GetCollection <PropertiesModel>("Properties"); collection.InsertOneAsync(model); return(((int)StatusCode.Created).ToString()); } return(((int)StatusCode.BadRequest).ToString()); }
public void LoadTypeface(Font typeface, TypefaceModel model) { PropertiesModel propertiesModel = new PropertiesModel(); if (model != null) { propertiesModel.Name = model.TypefaceName; propertiesModel.Path = model.TypefaceFilePath; propertiesModel.TypefaceType = GetTypefaceType(model.TypefaceFilePath); } if (typeface != null) { try { string unit = GetUnitName(typeface.Unit); if (unit != null) { unit = " " + unit; } propertiesModel.Name = typeface.Name; propertiesModel.Bold = typeface.Bold; propertiesModel.Italic = typeface.Italic; propertiesModel.Underline = typeface.Underline; propertiesModel.Strikethrough = typeface.Strikeout; propertiesModel.Size = typeface.Size + unit; propertiesModel.LineHeight = typeface.Height + " px"; propertiesModel.Ascent = typeface.FontFamily.GetCellAscent(typeface.Style).ToString(); propertiesModel.Descent = typeface.FontFamily.GetCellDescent(typeface.Style).ToString(); propertiesModel.LineSpacing = typeface.FontFamily.GetLineSpacing(typeface.Style).ToString(); propertiesModel.EmHeight = typeface.FontFamily.GetEmHeight(typeface.Style).ToString(); } catch (Exception exc) { ExceptionHandler.CaptureException(exc); } } kpgTypefaceProperties.SelectedObject = propertiesModel; }
public void Update(PropertiesModel p) { PropertyId = p.PropertyId; AddressId = p.AddressId; PropertyName = p.PropertyName; SquareFeet = p.SquareFeet; NumberOfBathrooms = p.NumberOfBathrooms; NumberOfBedrooms = p.NumberOfBedrooms; NumberofVehicles = p.NumberofVehicles; Address.Update(p.Address); }
public async Task <ActionResult> Details(string propertiesId, string processName, string processVersion, string fieldType, string fieldName) { ViewBag.ProcessName = processName; ViewBag.ProcessVersion = processVersion; ViewBag.FieldName = fieldName; ViewBag.FieldType = fieldType; _Connection.DatabaseConnection(); _Properties.SetDatabase(_Connection.GetDatabase()); PropertiesModel propertiesModel = _Properties.GetProperties(propertiesId); return(await Task.Run(() => View("Details", propertiesModel))); }
public void EvaluateProperties() { var model = new PropertiesModel(); var type = model.GetType(); var xProperty = type.GetProperty("X"); var yProperty = type.GetProperty("Y"); var zProperty = type.GetProperty("Z"); var wProperty = type.GetProperty("W"); Assert.IsNotNull(xProperty); Assert.IsTrue(xProperty.CanRead); Assert.IsFalse(xProperty.CanWrite); Assert.IsNotNull(yProperty); Assert.IsTrue(yProperty.CanRead); Assert.IsTrue(yProperty.CanWrite); Assert.IsNotNull(zProperty); Assert.IsFalse(zProperty.CanRead); Assert.IsTrue(zProperty.CanWrite); Assert.IsNotNull(wProperty); Assert.IsTrue(wProperty.CanRead); Assert.IsTrue(wProperty.CanWrite); Assert.AreEqual(xProperty.GetValue(model), model.X); var xGetMethod = xProperty.GetGetMethod(); Assert.IsNotNull(xGetMethod); Assert.AreEqual((int)xGetMethod.Invoke(model, null), model.X); zProperty.SetValue(model, 20); Assert.AreEqual(model.GetZ(), 20); var zSetMethod = zProperty.GetSetMethod(); Assert.IsNotNull(zSetMethod); zSetMethod.Invoke(model, new object[] { 12 }); Assert.AreEqual(model.GetZ(), 12); wProperty.SetValue(model, 99); Assert.AreEqual(model.W, 99); var indexerProperty = type.GetProperty("Item"); Assert.IsNotNull(indexerProperty); Assert.IsTrue(indexerProperty.GetIndexParameters().Any()); Assert.AreEqual(model[64], indexerProperty.GetValue(model, new object[] { 64 })); }
public async Task OnGetAsync_InvalidId() { // Arrange var model = new PropertiesModel(new Mock <IConfigurationDbContext>().Object); // Act var get = await model.OnGetAsync(0).ConfigureAwait(false); // Assert Assert.Null(model.IdentityResource); Assert.Null(model.Properties); Assert.IsType <NotFoundResult>(get); }
public override void Initialize(PropertiesModel.Property property) { base.Initialize(property); m_textBox = new MetroTextBox(); MetroSkinManager.ApplyMetroStyle(m_textBox); m_textBox.Width = 0; m_textBox.Dock = DockStyle.Top; m_textBox.TextChanged += m_textBox_TextChanged; m_textBox.Leave += m_textBox_Leave; Content.Controls.Add(m_textBox); UpdateEditor(); }
public override void Initialize(PropertiesModel.Property property) { base.Initialize(property); m_toggle = new MetroToggle(); MetroSkinManager.ApplyMetroStyle(m_toggle); m_toggle.Cursor = Cursors.Hand; m_toggle.Width = 0; m_toggle.Dock = DockStyle.Top; m_toggle.CheckedChanged += m_toggle_CheckedChanged; Content.Controls.Add(m_toggle); UpdateEditor(); }
public override void Initialize(PropertiesModel.Property property) { base.Initialize(property); m_colorBox = new Panel(); m_colorBox.Cursor = Cursors.Hand; m_colorBox.Width = 0; m_colorBox.Height = 48; m_colorBox.Dock = DockStyle.Top; m_colorBox.Click += m_colorBox_Click; m_colorBox.Paint += m_colorBox_Paint; Content.Controls.Add(m_colorBox); UpdateEditor(); }
public async Task <IActionResult> Create([Bind("Id,Title,Description,ShortDescription,Image,CategoryId")] PropertiesModel propertiesModel, IFormFile imageFile) { if (imageFile != null) { propertiesModel.Image = ImageHelper.AddImage(_appEnvironment, imageFile); } if (ModelState.IsValid) { _context.Add(propertiesModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Title", propertiesModel.CategoryId); return(View(propertiesModel)); }
public IActionResult AddProperty(PropertiesModel model) { var client = _configurationDbContext.Clients .Include(x => x.Properties) .FirstOrDefault(x => x.Id == model.Client.Id); client.Properties.Add(new ClientProperty { Key = model.Key, Value = model.Value, }); _configurationDbContext.SaveChanges(); return(RedirectToAction(nameof(Properties), new { id = client.Id })); }
public IActionResult AddProperty(PropertiesModel model) { var api = _configurationDbContext.ApiResources .Include(x => x.Properties) .FirstOrDefault(x => x.Id == model.ApiResourceId); api.Properties.Add(new ApiResourceProperty { Key = model.Key, Value = model.Value, }); _configurationDbContext.SaveChanges(); return(RedirectToAction(nameof(Properties), new { id = api.Id })); }
public void TestGetProperties() { //Arrange manager.DatabaseConnection(); property.SetDatabase(manager.GetDatabase()); string propertyId = "5d6c0790213c2933d816595d"; //Act PropertiesModel model = property.GetProperties(propertyId); if (model != null) { string result = "Model id " + model.ID + " with Size = " + model.Size + ", Value = " + model.Value + ", Maxlength = " + model.Maxlength + ", and Required = " + model.Required; Assert.Pass("Result: " + result + ", Status Code: " + ((int)StatusCode.Ok).ToString() + " - " + StatusCode.Ok.ToString()); } Assert.Fail(); }
public override void Initialize(PropertiesModel.Property property) { base.Initialize(property); m_info = property.EditorAdditionalData<NumberInfo>(); m_textBox = new MetroTextBox(); MetroSkinManager.ApplyMetroStyle(m_textBox); m_textBox.Width = 0; m_textBox.Dock = DockStyle.Top; m_textBox.TextChanged += m_textBox_TextChanged; m_textBox.CustomPaintForeground += m_textBox_CustomPaintForeground; m_textBox.Leave += m_textBox_Leave; Content.Controls.Add(m_textBox); UpdateEditor(); m_textBox.Refresh(); }
public async Task OnPostAsync_InvalidId() { // Arrange var context = new Mock <IConfigurationDbContext>(); var properties = new PropertiesModel(context.Object) { IdentityResource = new IdentityResource { Id = 0 } }; // Act var post = await properties.OnPostAsync().ConfigureAwait(false); // Assert context.Verify(x => x.SaveChangesAsync(), Times.Never); Assert.IsType <PageResult>(post); }
public IHttpActionResult PutProperty(int id, PropertiesModel property) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != property.PropertyId) { return(BadRequest()); } //var dbProperty = db.Properties.Find(id); Property dbProperty = db.Properties.FirstOrDefault(p => p.User.UserName == User.Identity.Name && p.PropertyId == id); if (dbProperty == null) { return(BadRequest()); } dbProperty.Update(property); db.Entry(dbProperty).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PropertyExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public override void Initialize(PropertiesModel.Property property) { ColorCurveInfo colorCurveInfo = property.EditorAdditionalData<ColorCurveInfo>(); CurveInfo curveInfo = new CurveInfo(); if (colorCurveInfo.Type == ColorCurveType.R) curveInfo.Curves = new string[] { "Red" }; else if (colorCurveInfo.Type == ColorCurveType.G) curveInfo.Curves = new string[] { "Green" }; if (colorCurveInfo.Type == ColorCurveType.B) curveInfo.Curves = new string[] { "Blue" }; else if (colorCurveInfo.Type == ColorCurveType.RGB) curveInfo.Curves = new string[] { "Red", "Green", "Blue" }; else if (colorCurveInfo.Type == ColorCurveType.RGBA) curveInfo.Curves = new string[] { "Red", "Green", "Blue", "Alpha" }; PropertiesModel.Property p = new PropertiesModel.Property(property.Name, property.Editor, property.Value.DeepClone()); p.EditorAdditionalData<CurveInfo>(curveInfo); base.Initialize(p); }
public async Task <ActionResult> AddField(ViewFieldModel model) { //Defines the properties model key _KeyId.SetKey(); //Sets a new properties ObjectID collection; string propertiesId = _KeyId.GetKey(); //First must create properties model; PropertiesModel properties = new PropertiesModel() { ID = propertiesId, Size = Convert.ToInt32(model.Size), Value = model.Value, Maxlength = Convert.ToInt32(model.Maxlength), Required = Convert.ToBoolean(model.Required) }; _KeyId.SetKey(); //Sets a new properties ObjectID collection; string fieldId = _KeyId.GetKey(); //Third creates field model FieldModel field = new FieldModel() { Id = fieldId, Name = model.Name, Type = model.Type, Properties = propertiesId, Date = DateTime.Now.ToLocalTime() }; _Connection.DatabaseConnection(); _Properties.SetDatabase(_Connection.GetDatabase()); _Properties.CreateProperties(properties); _Field.SetDatabase(_Connection.GetDatabase()); _Field.CreateField(field); _Metadata.SetProcessVersion(model.ProcessID); _Metadata.AddFieldToProcess(model.ProcessID, fieldId); return(await Task.Run(() => RedirectToAction("Read", "Field", new { ProcessId = model.ProcessID }))); }
public async Task OnGetAsync() { // Arrange var databaseName = $"{DatabaseNamePrefix}.{nameof(OnGetAsync)}"; var options = new DbContextOptionsBuilder <IdentityServerDbContext>() .UseInMemoryDatabase(databaseName) .Options; var client = new Client { Id = Random.Next(), Properties = new List <ClientProperty> { new ClientProperty(), new ClientProperty(), new ClientProperty() } }; PropertiesModel model; IActionResult get; using (var context = new IdentityServerDbContext(options, _configurationStoreOptions.Object, _operationalStoreOptions.Object)) { context.Add(client); await context.SaveChangesAsync().ConfigureAwait(false); } // Act using (var context = new IdentityServerDbContext(options, _configurationStoreOptions.Object, _operationalStoreOptions.Object)) { model = new PropertiesModel(context); get = await model.OnGetAsync(client.Id).ConfigureAwait(false); } // Assert Assert.NotNull(model.Client); Assert.Equal(client.Id, model.Client.Id); var properties = Assert.IsAssignableFrom <IEnumerable <ClientProperty> >(model.Properties); Assert.Equal(client.Properties.Count, properties.Count()); Assert.IsType <PageResult>(get); }
public async Task OnGetAsync() { // Arrange var databaseName = $"{DatabaseNamePrefix}.{nameof(OnGetAsync)}"; var options = new DbContextOptionsBuilder <OidcDbContext>() .UseInMemoryDatabase(databaseName) .Options; var identityResource = new IdentityResource { Id = Random.Next(), Properties = new List <IdentityResourceProperty> { new IdentityResourceProperty(), new IdentityResourceProperty(), new IdentityResourceProperty() } }; PropertiesModel model; IActionResult get; using (var context = new OidcDbContext(options)) { context.Add(identityResource); await context.SaveChangesAsync().ConfigureAwait(false); } // Act using (var context = new OidcDbContext(options)) { model = new PropertiesModel(context); get = await model.OnGetAsync(identityResource.Id).ConfigureAwait(false); } // Assert Assert.NotNull(model.IdentityResource); Assert.Equal(identityResource.Id, model.IdentityResource.Id); var properties = Assert.IsAssignableFrom <IEnumerable <IdentityResourceProperty> >(model.Properties); Assert.Equal(identityResource.Properties.Count, properties.Count()); Assert.IsType <PageResult>(get); }
public async Task <Result> Handle(ListPropertyQuery request, CancellationToken cancellationToken) { await Task.Yield(); var allProperties = new List <PropertyModel>(); var workOrderPropertyTypePairs = _workOrderProvider.GetPropertyTypePairs(); foreach (var pair in workOrderPropertyTypePairs) { allProperties.Add(new PropertyModel { Property = pair.Key, Type = pair.Value }); } var count = allProperties.Count; var propertiesModel = new PropertiesModel { Value = allProperties, Count = count, NextLink = null }; return(Result.Ok(propertiesModel)); }
public override void Initialize(PropertiesModel.Property property) { base.Initialize(property); m_colorBox = new Panel(); m_colorBox.Cursor = Cursors.Hand; m_colorBox.Width = 0; m_colorBox.Height = 48; m_colorBox.Dock = DockStyle.Top; m_colorBox.Click += m_colorBox_Click; m_colorBox.Paint += m_colorBox_Paint; m_alphaTrack = new MetroTrackBar(); MetroSkinManager.ApplyMetroStyle(m_alphaTrack); m_alphaTrack.Width = 0; m_alphaTrack.Height = 16; m_alphaTrack.Dock = DockStyle.Top; m_alphaTrack.Maximum = 255; m_alphaTrack.Value = 255; m_alphaTrack.ValueChanged += m_alphaTrack_ValueChanged; m_alphaTextBox = new MetroTextBox(); MetroSkinManager.ApplyMetroStyle(m_alphaTextBox); m_alphaTextBox.Width = 0; m_alphaTextBox.Dock = DockStyle.Top; m_alphaTextBox.TextChanged += m_alphaTextBox_TextChanged; m_alphaTextBox.CustomPaintForeground += m_alphaTextBox_CustomPaintForeground; m_alphaTextBox.Leave += m_alphaTextBox_Leave; Content.Controls.Add(m_alphaTrack); Content.Controls.Add(m_alphaTextBox); Content.Controls.Add(m_colorBox); UpdateEditor(); m_alphaTextBox.Refresh(); }
public void RegisterPropertyEditors() { MainForm mainForm = FindForm() as MainForm; if (mainForm == null || mainForm.ProjectModel == null) return; m_editorsRegistry.UnregisterAllControls(); m_editorsRegistry.RegisterControl<PropertyEditors.Number_PropertyEditor>("number"); m_editorsRegistry.RegisterControl<PropertyEditors.String_PropertyEditor>("string"); m_editorsRegistry.RegisterControl<PropertyEditors.Boolean_PropertyEditor>("boolean"); //m_controlsRegistry.RegisterControl<PropertyEditors.Asset_PropertyEditor>("asset"); //m_controlsRegistry.RegisterControl<PropertyEditors.Entity_PropertyEditor>("entity"); m_editorsRegistry.RegisterControl<PropertyEditors.PlayCanvas_Rgb_PropertyEditor>("rgb"); m_editorsRegistry.RegisterControl<PropertyEditors.PlayCanvas_Rgba_PropertyEditor>("rgba"); m_editorsRegistry.RegisterControl<PropertyEditors.PlayCanvas_Vector_PropertyEditor>("vector"); m_editorsRegistry.RegisterControl<PropertyEditors.PlayCanvas_Enumeration_PropertyEditor>("enumeration"); m_editorsRegistry.RegisterControl<PropertyEditors.PlayCanvas_Curve_PropertyEditor>("curve"); m_editorsRegistry.RegisterControl<PropertyEditors.PlayCanvas_ColorCurve_PropertyEditor>("colorcurve"); string assetsPath = Path.Combine(mainForm.ProjectModel.WorkingDirectory, "assets"); DirectoryInfo info = new DirectoryInfo(assetsPath); if (info.Exists) { FileInfo[] files = info.GetFiles("*.editor.json", SearchOption.AllDirectories); if (files != null && files.Length > 0) { foreach (var file in files) { try { string name = file.Name.Remove(file.Name.Length - ".editor.json".Length); string content = File.ReadAllText(file.FullName); if (!String.IsNullOrEmpty(content)) { PropertiesControl.TypeDescriptor typeDesc = JsonConvert.DeserializeObject<PropertiesControl.TypeDescriptor>(content); if (typeDesc == null || !m_editorsRegistry.RegisterControl(name, typeDesc)) throw new Exception("Cannot register custom editor: " + name); } else throw new Exception("Cannot load custom editor: " + file.FullName); } catch (Exception ex) { MetroMessageBox.Show(mainForm, ex.Message, "Registering custom editor error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } files = info.GetFiles("*.editor.html", SearchOption.AllDirectories); if (files != null && files.Length > 0) { foreach (var file in files) { try { string name = file.Name.Remove(file.Name.Length - ".editor.html".Length); if (!m_editorsRegistry.RegisterControl(name, file.FullName)) throw new Exception("Cannot register custom editor: " + name); } catch (Exception ex) { MetroMessageBox.Show(mainForm, ex.Message, "Registering custom editor error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } PropertiesModel model = new PropertiesModel(); var numberInfo = new PropertyEditors.Number_PropertyEditor.NumberInfo() { Min = 0.5f, Max = 1.5f }; model.Properties.Add(PropertiesModel.Property.Create<float, PropertyEditors.Number_PropertyEditor.NumberInfo>("number", "number", 1.0f, numberInfo)); model.Properties.Add(PropertiesModel.Property.Create<string>("string", "string", "text")); model.Properties.Add(PropertiesModel.Property.Create<bool>("boolean", "boolean", true)); //model.Properties.Add(PropertiesModel.Property.Create<PlayCanvas.Assets>("asset", "asset", null)); //model.Properties.Add(PropertiesModel.Property.Create<PlayCanvas.Entity>("entity", "entity", null)); model.Properties.Add(PropertiesModel.Property.Create<PlayCanvas.Color>("rgb", "rgb", new PlayCanvas.Color(1.0f, 0.5f, 0.0f))); model.Properties.Add(PropertiesModel.Property.Create<PlayCanvas.Color>("rgba", "rgba", new PlayCanvas.Color(0.0f, 0.5f, 1.0f, 0.5f))); model.Properties.Add(PropertiesModel.Property.Create<PlayCanvas.Vector>("vector", "vector", new PlayCanvas.Vector(0.0f, 1.0f, 0.0f))); var enumsInfo = new PropertyEditors.PlayCanvas_Enumeration_PropertyEditor.EnumerationInfo(); enumsInfo["Cat"] = 0; enumsInfo["Dog"] = 1; model.Properties.Add(PropertiesModel.Property.Create<int, PropertyEditors.PlayCanvas_Enumeration_PropertyEditor.EnumerationInfo>("enumeration", "enumeration", 0, enumsInfo)); var curveData = new float[] { 0.0f, 1.0f, 1.0f, 0.0f }; model.Properties.Add(PropertiesModel.Property.Create<PlayCanvas.Curve>("curve", "curve", new PlayCanvas.Curve(curveData))); var curveSetInfo = new PropertyEditors.PlayCanvas_Curve_PropertyEditor.CurveInfo() { Curves = new string[] { "x", "y", "z" } }; var curveSetData = new float[][] { new float[]{ 0.0f, 1.0f, 1.0f, 0.0f }, new float[]{ 0.0f, 0.5f, 1.0f, 0.5f } }; model.Properties.Add(PropertiesModel.Property.Create<PlayCanvas.CurveSet, PropertyEditors.PlayCanvas_Curve_PropertyEditor.CurveInfo>("curveSet", "curve", new PlayCanvas.CurveSet(curveSetData), curveSetInfo)); var colorCurveSetInfo = new PropertyEditors.PlayCanvas_ColorCurve_PropertyEditor.ColorCurveInfo() { Type = PropertyEditors.PlayCanvas_ColorCurve_PropertyEditor.ColorCurveType.RGB }; model.Properties.Add(PropertiesModel.Property.Create<PlayCanvas.CurveSet, PropertyEditors.PlayCanvas_ColorCurve_PropertyEditor.ColorCurveInfo>("colorCurve", "colorcurve", new PlayCanvas.CurveSet(), colorCurveSetInfo)); model.Properties.Add(PropertiesModel.Property.Create<CustomType>("CustomType", "CustomType")); model.Properties.Add(PropertiesModel.Property.Create<CustomType>("Date", "Date")); model.Properties.Add(new PropertiesModel.Property("Array", "[string]")); model.Properties.Add(new PropertiesModel.Property("Object", "{CustomType}")); PropertiesControl properties = new PropertiesControl(model, m_editorsRegistry); properties.Dock = DockStyle.Fill; m_inspectPanel.Content.Controls.Clear(); m_inspectPanel.Content.Controls.Add(properties); }
public PlayCanvas_Vector_PropertyEditor(string name, PropertiesModel.Property property) : base(name, property) { }
public Number_PropertyEditor(string name, PropertiesModel.Property property) : base(name, property) { }
public PlayCanvas_ColorCurve_PropertyEditor(string name, PropertiesModel.Property property) : base(name, property) { }
public Boolean_PropertyEditor(string name, PropertiesModel.Property property) : base(name, property) { }