Esempio n. 1
0
        private void Save()
        {
            var recipe = new RecipeDTO();

            recipeApi          = new RecipeAPI();
            recipe.Name        = this.name;
            recipe.Description = this.description;
            recipe.Products    = ProductsRecipe.Select(x => new ProductRecipeDTO()
            {
                ProductId = x.ProductId,
                Value     = x.Value
            }).ToList();
            var newRecipe      = recipeApi.Create(recipe);
            var recipeLocation = new RecipeLocationDTO();

            recipeLocation.Id        = newRecipe.Id;
            recipeLocation.Locations = LocationsRecipe.Select(x => new LocationDTO()
            {
                Id = x.Id
            }).ToList();
            var flagResult = recipeApi.UpdateLocations(recipeLocation);

            if (flagResult)
            {
                MessageBox.Show("Рецепт создан");
            }
            if (!flagResult)
            {
                MessageBox.Show("Ошибка при создании");
            }
        }
Esempio n. 2
0
        private void RemoveLocation(int locationId)
        {
            var location = LocationsRecipe.Single(x => x.Id == locationId);

            if (location != null)
            {
                LocationsRecipe.Remove(location);
                Locations.Add(location);
            }
        }