public async Task <IActionResult> Create([Bind("IdHorarios,HorariosAtencion")] Horarios horarios)
        {
            if (ModelState.IsValid)
            {
                _context.Add(horarios);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(horarios));
        }
        public async Task <IActionResult> Create([Bind("Id,Name,NormalizedName,ConcurrencyStamp")] AspNetRoles aspNetRoles)
        {
            if (ModelState.IsValid)
            {
                _context.Add(aspNetRoles);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(aspNetRoles));
        }
Exemple #3
0
        public async Task <IActionResult> Create([Bind("IdVotos,IdRestaurante,Calificacion1,Usuario,Comentario")] Calificacion calificacion)
        {
            if (ModelState.IsValid)
            {
                _context.Add(calificacion);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdRestaurante"] = new SelectList(_context.Restaurantes, "IdRestaurante", "IdRestaurante", calificacion.IdRestaurante);
            return(View(calificacion));
        }
        public async Task <IActionResult> Create([Bind("UserId,RoleId")] AspNetUserRoles aspNetUserRoles)
        {
            if (ModelState.IsValid)
            {
                _context.Add(aspNetUserRoles);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RoleId"] = new SelectList(_context.AspNetRoles, "Id", "Id", aspNetUserRoles.RoleId);
            ViewData["UserId"] = new SelectList(_context.AspNetUsers, "Id", "Id", aspNetUserRoles.UserId);
            return(View(aspNetUserRoles));
        }
        public async Task <IActionResult> Create([Bind("IdRestaurante,IdHorarios,InformacionGeneral,Logo,ImagenItemDestacado,Calificacion")] Restaurantes restaurantes, IFormFile imglogo, IFormFile imgdestacada)
        {
            if (ModelState.IsValid)
            {
                if (imglogo != null)

                {
                    if (imglogo.Length > 0)

                    //Convert Image to byte and save to database

                    {
                        byte[] p1 = null;
                        using (var fs1 = imglogo.OpenReadStream())
                            using (var ms1 = new MemoryStream())
                            {
                                fs1.CopyTo(ms1);
                                p1 = ms1.ToArray();
                            }
                        restaurantes.Logo = p1;
                    }
                }
                if (imgdestacada != null)

                {
                    if (imgdestacada.Length > 0)

                    //Convert Image to byte and save to database

                    {
                        byte[] p2 = null;
                        using (var fs2 = imgdestacada.OpenReadStream())
                            using (var ms2 = new MemoryStream())
                            {
                                fs2.CopyTo(ms2);
                                p2 = ms2.ToArray();
                            }
                        restaurantes.ImagenItemDestacado = p2;
                    }
                }

                _context.Add(restaurantes);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdHorarios"] = new SelectList(_context.Horarios, "IdHorarios", "HorariosAtencion", restaurantes.IdHorarios);
            return(View(restaurantes));
        }