public void Convert_CookbookSourceViewModel_To_RecipeCookbookSource() { Initalize(); var input = new CookbookSourceViewModel { Name = "Cookbook 1", PublishingCompany = "ABC Corp", ISBN = "1234", Id = 1, Url = "http://www.test.de", Recipes = new List <RecipeShortInfoViewModel>() { new RecipeShortInfoViewModel() { Id = 1, Name = "Recipe 1", Page = 1, Type = SourceType.Cookbook, Url = "http://www.recipeUrl.de" }, new RecipeShortInfoViewModel() { Id = 1, Name = "Recipe 2", Page = 2, Type = SourceType.Cookbook, Url = "http://www.recipeUrl2.de" }, } }; var output = Mapper.Map <RecipeCookbookSource>(input); Assert.IsType <RecipeCookbookSource>(output); Assert.Equal(input.Name, output.Name); Assert.Equal(input.ISBN, output.ISBN); Assert.Equal(input.PublishingCompany, output.PublishingCompany); Assert.Equal(input.Id, output.Id); Assert.NotNull(output.RecipeSourceRecipes); Assert.Empty(output.RecipeSourceRecipes); }
public async Task <IActionResult> UpdateCookbookAsync(int sourceId, [FromBody] CookbookSourceViewModel model) { await _service.UpdateCookbookAsync(sourceId, model); return(NoContent()); }
/// <summary> /// Updates an existing cookbook /// </summary> /// <param name="cookbookId">Id of a cookbook</param> /// <param name="model">New Data</param> /// <returns></returns> public async Task UpdateCookbookAsync(int cookbookId, CookbookSourceViewModel model) { await this.Client.PutAsJsonAsync(model, $"Cookbooks/{cookbookId}"); }
public async Task UpdateCookbookAsync(int id, CookbookSourceViewModel model) { await this._cookbookAdapter.UpdateAsync(id, model); }