-
Notifications
You must be signed in to change notification settings - Fork 2
UpdateFood (3.2.x)
Alex edited this page May 30, 2019
·
1 revision
var ingredient = new IngredientDto();
ingredient.Id = Guid.Parse("d6e1c25c-45ea-00e3-575f-443582096cec"); // Existing Item in Database
ingredient.Name = new [] { new GlobalString() { Language = "en-US", Value = "New Ingredient1" } };
ingredient.CommonName = new[] { new GlobalString() { Language = "en-US", Value = "Ingredient" } };
ingredient.UserCode = "1414-3";
ingredient.Description = new[] { new GlobalString() { Language = "en-US", Value = "Description" } };
ingredient.UsdaCode = 1234;
ingredient.Created = new XmlDateTimeOffset
{
DateTime = DateTime.Now.ToUniversalTime(),
UtcOffsetInMinutes = 0
};
ingredient.Brand = new BrandDto
{
Product = "Product",
Supplier = "Supplier"
};
ingredient.AllergenStatements = new []
{
new AllergenStatementDto {AllergenGroups = new []
{
Guid.Parse("f01975c0-0191-0000-ff88-2a01e505d63d") // Egg
}}
};
ingredient.Groups = new[] {Guid.Parse("021c021f-000a-0000-8d69-0b60293379ea")};
ingredient.Conversions = new[]
{
new ConversionDto
{
From = new AmountDto
{
Quantity = new QuantityDto() { Type = QuantityType.Double, Value = "100" },
UnitId = Guid.Parse("a7df0af5-0008-0000-7484-751e8eaf05c6") // gram
},
To = new AmountDto
{
Quantity = new QuantityDto() { Type = QuantityType.Double, Value = "1" },
UnitId = Guid.Parse("a7df0af5-001c-0000-7484-751e8eaf05c6") // bowl
},
}
};
ingredient.DefiningAmount = new AmountDto
{
Quantity = new QuantityDto() { Type = QuantityType.Double, Value = "100" },
UnitId = Guid.Parse("a7df0af5-0008-0000-7484-751e8eaf05c6")
};
ingredient.NutrientProfileId = Guid.NewGuid();
var nutrientProfile = new NutrientProfileDto();
nutrientProfile.Id = ingredient.NutrientProfileId;
nutrientProfile.DefiningAmount = ingredient.DefiningAmount;
nutrientProfile.NutrientIdVector = new []
{
new NutrientQuantityDto
{
NutrientId = Guid.Parse("84a8709a-0000-0000-ebf9-90cea7d9d44f"),
Quantity = new QuantityDto
{
Type = QuantityType.Double,
Value = "10"
}
}
};
var updateFoodRequest = new UpdateFoodRequest
{
Foods = new [] {ingredient},
NutrientProfiles = new []{nutrientProfile}
};
var updateFoodResponse = foodEditServiceClient.UpdateFood(updateFoodRequest);
var recipe = new RecipeDto();
recipe.Id = Guid.Parse("d6e1c25c-45ea-00e3-575f-443582096cec"); // Existing Item in Database
recipe.Name = new [] { new GlobalString() { Language = "en-US", Value = "New Recipe" } };
recipe.CommonName = new[] { new GlobalString() { Language = "en-US", Value = "Recipe" } };
recipe.UserCode = "1414-3";
recipe.Description = new[] { new GlobalString() { Language = "en-US", Value = "Description" } };
recipe.UsdaCode = 1234;
recipe.Created = new XmlDateTimeOffset
{
DateTime = DateTime.Now.ToUniversalTime(),
UtcOffsetInMinutes = 0
};
recipe.Brand = new BrandDto
{
Product = "Product",
Supplier = "Supplier"
};
recipe.AllergenStatements = new []
{
new AllergenStatementDto {AllergenGroups = new []
{
Guid.Parse("f01975c0-0191-0000-ff88-2a01e505d63d") // Egg
}}
};
recipe.Groups = new[] {Guid.Parse("021c021f-000a-0000-8d69-0b60293379ea")};
recipe.Conversions = new[]
{
new ConversionDto
{
From = new AmountDto
{
Quantity = new QuantityDto() { Type = QuantityType.Double, Value = "100" },
UnitId = Guid.Parse("a7df0af5-0008-0000-7484-751e8eaf05c6") // gram
},
To = new AmountDto
{
Quantity = new QuantityDto() { Type = QuantityType.Double, Value = "1" },
UnitId = Guid.Parse("a7df0af5-001f-0000-7484-751e8eaf05c6") // serving
},
}
};
recipe.Items = new[] {new FoodItemDto
{
FoodId = Guid.Parse("d6e1c25c-45ea-00e3-575f-443582096cec"), // Existing Food in Database
Amount = new AmountDto
{
Quantity = new QuantityDto() { Type = QuantityType.Double, Value = "100" },
UnitId = Guid.Parse("a7df0af5-0008-0000-7484-751e8eaf05c6") // gram
}
}};
var updateFoodRequest = new UpdateFoodRequest
{
Foods = new [] {recipe}
};
var updateFoodRequest = foodEditServiceClient.UpdateFood(updateFoodRequest);