コード例 #1
0
        public async Task <IActionResult> Create([Bind("Id,Descripcion,Color,Precio,IdCategoria,FileName")] Producto producto)
        {
            if (ModelState.IsValid)
            {
                var files = HttpContext.Request.Form.Files;
                var FileUploadDirectory = Path.Combine(_hostEnvironment.WebRootPath, "Files\\Products");


                if (files.Count > 0)
                {
                    var file = files.FirstOrDefault();

                    if (file.Length > 0)
                    {
                        var fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"');

                        using (var fileStream = new FileStream(Path.Combine(FileUploadDirectory, fileName), FileMode.Create))
                        {
                            await file.CopyToAsync(fileStream);

                            producto.FileName = file.FileName;
                        }
                    }
                }


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

                return(RedirectToAction(nameof(Index)));
            }
            return(View(producto));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Id,Descripcion")] CategoriaProducto categoriaProducto)
        {
            if (ModelState.IsValid)
            {
                _context.Add(categoriaProducto);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(categoriaProducto));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("Id,NombrePais,Description")] Pais pais)
        {
            if (ModelState.IsValid)
            {
                _context.Add(pais);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(pais));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("Id,IdPais,Descripcion")] Ciudad ciudad)
        {
            if (ModelState.IsValid)
            {
                _context.Add(ciudad);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(ciudad));
        }
コード例 #5
0
        public async Task <IActionResult> Create([Bind("Id,IdVenta,IdProducto,Cantidad")] VentaDetalle ventaDetalle)
        {
            if (ModelState.IsValid)
            {
                _context.Add(ventaDetalle);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(ventaDetalle));
        }
コード例 #6
0
        public async Task <IActionResult> Create([Bind("Mail,Id,Nombre,Apellido,FechaNacimiento,Telefono,Pais")] Cliente cliente)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cliente);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cliente));
        }
コード例 #7
0
        public async Task <IActionResult> Create([Bind("Id,Apellido,Nombre,FechaNacimiento")] Persona persona)
        {
            if (ModelState.IsValid)
            {
                _context.Add(persona);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(persona));
        }
コード例 #8
0
        public async Task <IActionResult> Create([Bind("Id,Fecha,IdCliente,Observaciones")] Venta venta)
        {
            if (ModelState.IsValid)
            {
                _context.Add(venta);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(venta));
        }
コード例 #9
0
        public async Task <IActionResult> Create([Bind("Legajo,Id,Nombre,Apellido,FechaNacimiento,Telefono")] Vendedor vendedor)
        {
            if (ModelState.IsValid)
            {
                _context.Add(vendedor);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(vendedor));
        }