// GET: Bouquet/Create public ActionResult Create() { var model = new BouquetViewModel { SizeInBouquet = new List <SizeItemInBouquet>(3) }; var item1 = new SizeItemInBouquet { Size = Size.Küçük, FlowerListInBouquet = new List <FlowerItemInBouquet>() }; var item2 = new SizeItemInBouquet { Size = Size.Orta, FlowerListInBouquet = new List <FlowerItemInBouquet>() }; var item3 = new SizeItemInBouquet { Size = Size.Büyük, FlowerListInBouquet = new List <FlowerItemInBouquet>() }; model.SizeInBouquet.Add(item1); model.SizeInBouquet.Add(item2); model.SizeInBouquet.Add(item3); model.FlowerList = _flowerService.GetAll().ToList(); return(View(model)); }
// GET: Bouquet/Details/5 public ActionResult Details(int id) { var bouquet = _bouquetService.GetById(id); if (bouquet == null) { return(HttpNotFound()); } var model = new BouquetViewModel(); var bouquetSizes = _bouquetService.GetSizesOfBouquet(id); model.BouquetId = bouquet.Id; model.BouquetName = bouquet.Name; model.SizeInBouquet = new List <SizeItemInBouquet>(); foreach (var bouquetSizeItem in bouquetSizes) { var bouquetSize = new SizeItemInBouquet { Size = (Size)bouquetSizeItem.SizeId, Price = bouquetSizeItem.Price, FlowerListInBouquet = new List <FlowerItemInBouquet>() }; var flowers = _bouquetService.GetFlowersInBouquetType(bouquetSizeItem.Id); var flowerList = new List <FlowerItemInBouquet>(); foreach (var flower in flowers) { var flowerInBouquet = new FlowerItemInBouquet(); flowerInBouquet.FlowerId = flower.FlowerId; var f = _flowerService.GetById(flower.FlowerId); flowerInBouquet.FlowerName = f.Name; flowerInBouquet.Flower = f; flowerInBouquet.FlowerCount = flower.FlowerCount; flowerList.Add(flowerInBouquet); } bouquetSize.FlowerListInBouquet = flowerList; model.SizeInBouquet.Add(bouquetSize); } model.FlowerList = _flowerService.GetAll().ToList(); return(View(model)); }
public ActionResult Index() { var result = new BouquetsViewModel(); result.Bouquets = new List <BouquetViewModel>(); var bouquetList = _bouquetService.GetAll(); foreach (var item in bouquetList) { var id = item.Id; var bouquets = new BouquetViewModel(); var bouquetSizes = _bouquetService.GetSizesOfBouquet(id); bouquets.BouquetId = id; bouquets.BouquetName = item.Name; bouquets.SizeInBouquet = new List <SizeItemInBouquet>(); foreach (var bouquetSizeItem in bouquetSizes) { var bouquet = new SizeItemInBouquet(); bouquet.Size = (Size)bouquetSizeItem.SizeId; bouquet.Price = bouquetSizeItem.Price; bouquet.FlowerListInBouquet = new List <FlowerItemInBouquet>(); var flowers = _bouquetService.GetFlowersInBouquetType(bouquetSizeItem.Id); var flowerList = new List <FlowerItemInBouquet>(); foreach (var flower in flowers) { var flowerInBouquet = new FlowerItemInBouquet(); flowerInBouquet.FlowerId = flower.FlowerId; flowerInBouquet.FlowerName = _flowerService.GetById(flower.FlowerId).Name; flowerInBouquet.FlowerCount = flower.FlowerCount; flowerList.Add(flowerInBouquet); } bouquet.FlowerListInBouquet = flowerList; bouquets.SizeInBouquet.Add(bouquet); } result.Bouquets.Add(bouquets); } return(View(result)); }