public ActionResult Create(BouquetViewModel bouquetViewModel)
        {
            if (ModelState.IsValid)
            {
                var bouquet = new Bouquet();
                bouquet.Name = bouquetViewModel.BouquetName;
                _bouquetService.AddBouquet(bouquet);
                var i = 0;
                foreach (var sizeItemInBouquet in bouquetViewModel.SizeInBouquet)
                {
                    try
                    {
                        var bouquetSize = new BouquetSize();
                        bouquetSize.SizeId    = i;
                        bouquetSize.Price     = sizeItemInBouquet.Price;
                        bouquetSize.BouquetId = bouquet.Id;
                        bouquetSize.Bouquet   = bouquet;
                        _bouquetService.AddSizeOfBouquet(bouquetSize);
                        i++;
                        foreach (var flowerItemInBouquet in sizeItemInBouquet.FlowerListInBouquet)
                        {
                            try
                            {
                                var flowerItem = new FlowersInBouquet();
                                flowerItem.FlowerCount = flowerItemInBouquet.FlowerCount;
                                flowerItem.FlowerId    = flowerItemInBouquet.FlowerId;
                                var f = _flowerService.GetById(flowerItemInBouquet.FlowerId);
                                flowerItem.Flower        = f;
                                flowerItem.BouquetSizeId = bouquetSize.Id;
                                _bouquetService.AddFlowerToBouquet(flowerItem);
                            }
                            catch (Exception e)
                            {
                                //todo: log error
                                Console.WriteLine(e);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        //todo: log error
                        Console.WriteLine(e);
                    }
                }

                return(RedirectToAction("Index"));
            }
            bouquetViewModel.FlowerList = _flowerService.GetAll().ToList();

            return(View(bouquetViewModel));
        }
 public void AddFlowerToBouquet(FlowersInBouquet flower)
 {
     _entities.Set <FlowersInBouquet>().Add(flower);
 }
 public void AddFlowerToBouquet(FlowersInBouquet flower)
 {
     _bouquetRepository.AddFlowerToBouquet(flower);
     _unitOfWork.Commit();
 }