Exemplo n.º 1
0
        public ActionResult Index(LancheViewModel viewModel)
        {
            var ret = viewModel;

            char[] charSep           = new char[] { '|' };
            var    IngredientesSplit = viewModel.NovoLanche.Pedido.Split(charSep, StringSplitOptions.RemoveEmptyEntries);
            var    IngredientesIDs   = new List <long>();

            foreach (var ingrediente in IngredientesSplit)
            {
                IngredientesIDs.Add(long.Parse(ingrediente));
            }

            //Montar o lanche a partir dos ingredientes.
            var lancheMontado = this.LancheService.MontarLanche(IngredientesIDs);

            lancheMontado.Nome      = viewModel.NovoLanche.Nome;
            lancheMontado.Descricao = viewModel.NovoLanche.Descricao;

            this.LancheService.Adicionar(lancheMontado);

            TempData["tagMessage"] = "sucesso";
            TempData["message"]    = "Registro salvo com sucesso.";

            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            var viewModel = new LancheViewModel();

            viewModel.ListaLanches            = this.LancheService.Buscar().Cast <LancheModel>().ToList();
            viewModel.IngredientesDisponiveis = this.IngredienteService.Buscar().Cast <IngredienteModel>().ToList();
            return(View(viewModel));
        }
Exemplo n.º 3
0
        public void Post([FromBody] LancheViewModel lancheModel)
        {
            var lanche = LancheFactory.Criar(lancheModel);

            pedidoService.FecharPedido(new Dominio.Pedido(lanche), null);
        }
Exemplo n.º 4
0
 public static Lanche Criar(LancheViewModel lancheModel)
 {
     return(new Lanche(lancheModel.Id, lancheModel.Nome, LancheItemFactory.Criar(lancheModel.LancheItens)));
 }