public static PizzaModel AddIngredientToPizza(PizzaModel pizza, IngredientModel ingredient) { UnitOfWorkRepository unitOfWork = new UnitOfWorkRepository(); PizzaIngredientModel pizIngModel = new PizzaIngredientModel(); pizIngModel.Ingredient = ingredient; pizIngModel.PizzaId = pizza.Id; pizza.PizzaIngredients.Add(pizIngModel); var _object = PizzaFactory.ConvertPizzaModel(pizza); unitOfWork.PizzaRepository.UpdatePizza(_object); return(pizza); }
public static Pizza_Ingredient ConvertPizzaIngredientModel(PizzaIngredientModel model) { if (model == null) { return(null); } Pizza_Ingredient pizINg = new Pizza_Ingredient() { Id = model.Id, PizzaIngredient_Id = model.PizzaId, IngriedientId = model.Ingredient.Id }; return(pizINg); }
public static PizzaIngredientModel ConvertPizzaIngredient(Pizza_Ingredient pizIng) { if (pizIng == null) { return(null); } var ingredient = IngredientModelFactory.GetIngredientModel(pizIng.IngriedientId); PizzaIngredientModel model = new PizzaIngredientModel { Id = pizIng.Id, PizzaId = pizIng.PizzaIngredient_Id, Ingredient = ingredient }; return(model); }
public static PizzaModel AssignIngredients(PizzaModel model, List <IngredientModel> ingredients) { UnitOfWorkRepository unitOfWork = new UnitOfWorkRepository(); foreach (var ing in ingredients) { PizzaIngredientModel pizIng = new PizzaIngredientModel { Id = new Guid(), Ingredient = ing, PizzaId = model.Id }; unitOfWork.PizzaIngredientRepository.AddPizza_Ingredients(PizzaIngredientFactory.ConvertPizzaIngredientModel(pizIng)); model.PizzaIngredients.Add(pizIng); } unitOfWork.PizzaRepository.UpdatePizza(PizzaFactory.ConvertPizzaModel(model)); return(model); }