Spontaneous.WebApp.Services.ModelConverter.ToViewModel.ToDishModel C# (CSharp) Method

ToDishModel() public method

public ToDishModel ( Dish dishData, string restId, int MenuPId, string lang = DefaultLang, RestaurantModel restaurantModel = null ) : DishModel
dishData Spontaneous.DataModel.Dish
restId string
MenuPId int
lang string
restaurantModel Spontaneous.WebApp.Models.RestaurantModel
return Spontaneous.WebApp.Models.DishModel
        public override DishModel ToDishModel(Dish dishData, string restId, int MenuPId, string lang = DefaultLang, RestaurantModel restaurantModel = null)
        {
            if (restaurantModel == null)
            {
                restaurantModel = new RestaurantModel();
            }
            if(restaurantModel.GetType() == typeof(RestaurantModelBackOffice))
            {
                return ((RestaurantModelBackOffice)restaurantModel).GetDishModel(dishData, restId, MenuPId, false, lang);
            }
            return restaurantModel.GetDishModel(dishData, restId, MenuPId, false, lang);
            //return dishData.ToDishModel(restId, MenuPId, false, lang, restaurantModel);
        }

Same methods

ToViewModel::ToDishModel ( Dish dishData, string restId, string lang = DefaultLang, RestaurantModel restaurantModel = null ) : DishModel

Usage Example

        public void ToViewModelTest_ShouldConverToViewModelRegularCarbohydrateLevel()
        {
            Dish dish1 = new Dish()
            {
                Name = "dish1",
                Description = "description1",
                NutritionFacts = new NutritionFacts() { TotalCarbohydrate = 2 },
                BaseLineNutritionFacts = new NutritionFacts() { TotalCarbohydrate = 1 }
            };

            ToViewModelConverter converter = new ToViewModel();

            DishModel dishModel1 = converter.ToDishModel(dish1, "111111");

            Assert.IsTrue(dishModel1.NutritionFacts.TotalCarbohydrate == 2);
        }
All Usage Examples Of Spontaneous.WebApp.Services.ModelConverter.ToViewModel::ToDishModel