Exemple #1
0
 public IngredientEntity MapIngredientUpdateModelToEntity(IngredientUpdateModel ingredientUpdateModel)
 {
     return(new IngredientEntity
     {
         Id = ingredientUpdateModel.Id,
         Name = ingredientUpdateModel.Name,
         Description = ingredientUpdateModel.Description
     });
 }
        public async Task Update_Should_Update_Existing_Ingredient()
        {
            // Arrange
            Guid ingredientToUpdateGuid = new Guid("df935095-8709-4040-a2bb-b6f97cb416dc");
            var  ingredientUpdateModel  = new IngredientUpdateModel
            {
                Id          = ingredientToUpdateGuid,
                Name        = "Velké vejce",
                Description = "Nový popis"
            };
            var ingredientUpdateModelSerialized = JsonConvert.SerializeObject(ingredientUpdateModel);
            var stringContent = new StringContent(ingredientUpdateModelSerialized, Encoding.UTF8, "application/json");

            // Act
            var response = await _client.PutAsync("api/ingredient", stringContent);

            // Assert
            response.StatusCode.Should().Be(HttpStatusCode.OK);

            var ingredientGuid = JsonConvert.DeserializeObject <Guid>(await response.Content.ReadAsStringAsync());

            ingredientGuid.Should().Be(ingredientToUpdateGuid);
        }
Exemple #3
0
        public Guid?Update(IngredientUpdateModel ingredient)
        {
            var ingredientEntity = mapper.Map <IngredientEntity>(ingredient);

            return(ingredientRepository.Update(ingredientEntity));
        }
 public ActionResult <Guid> Update(IngredientUpdateModel ingredient)
 {
     return(ingredientFacade.Update(ingredient));
 }