Example #1
0
        public ActionResult OrderOneMenu(OrderOneMenuViewModel orderOneMenuViewModel)
        {
            if (ModelState.IsValid)
            {
                var menu  = menuRepository.Find(orderOneMenuViewModel.IdMenuSelected);
                var order = orderRepository.Find(orderOneMenuViewModel.IdOrder);
                //ajoute menu depuis le bon contexte pour eviter duplication
                menuRepository.AddMenuToOrder(order, menu);

                if (orderOneMenuViewModel.IsOrderTerminated)
                {
                    return(RedirectToAction("CreateFromOrder", "Orders", new { idOrder = orderOneMenuViewModel.IdOrder, state = "created" }));
                }
                else
                {   //n'ajoute qu'un menu du meme type pas forcement un probleme mais a voir
                    return(RedirectToAction("OrderOneMenu", new { orderOneMenuViewModel.IdOrder }));
                }
            }
            else
            {
                ViewBag.PossibleProductTypes = producttypeRepository.All;
                return(View());
            }
        }