public async Task <JsonResult> PutCategoriaProducto(int id, CategoriaProducto categoriaProducto) { if (id != categoriaProducto.id) { return(new JsonResult(new { mensaje = "No coinciden los id." })); } _context.Entry(categoriaProducto).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoriaProductoExists(id)) { return(new JsonResult(new { mensaje = "No se encontro esa categoria" })); } else { throw; } } return(new JsonResult(categoriaProducto)); }
public async Task <ActionResult> PostMaxMix(MaximosMinimos maxmin) { string _id = null; try { _id = User.Claims.First(x => x.Type == "Idusuario").Value; } catch (Exception) { return(await Task.FromResult(StatusCode(401, "Acceso restringido"))); } MaximosMinimos item = new MaximosMinimos() { Idproducto = maxmin.Idproducto, MinimoAceptable = maxmin.MinimoAceptable, MaximoAceptable = maxmin.MaximoAceptable, IdusuarioCreado = Int32.Parse(_id), FechaCreado = DateTime.Now, IdusuarioActualizo = Int32.Parse(_id), FechaActualizado = DateTime.Now, Estado = maxmin.Estado }; _context.MaximosMinimos.Add(item); await _context.SaveChangesAsync(); return(Ok("MaxMin agregado con exito!!!")); }
public async Task <IActionResult> PutPresentacion([FromRoute] int id, [FromBody] Presentacion presentacion) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != presentacion.Id) { return(BadRequest()); } _context.Entry(presentacion).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PresentacionExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult> PostProducto(Producto pro) { string _id = null; try { _id = User.Claims.First(x => x.Type == "Idusuario").Value; } catch (Exception) { return(await Task.FromResult(StatusCode(401, "Acceso restringido"))); } //var existe = _context.Producto.Any(x => x.Idproducto == pro.Idproducto); Producto item = new Producto() { Idmarca = pro.Idmarca, Idcategoria = pro.Idcategoria, Iddimension = pro.Iddimension, IdusuarioCreado = Int32.Parse(_id), FechaCreado = DateTime.Now, IdusuarioActualizo = Int32.Parse(_id), FechaActualizado = DateTime.Now, Estado = pro.Estado, PrecioCompra = pro.PrecioCompra, PrecioVenta = pro.PrecioVenta }; _context.Producto.Add(item); await _context.SaveChangesAsync(); return(Ok("Producto agregado con exito!!!")); }
public async Task <JsonResult> PutSucursal(int id, Sucursal sucursal) { if (id != sucursal.id) { return(new JsonResult(new { mensaje = "El id de la url y el de la surcursal deben de coincidir" })); } _context.Entry(sucursal).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SucursalExists(id)) { return(new JsonResult(new { mensaje = "No existe ninguna sucursal con ese id" })); } else { throw; } } return(new JsonResult(sucursal)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,product,color,tallas,sexo,cantidad,modelo")] Producto producto) { if (id != producto.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(producto); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { return(NotFound()); } TempData["prueba02"] = "prueba02"; return(RedirectToAction(nameof(Listar))); } return(View(producto)); }
public async Task <JsonResult> PutProducto(int id, Producto producto) { if (id != producto.id) { return(new JsonResult(new { mensaje = "El id del producto debe de coincidir con el de la url." })); } _context.Entry(producto).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductoExists(id)) { return(new JsonResult(new { mensaje = "El producto con ese id no existe." })); } else { return(new JsonResult(new { mensaje = "Ocurrio un problema en la bd, vuelva a intentarlo" })); } } return(new JsonResult(producto)); }
public async Task <JsonResult> PutPedido(int id, Pedido pedido) { if (id != pedido.id) { return(new JsonResult(new { mensaje = "No se encontro nigún pedido con ese id" })); } _context.Entry(pedido).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PedidoExists(id)) { return(new JsonResult(new { mensaje = "No se encontro nigún pedido con ese id" })); } else { throw; } } return(new JsonResult(pedido)); }
public async Task <ActionResult> addUsuario(Usuario usuario) { string _id = null; try { _id = User.Claims.First(x => x.Type == "Idusuario").Value; } catch (Exception) { return(await Task.FromResult(StatusCode(401, "Acceso restringido"))); } Usuario item = new Usuario() { Nombre = usuario.Nombre, Correo = usuario.Correo, UserName = usuario.UserName, Idrole = usuario.Idrole, FechaCreacion = usuario.FechaCreacion, Estado = usuario.Estado }; _context.Usuario.Add(item); await _context.SaveChangesAsync(); return(Ok("Usuario agregado con exito!!!")); }
public async Task <JsonResult> PutInventario(int id, Inventario inventario) { if (id != inventario.id) { return(new JsonResult(new { mensaje = "El id del inventario debe coincidir con el id de l url." })); } _context.Entry(inventario).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InventarioExists(id)) { return(new JsonResult(new { mensaje = "No se encontró ningún inventario con ese id." })); } else { throw; } } return(new JsonResult(inventario)); }
public async Task <JsonResult> PutUsuario(int id, Usuario usuario) { if (id != usuario.id) { return(new JsonResult(new { mensaje = "El id del usuario debe de coincidir con el id de la url." })); } _context.Entry(usuario).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UsuarioExists(id)) { return(new JsonResult(new { mensaje = "No se encontro ningún usuario con ese id." })); } else { return(new JsonResult(new { mensaje = "Ocurrio un error en la bd, vuelva a intentarlo" })); } } return(new JsonResult(usuario)); }
public async Task <ActionResult> PostCategoria(Categoria cate) { string _id = null; try { _id = User.Claims.First(x => x.Type == "Idusuario").Value; } catch (Exception) { return(await Task.FromResult(StatusCode(401, "Acceso restringido"))); } var existe = _context.Categoria.Any(x => x.Nombre.Contains(cate.Nombre)); if (existe) { return(Ok("La categoria ya existe")); } Categoria item = new Categoria() { Nombre = cate.Nombre, IdusuarioCreado = Int32.Parse(_id), FechaCreado = DateTime.Now, IdusuarioActualizo = Int32.Parse(_id), FechaActualizado = DateTime.Now, Estado = cate.Estado }; _context.Categoria.Add(item); await _context.SaveChangesAsync(); return(Ok("Categoria agregada con exito!!!")); }
public async Task <IActionResult> PutDetallePedido(int id, DetallePedido detallePedido) { if (id != detallePedido.id) { return(BadRequest()); } _context.Entry(detallePedido).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DetallePedidoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <JsonResult> PutProveedor(int id, Proveedor proveedor) { if (id != proveedor.id) { return(new JsonResult(new { mensaje = "El id del proveedor debe de coincidir con el del url." })); } _context.Entry(proveedor).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProveedorExists(id)) { return(new JsonResult(new { mensaje = "No se encontro ningún proveedor con ese id" })); } else { throw; } } return(new JsonResult(proveedor)); }
public async Task <JsonResult> PutLote(int id, Lote lote) { if (id != lote.id) { return(new JsonResult(new { mensaje = "El id del lote debe de coincidir con el del url." })); } _context.Entry(lote).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LoteExists(id)) { return(new JsonResult(new { mensaje = "No se encontró ningún lote con ese id." })); } else { return(new JsonResult(new { mensaje = "Ocurrió un error en la bd, vuelva a intentarlo" })); } } return(new JsonResult(lote)); }
public async Task <string> AddInventario(Inventarios Invent) { await _InventarioDbContext.Inventarios.AddAsync(Invent); await _InventarioDbContext.SaveChangesAsync(); return("Inventario Grabado"); }
public async Task <IActionResult> Create([Bind("IdCategoria,Nombre,FechaCreacion")] Categoria categoria) { if (ModelState.IsValid) { _context.Add(categoria); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(categoria)); }
public async Task <IActionResult> Create([Bind("SECUENCIAL,TIPO,SECUANCIALPERSONA,SECUANCIALINGRESOCOMPUTADORES")] MANTENIMIENTOCOMPUTADORES mANTENIMIENTOCOMPUTADORES) { if (ModelState.IsValid) { _context.Add(mANTENIMIENTOCOMPUTADORES); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(mANTENIMIENTOCOMPUTADORES)); }
public async Task <IActionResult> Create([Bind("SECUENCIAL,RESPONSABLE,CODIGOINTERNO,TIEMPOINICIO,TIEMPOFIN")] ASIGNACIONVARIOS aSIGNACIONVARIOS) { if (ModelState.IsValid) { _context.Add(aSIGNACIONVARIOS); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(aSIGNACIONVARIOS)); }
public async Task <IActionResult> Create([Bind("SECUENCIAL,TIPO,RESPONSABLE,CODIGOINTERNO,MOTIVO")] BAJADEEQUIPOSVARIOS bAJADEEQUIPOSVARIOS) { if (ModelState.IsValid) { _context.Add(bAJADEEQUIPOSVARIOS); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(bAJADEEQUIPOSVARIOS)); }
public async Task <IActionResult> Create([Bind("SECUENCIAL,CODIGO,TIPOITEM,CATEGORIAITEM")] ITEM iTEM) { if (ModelState.IsValid) { _context.Add(iTEM); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(iTEM)); }
public async Task <IActionResult> Create([Bind("SECUENCIAL,CODIGOINTERNO,CUADADDEUBICACION,ITEM,DESCRIPCION,MEMORIARAM,PROCESADOR,DISCODURO,SISTEMAOPERATIVO,LICENCIADO,OFFICE,MARCA,MODELO,SERIE,PARTICULARIDAD,ESTADO,NODEFACTURA,VALORFACTURA,FECHAADQUISICION,OBSERVACIONES")] INGRESOCOMPUTADORES iNGRESOCOMPUTADORES) { if (ModelState.IsValid) { _context.Add(iNGRESOCOMPUTADORES); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(iNGRESOCOMPUTADORES)); }
public async Task <IActionResult> Create([Bind("IdProducto,Nombre,IdCategoria,Color,PrecioUnitario,CantidadDisponible,FechaCreacion")] Producto producto) { if (ModelState.IsValid) { _context.Add(producto); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IdCategoria"] = new SelectList(_context.Categoria, "IdCategoria", "Nombre", producto.IdCategoria); return(View(producto)); }
public async Task <ActionResult> PostOrdenCompra(DTOOrdenVenta orden) { string _id = null; try { _id = User.Claims.First(x => x.Type == "Idusuario").Value; } catch (Exception) { return(await Task.FromResult(StatusCode(401, "Acceso restringido"))); } OrdenVenta item = new OrdenVenta() { FechaCreacion = DateTime.Now, FechaSalida = orden.FechaSalida, UserCreatedId = Int32.Parse(_id), Idcliente = orden.Idcliente, IdestadoOrdenVenta = (int)EnumVentas.Proceso, Tipo = orden.Tipo, SubTotal = orden.SubTotal, IdDescuento = orden.IdDescuento, MontoDescuento = orden.MontoDescuento, Impuesto = orden.Impuesto, Total = orden.Total }; _context.OrdenVenta.Add(item); await _context.SaveChangesAsync(); foreach (var detalle in orden.DetalleOrdenVenta) { DetalleOrdenVenta itemDetalle = new DetalleOrdenVenta() { IdordenVenta = item.IdordenVenta, Idproducto = detalle.Idproducto, IdunidadMedida = detalle.IdunidadMedida, Cantidad = detalle.Cantidad, TotalUnidadVenta = detalle.TotalUnidadVenta }; _context.DetalleOrdenVenta.Add(itemDetalle); //var producto = await _context.Inventario.FirstOrDefaultAsync(x => x.Idproducto == detalle.Idproducto); //producto.Cantidad += detalle.Cantidad; await _context.SaveChangesAsync(); } return(Ok("Orden de venta realizada")); }
public async Task <IActionResult> Edit(int id, [Bind("ID,DNI,Nombre,Apellido,Correo,sexo,distrito,direccion,celular")] Cliente cliente) { if (id != cliente.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cliente); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { return(NotFound()); } TempData["prueba02"] = "prueba02"; return(RedirectToAction(nameof(Listar))); } return(View(cliente)); }
public async Task <ActionResult> PostProveedor(Proveedor pro) { string _id = null; try { _id = User.Claims.First(x => x.Type == "Idusuario").Value; } catch (Exception) { return(await Task.FromResult(StatusCode(401, "Acceso restringido"))); } var existe = _context.Proveedor.Any(x => x.Nombre.Contains(pro.Nombre)); if (existe) { return(Ok("El proveedor ya existe")); } Proveedor item = new Proveedor() { Nombre = pro.Nombre, Direccion = pro.Direccion, Telefono = pro.Telefono, IdusuarioCreado = Int32.Parse(_id), FechaCreado = DateTime.Now, IdusuarioActualizo = Int32.Parse(_id), FechaActualizado = DateTime.Now, Estado = pro.Estado }; _context.Proveedor.Add(item); await _context.SaveChangesAsync(); return(Ok("Proveedor agregada con exito!!!")); }
public async Task <ActionResult> PostRole(Roles rol) { string _id = null; try { _id = User.Claims.First(x => x.Type == "Idusuario").Value; } catch (Exception) { return(await Task.FromResult(StatusCode(401, "Acceso restringido"))); } Roles item = new Roles() { Nombre = rol.Nombre, Descripcion = rol.Descripcion }; _context.Roles.Add(item); await _context.SaveChangesAsync(); return(Ok("Rol agregado con exito!!!")); }
public async Task <ActionResult> PostInventario(Inventario inventario) { string _id = null; try { _id = User.Claims.First(x => x.Type == "Idusuario").Value; } catch (Exception) { return(await Task.FromResult(StatusCode(401, "Acceso restringido"))); } var existe = _context.Inventario.Any(x => x.Idproducto == inventario.Idproducto); if (existe) { return(Ok("El producto ya tiene un inventario creado")); } Inventario item = new Inventario() { Idproducto = inventario.Idproducto, Cantidad = inventario.Cantidad, IdusuarioCreado = Int32.Parse(_id), FechaCreado = DateTime.Now, IdusuarioActualizo = Int32.Parse(_id), FechaActualizado = DateTime.Now, Estado = inventario.Estado }; _context.Inventario.Add(item); await _context.SaveChangesAsync(); return(Ok("Inventario para producto creado")); }
public async Task<ActionResult> PostUnidadesMedidas(UnidadesDeMedida uni) { string _id = null; try { _id = User.Claims.First(x => x.Type == "Idusuario").Value; } catch (Exception) { return await Task.FromResult(StatusCode(401, "Acceso restringido")); } var existe = _context.UnidadesDeMedida.Any(x => x.Nombre.Contains(uni.Nombre)); if (existe) { return Ok("La medida ya existe"); } UnidadesDeMedida item = new UnidadesDeMedida() { Nombre = uni.Nombre, IdusuarioCreado = Int32.Parse(_id), FechaCreado = DateTime.Now, IdusuarioActualizo = Int32.Parse(_id), FechaActualizado = DateTime.Now, Estado = uni.Estado }; _context.UnidadesDeMedida.Add(item); await _context.SaveChangesAsync(); return Ok("Unidades y Medidas agregado con exito!!!"); }
public async Task <IActionResult> Edit(int id, [Bind("ID,DNI,Nombre,Apellido,Correo,Cargo,Contraseña")] Registrar usuario) { if (id != usuario.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(usuario); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { return(NotFound()); } TempData["prueba02"] = "prueba02"; return(RedirectToAction(nameof(Listar))); } return(View(usuario)); }