public void ShowProductTest() { string result = new ContentUpdater().ShowProduct(new Product_table2 { ID = 1, Product_Name = "Sponge", Product_Description = "Cleaning Sponge", Ean = "4 34324 2342", ExpectedRestock = true, BrandId = 1, BrandName = "Soggy sponge", CategoryId = 1, CategoryName = "Cleaning", Price = 3.56, Original_Price = 5.00 }); string expected = "Product ID: 1Product name: Sponge Product Desc: Cleaning Sponge Product price 3.56"; Assert.AreEqual(expected, result); }
private void Awake() { _sr = GetComponent <ScrollRect>(); _cu = GetComponent <ContentUpdater>(); }
public async Task <ContentResponseMessage> SaveContent([FromBody] SaveContentRequestBody data) { if (!ModelState.IsValid) { return(ContentResponseMessage.CreateFrom(ModelState)); } var contentType = ContentTypeProvider.Get(data.ContentTypeId); var b = JsonConvert.DeserializeObject(data.Content, contentType.Type, PolymorphicFormConverter); if (!TryValidateModel(b)) { return(ContentResponseMessage.CreateFrom(ModelState)); } if (PrimaryKeyGetter.Get(b).All(id => id != null)) { var a = await ContentGetter.GetAsync(contentType.Id, PrimaryKeyConverter.Convert(data.KeyValues, contentType.Id)).ConfigureAwait(false); foreach (var coreInterface in ContentTypeCoreInterfaceProvider.GetFor(contentType.Id)) { foreach (var propertyDefinition in coreInterface.PropertyDefinitions) { var display = propertyDefinition.Attributes.OfType <DisplayAttribute>().FirstOrDefault(); if (display != null && display.GetAutoGenerateField() == false) { continue; } propertyDefinition.Setter(a, propertyDefinition.Getter(b)); } } foreach (var propertyDefinition in PropertyDefinitionProvider.GetFor(contentType.Id)) { var display = propertyDefinition.Attributes.OfType <DisplayAttribute>().FirstOrDefault(); if (display != null && display.GetAutoGenerateField() == false) { continue; } propertyDefinition.Setter(a, propertyDefinition.Getter(b)); } if (!TryValidateModel(b)) { throw new Exception("a was valid but b was not."); } await ContentUpdater.UpdateAsync(a).ConfigureAwait(false); return(new ContentResponseMessage(true, "Updated")); } else { await ContentCreator.CreateAsync(b).ConfigureAwait(false); return(new ContentResponseMessage(true, "Created")); } }