Ejemplo n.º 1
0
        public async Task <IActionResult> NewMenu(CrearMenuVM crearMenuVM)
        {
            Entrante primero = await _context.Entrantes.FindAsync(crearMenuVM.Menu.EntranteId);

            Principal segundo = await _context.Principales.FindAsync(crearMenuVM.Menu.PrincipalId);

            Postre tercero = await _context.Postres.FindAsync(crearMenuVM.Menu.PostreId);

            Menu nuevoMenu = new Menu
            {
                Entrante  = primero,
                Principal = segundo,
                Postre    = tercero,
                Fecha     = DateTime.Now,
                //PrecioTotal = primero.Precio + segundo.Precio + tercero.Precio,
            };

            double precio = 0;

            if (primero != null)
            {
                precio += primero.Precio;
            }
            if (segundo != null)
            {
                precio += segundo.Precio;
            }
            if (tercero != null)
            {
                precio += tercero.Precio;
            }
            nuevoMenu.PrecioTotal = precio;

            return(View(nuevoMenu));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> CreateMenu(CrearMenuVM cmvm)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cmvm.Menu);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cmvm));
        }
Ejemplo n.º 3
0
        // GET: Menus
        public async Task <IActionResult> Index()
        {
            CrearMenuVM cmvm = new CrearMenuVM
            {
                Principales = await _context.Principales.ToListAsync(),
                Entrantes   = await _context.Entrantes.ToListAsync(),
                Postres     = await _context.Postres.ToListAsync(),
            };

            return(View(cmvm));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> CrearMenu()
        {
            CrearMenuVM crearMenuVM = new CrearMenuVM
            {
                Fecha       = DateTime.Now,
                Entrantes   = await _context.Entrantes.ToListAsync(),
                Principales = await _context.Principales.ToListAsync(),
                Postres     = await _context.Postres.ToListAsync()
            };

            return(View(crearMenuVM));
        }