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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }