Professional Documents
Culture Documents
Manual de Codigo
Manual de Codigo
Manual de Codigo
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using StorePlace.Models;
namespace StorePlace.Controllers
{
[Authorize(Roles = "Administrador,Bodeguero")]
public class CategoriaProductoesController : Controller
{
private readonly storeplacedbContext _context;
// GET: CategoriaProductoes
public async Task<IActionResult> Index()
{
ViewBag.Message = TempData["Message"];
ViewBag.Class = TempData["class"];
ViewBag.Icon = TempData["icon"];
return View(await _context.CategoriaProductos.ToListAsync());
}
// GET: CategoriaProductoes/Details/5
public async Task<IActionResult> Details(int? id)
{
if (id == null)
{
return NotFound();
}
return View(categoriaProducto);
}
// GET: CategoriaProductoes/Create
public IActionResult Create()
{
ViewBag.Message = TempData["Message"];
return View();
}
// POST: CategoriaProductoes/Create
// To protect from overposting attacks, enable the specific
properties you want to bind to.
// For more details, see http://go.microsoft.com/fwlink/?
LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult>
Create([Bind("Idcategoria,Descripcion")] CategoriaProducto
categoriaProducto)
{
if (ModelState.IsValid)
{
_context.Add(categoriaProducto);
await _context.SaveChangesAsync();
TempData["Message"] = "El registro se guardo correctamente";
TempData["class"] = "alert alert-success alert-dismissible
fade show";
TempData["icon"] = "bi bi-check-circle me-1";
return RedirectToAction(nameof(Index));
}
else
{
TempData["Message"] = "Llene todos los campos
correctamente";
}
return View(categoriaProducto);
}
// GET: CategoriaProductoes/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if (id == null)
{
return NotFound();
}
// POST: CategoriaProductoes/Edit/5
// To protect from overposting attacks, enable the specific
properties you want to bind to.
// For more details, see http://go.microsoft.com/fwlink/?
LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id,
[Bind("Idcategoria,Descripcion")] CategoriaProducto categoriaProducto)
{
if (id != categoriaProducto.Idcategoria)
{
return NotFound();
}
if (ModelState.IsValid)
{
try
{
_context.Update(categoriaProducto);
TempData["Message"] = "El registro se actualizo
correctamente";
TempData["class"] = "alert alert-success alert-
dismissible fade show";
TempData["icon"] = "bi bi-check-circle me-1";
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!
CategoriaProductoExists(categoriaProducto.Idcategoria))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}
return View(categoriaProducto);
}
// GET: CategoriaProductoes/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if (id == null)
{
return NotFound();
}
return View(categoriaProducto);
}
// POST: CategoriaProductoes/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
var categoriaProducto = await
_context.CategoriaProductos.FindAsync(id);
_context.CategoriaProductos.Remove(categoriaProducto);
TempData["Message"] = $"La categoria
'{categoriaProducto.Descripcion}' se elimino correctamente";
TempData["class"] = "alert alert-info alert-dismissible fade
show";
TempData["icon"] = "bi bi-info-circle me-1";
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using StorePlace.Models;
namespace StorePlace.Controllers
{
[Authorize(Roles = "Administrador,Cajero")]
public class ClientesController : Controller
{
private readonly storeplacedbContext _context;
// GET: Clientes
public async Task<IActionResult> Index()
{
ViewBag.Message = TempData["Message"];
ViewBag.Class = TempData["class"];
ViewBag.Icon = TempData["icon"];
var storeplacedbContext = _context.Clientes.Include(c =>
c.IdctgclienteNavigation);
return View(await storeplacedbContext.ToListAsync());
}
// GET: Clientes/Details/5
public async Task<IActionResult> Details(int? id)
{
if (id == null)
{
return NotFound();
}
return View(cliente);
}
// GET: Clientes/Create
public IActionResult Create()
{
ViewData["Idctgcliente"] = new
SelectList(_context.CategoriaClientes, "Idcategoria", "Idcategoria");
return View();
}
// POST: Clientes/Create
// To protect from overposting attacks, enable the specific
properties you want to bind to.
// For more details, see http://go.microsoft.com/fwlink/?
LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult>
Create([Bind("Idcliente,Nit,Idctgcliente,Nombre,Apellido,Direccion,Telefono"
)] Cliente cliente)
{
if (ModelState.IsValid)
{
_context.Add(cliente);
TempData["Message"] = "El registro se guardo correctamente";
TempData["class"] = "alert alert-success alert-dismissible
fade show";
TempData["icon"] = "bi bi-check-circle me-1";
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
ViewData["Idctgcliente"] = new
SelectList(_context.CategoriaClientes, "Idcategoria", "Idcategoria",
cliente.Idctgcliente);
return View(cliente);
}
// GET: Clientes/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if (id == null)
{
return NotFound();
}
// POST: Clientes/Edit/5
// To protect from overposting attacks, enable the specific
properties you want to bind to.
// For more details, see http://go.microsoft.com/fwlink/?
LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id,
[Bind("Idcliente,Nit,Idctgcliente,Nombre,Apellido,Direccion,Telefono")]
Cliente cliente)
{
if (id != cliente.Idcliente)
{
return NotFound();
}
if (ModelState.IsValid)
{
try
{
_context.Update(cliente);
TempData["Message"] = "El registro se actualizo
correctamente";
TempData["class"] = "alert alert-success alert-
dismissible fade show";
TempData["icon"] = "bi bi-check-circle me-1";
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!ClienteExists(cliente.Idcliente))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}
ViewData["Idctgcliente"] = new
SelectList(_context.CategoriaClientes, "Idcategoria", "Idcategoria",
cliente.Idctgcliente);
return View(cliente);
}
// GET: Clientes/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if (id == null)
{
return NotFound();
}
var cliente = await _context.Clientes
.Include(c => c.IdctgclienteNavigation)
.FirstOrDefaultAsync(m => m.Idcliente == id);
if (cliente == null)
{
return NotFound();
}
return View(cliente);
}
// POST: Clientes/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
var cliente = await _context.Clientes.FindAsync(id);
_context.Clientes.Remove(cliente);
TempData["Message"] = $"El Cliente '{cliente.Nombre}
{cliente.Apellido}' se elimino correctamente";
TempData["class"] = "alert alert-info alert-dismissible fade
show";
TempData["icon"] = "bi bi-info-circle me-1";
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using StorePlace.Models;
using System.Diagnostics;
namespace StorePlace.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
private readonly storeplacedbContext _context;
namespace StorePlace.Controllers
{
public class LoginController : Controller
{
private readonly storeplacedbContext _context;
[HttpPost]
public async Task<IActionResult> Index(Usuario user)
{
Usuario _user = UserIsvalid(user);
if (_user != null)
{
var claims = new List<Claim>
{
new Claim(ClaimTypes.NameIdentifier,
_user.Idusuario.ToString()),
new Claim(ClaimTypes.Name, _user.Nombre + " " +
_user.Apellido),
new Claim(ClaimTypes.Email, _user.Correo),
};
claims.Add(new Claim(ClaimTypes.Role,
_user.IdrolNavigation.Descripcion));
await
HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using MySql.Data.MySqlClient;
using StorePlace.ClsJsonR;
using StorePlace.Models;
namespace StorePlace.Controllers
{
[Authorize(Roles = "Bodeguero,Administrador")]
//[Authorize(Roles = "Administrador")]
public class ProductosController : Controller
{
private readonly storeplacedbContext _context;
private readonly string _cn;
// GET: Productos
public async Task<IActionResult> Index()
{
ViewBag.Message = TempData["Message"];
ViewBag.Class = TempData["class"];
ViewBag.Icon = TempData["icon"];
var storeplacedbContext = _context.Productos.Include(p =>
p.IdcategoriaNavigation);
return View(await storeplacedbContext.ToListAsync());
}
// GET: Productos/Details/5
public async Task<IActionResult> Details(string id)
{
if (id == null)
{
return NotFound();
}
return View(producto);
}
// GET: Productos/Create
public IActionResult Create()
{
ViewBag.MessageErr = TempData["Message_err"];
ViewData["Idcategoria"] = new
SelectList(_context.CategoriaProductos, "Idcategoria", "Descripcion");
return View();
}
// POST: Productos/Create
// To protect from overposting attacks, enable the specific
properties you want to bind to.
// For more details, see http://go.microsoft.com/fwlink/?
LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult>
Create([Bind("Barcode,Idcategoria,Nombre,Costo,Porcganacia,Stock,Precio")]
Producto producto)
{
if (ModelState.IsValid)
{
_context.Add(producto);
TempData["Message"] = "El registro se guardo correctamente";
TempData["class"] = "alert alert-success alert-dismissible
fade show";
TempData["icon"] = "bi bi-check-circle me-1";
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
else if (!ModelState.IsValid) {
TempData["Message_err"] = "Llene todos los campos
correctamente";
// GET: Productos/Edit/5
public async Task<IActionResult> Edit(string id)
{
if (id == null)
{
return NotFound();
}
// POST: Productos/Edit/5
// To protect from overposting attacks, enable the specific
properties you want to bind to.
// For more details, see http://go.microsoft.com/fwlink/?
LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(string id,
[Bind("Barcode,Idcategoria,Nombre,Costo,Porcganacia,Stock,Precio")] Producto
producto)
{
if (id != producto.Barcode)
{
return NotFound();
}
if (ModelState.IsValid)
{
try
{
_context.Update(producto);
TempData["Message"] = "El registro se actualizo
correctamente";
TempData["class"] = "alert alert-success alert-
dismissible fade show";
TempData["icon"] = "bi bi-check-circle me-1";
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!ProductoExists(producto.Barcode))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}
ViewData["Idcategoria"] = new
SelectList(_context.CategoriaProductos, "Idcategoria", "Descripcion",
producto.Idcategoria);
return View(producto);
}
// GET: Productos/Delete/5
public async Task<IActionResult> Delete(string id)
{
if (id == null)
{
return NotFound();
}
return View(producto);
}
// POST: Productos/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(string id)
{
var producto = await _context.Productos.FindAsync(id);
_context.Productos.Remove(producto);
TempData["Message"] = $"El Producto '{producto.Nombre}' se
elimino correctamente";
TempData["class"] = "alert alert-info alert-dismissible fade
show";
TempData["icon"] = "bi bi-info-circle me-1";
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
private bool ProductoExists(string id)
{
return _context.Productos.Any(e => e.Barcode == id);
}
}
}
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using StorePlace.Models;
namespace StorePlace.Controllers
{
[Authorize(Roles = "Administrador,Bodeguero")]
public class ProveedoresController : Controller
{
private readonly storeplacedbContext _context;
// GET: Proveedores
public async Task<IActionResult> Index()
{
ViewBag.Message = TempData["Message"];
ViewBag.Class = TempData["class"];
ViewBag.Icon = TempData["icon"];
return View(await _context.Proveedors.ToListAsync());
}
// GET: Proveedores/Details/5
public async Task<IActionResult> Details(int? id)
{
if (id == null)
{
return NotFound();
}
return View(proveedor);
}
// GET: Proveedores/Create
public IActionResult Create()
{
return View();
}
// POST: Proveedores/Create
// To protect from overposting attacks, enable the specific
properties you want to bind to.
// For more details, see http://go.microsoft.com/fwlink/?
LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult>
Create([Bind("Idproveedor,Nombre,Direccion,Telefono")] Proveedor proveedor)
{
if (ModelState.IsValid)
{
_context.Add(proveedor);
TempData["Message"] = "El registro se guardo correctamente";
TempData["class"] = "alert alert-success alert-dismissible
fade show";
TempData["icon"] = "bi bi-check-circle me-1";
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
return View(proveedor);
}
// GET: Proveedores/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if (id == null)
{
return NotFound();
}
// POST: Proveedores/Edit/5
// To protect from overposting attacks, enable the specific
properties you want to bind to.
// For more details, see http://go.microsoft.com/fwlink/?
LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id,
[Bind("Idproveedor,Nombre,Direccion,Telefono")] Proveedor proveedor)
{
if (id != proveedor.Idproveedor)
{
return NotFound();
}
if (ModelState.IsValid)
{
try
{
_context.Update(proveedor);
TempData["Message"] = "El registro se actualizo
correctamente";
TempData["class"] = "alert alert-success alert-
dismissible fade show";
TempData["icon"] = "bi bi-check-circle me-1";
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!ProveedorExists(proveedor.Idproveedor))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}
return View(proveedor);
}
// GET: Proveedores/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if (id == null)
{
return NotFound();
}
return View(proveedor);
}
// POST: Proveedores/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
var proveedor = await _context.Proveedors.FindAsync(id);
TempData["Message"] = $"El Proveedor '{proveedor.Nombre}' se
elimino correctamente";
TempData["class"] = "alert alert-info alert-dismissible fade
show";
TempData["icon"] = "bi bi-info-circle me-1";
_context.Proveedors.Remove(proveedor);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using StorePlace.Models;
using StorePlace.Models.ViewsModels;
using Microsoft.AspNetCore.Authorization;
namespace StorePlace.Controllers
{
[Authorize(Roles = "Administrador")]
public class UsuariosController : Controller
{
private readonly storeplacedbContext _context;
// GET: Usuarios
public async Task<IActionResult> Index()
{
ViewBag.Message = TempData["Message"];
ViewBag.Class = TempData["class"];
ViewBag.Icon = TempData["icon"];
var storeplacedbContext = _context.Usuarios.Include(u =>
u.IdrolNavigation);
return View(await storeplacedbContext.ToListAsync());
}
// GET: Usuarios/Details/5
public async Task<IActionResult> Details(int? id)
{
if (id == null)
{
return NotFound();
}
return View(usuario);
}
// GET: Usuarios/Create
public IActionResult Create()
{
//ViewBag.MessageErr = TempData["Message_err"];
ViewData["Idrol"] = new SelectList(_context.Rols, "Idrol",
"Descripcion");
return View();
}
// POST: Usuarios/Create
// To protect from overposting attacks, enable the specific
properties you want to bind to.
// For more details, see http://go.microsoft.com/fwlink/?
LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult>
Create([Bind("Idusuario,Nombre,Apellido,Correo,Idrol,Contraseña")] Usuario
usuario)
{
if (UsuarioExists(usuario.Correo))
{
TempData["Message_err"] = "Este usuario ya existe";
ViewData["Idrol"] = new SelectList(_context.Rols, "Idrol",
"Descripcion", usuario.Idrol);
return View(usuario);
}
else
{
usuario.Contraseña = Encrypt.Encriptar(usuario.Contraseña);
_context.Add(usuario);
TempData["Message"] = "El registro se guardo correctamente";
TempData["class"] = "alert alert-success alert-dismissible
fade show";
TempData["icon"] = "bi bi-check-circle me-1";
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
}
// GET: Usuarios/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if (id == null)
{
return NotFound();
}
// POST: Usuarios/Edit/5
// To protect from overposting attacks, enable the specific
properties you want to bind to.
// For more details, see http://go.microsoft.com/fwlink/?
LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id,
[Bind("Idusuario,Nombre,Apellido,Correo,Idrol,Contraseña")] Usuario usuario)
{
if (id != usuario.Idusuario)
{
return NotFound();
}
_context.Update(usuario);
TempData["Message"] = "El registro se actualizo correctamente";
TempData["class"] = "alert alert-success alert-dismissible fade
show";
TempData["icon"] = "bi bi-check-circle me-1";
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
ViewData["Idrol"] = new SelectList(_context.Rols, "Idrol",
"Descripcion", usuario.Idrol);
return View(usuario);
}
// GET: Usuarios/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if (id == null)
{
return NotFound();
}
return View(usuario);
}
// POST: Usuarios/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
var usuario = await _context.Usuarios.FindAsync(id);
_context.Usuarios.Remove(usuario);
TempData["Message"] = $"El Producto '{usuario.Nombre}
{usuario.Apellido}' se elimino correctamente";
TempData["class"] = "alert alert-info alert-dismissible fade
show";
TempData["icon"] = "bi bi-info-circle me-1";
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
}
}
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using StorePlace.Models;
using StorePlace.Models.ViewsModels;
namespace StorePlace.Controllers
{
[Authorize(Roles = "Administrador,Cajero")]
public class VentasController : Controller
{
private readonly storeplacedbContext _context;
// GET: Ventas
public async Task<IActionResult> Index()
{
var storeplacedbContext = _context.Venta.Include(v =>
v.IdclienteNavigation).Include(v => v.IdusuarioNavigation);
return View(await storeplacedbContext.ToListAsync());
}
// GET: Ventas/Details/5
public async Task<IActionResult> Details(uint? id)
{
if (id == null)
{
return NotFound();
}
return View(venta);
}
// GET: Ventas/Create
public IActionResult Create()
{
IEnumerable<Producto> Productos = _context.Productos.Include(p
=> p.IdcategoriaNavigation);
Tuple<Venta, IEnumerable<Producto>> model = new Tuple<Venta,
IEnumerable<Producto>>(new Venta(), Productos);
var Cliente = _context.Clientes.Select(x => new { x.Idcliente,
Nombre = string.Join(" ", x.Nit, x.Nombre, x.Apellido) }).ToList();
ViewData["Idcliente"] = new SelectList(Cliente, "Idcliente",
"Nombre");
ViewData["Idproducto"] = new SelectList(_context.Productos,
"Barcode", "Nombre");
return View(model);
}
// POST: Ventas/Create
// To protect from overposting attacks, enable the specific
properties you want to bind to.
// For more details, see http://go.microsoft.com/fwlink/?
LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult>
Create([Bind("Idventa,Idcliente,Idusuario,Fecha,Total")] Venta venta)
{
if (ModelState.IsValid)
{
_context.Add(venta);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
ViewData["Idcliente"] = new SelectList(_context.Clientes,
"Idcliente", "Idcliente", venta.Idcliente);
ViewData["Idusuario"] = new SelectList(_context.Usuarios,
"Idusuario", "Idusuario", venta.Idusuario);
return View(venta);
}
// GET: Ventas/Edit/5
public async Task<IActionResult> Edit(uint? id)
{
if (id == null)
{
return NotFound();
}
[HttpPost]
public JsonResult Add(VentaViewModel venta)
{
using (var Transaccion = _context.Database.BeginTransaction())
{
try
{
Venta _Venta = new Venta
{
Idcliente = venta.Idcliente,
Idusuario = venta.Idusuario,
Fecha = Convert.ToDateTime(DateTime.Now),
Total = venta.Total
};
_context.Add(_Venta);
_context.SaveChanges();
_context.SaveChanges();
//ViewBag.Message = "Registro insertado";
Transaccion.Commit();
return Json(true);
}
catch (Exception ex)
{
Transaccion.Rollback();
return Json(venta);
}
}
MODELS
using System;
using System.Collections.Generic;
namespace StorePlace.Models
{
public partial class CategoriaCliente
{
public CategoriaCliente()
{
Clientes = new HashSet<Cliente>();
}
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace StorePlace.Models
{
public partial class Venta
{
public Venta()
{
DetalleVenta = new HashSet<DetalleVenta>();
}
using System;
using System.Collections.Generic;
namespace StorePlace.Models
{
public partial class Usuario
{
public Usuario()
{
Ingresos = new HashSet<Ingreso>();
Venta = new HashSet<Venta>();
}
using System;
using System.Collections.Generic;
namespace StorePlace.Models
{
public partial class Proveedor
{
public Proveedor()
{
Ingresos = new HashSet<Ingreso>();
}
using System;
using System.Collections.Generic;
namespace StorePlace.Models
{
public partial class Producto
{
public Producto()
{
DetalleIngresos = new HashSet<DetalleIngreso>();
DetalleVenta = new HashSet<DetalleVenta>();
}
namespace StorePlace.Models
{
public partial class DetalleIngreso
{
public int IddetalleIngreso { get; set; }
public int Idingreso { get; set; }
public string? Idproducto { get; set; }
public int Cantidad { get; set; }
public decimal? Precio { get; set; }
using System;
using System.Collections.Generic;
namespace StorePlace.Models
{
public partial class Cliente
{
public Cliente()
{
Venta = new HashSet<Venta>();
}
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
namespace StorePlace.Models
{
public partial class storeplacedbContext : DbContext
{
public storeplacedbContext()
{
}
public storeplacedbContext(DbContextOptions<storeplacedbContext>
options)
: base(options)
{
}
modelBuilder.Entity<CategoriaCliente>(entity =>
{
entity.HasKey(e => e.Idcategoria)
.HasName("PRIMARY");
entity.ToTable("categoria_cliente");
modelBuilder.Entity<CategoriaProducto>(entity =>
{
entity.HasKey(e => e.Idcategoria)
.HasName("PRIMARY");
entity.ToTable("categoria_producto");
modelBuilder.Entity<Cliente>(entity =>
{
entity.HasKey(e => e.Idcliente)
.HasName("PRIMARY");
entity.ToTable("cliente");
modelBuilder.Entity<DetalleIngreso>(entity =>
{
entity.HasKey(e => e.IddetalleIngreso)
.HasName("PRIMARY");
entity.ToTable("detalle_ingreso");
modelBuilder.Entity<DetalleVenta>(entity =>
{
entity.HasKey(e => e.IddetalleVenta)
.HasName("PRIMARY");
entity.ToTable("detalle_venta");
modelBuilder.Entity<Ingreso>(entity =>
{
entity.HasKey(e => e.Idingreso)
.HasName("PRIMARY");
entity.ToTable("ingreso");
modelBuilder.Entity<Producto>(entity =>
{
entity.HasKey(e => e.Barcode)
.HasName("PRIMARY");
entity.ToTable("producto");
modelBuilder.Entity<Proveedor>(entity =>
{
entity.HasKey(e => e.Idproveedor)
.HasName("PRIMARY");
entity.ToTable("proveedor");
modelBuilder.Entity<Rol>(entity =>
{
entity.HasKey(e => e.Idrol)
.HasName("PRIMARY");
entity.ToTable("rol");
modelBuilder.Entity<Usuario>(entity =>
{
entity.HasKey(e => e.Idusuario)
.HasName("PRIMARY");
entity.ToTable("usuario");
modelBuilder.Entity<Venta>(entity =>
{
entity.HasKey(e => e.Idventa)
.HasName("PRIMARY");
entity.ToTable("venta");
OnModelCreatingPartial(modelBuilder);
}
CONEXIÓN
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"default": "server=localhost;port=3306;user=root;database=storeplacedb"
},
"AppSettings": {
"Language": "es"
}
}
namespace StorePlace
{
public class Encrypt
{
public static string Encriptar(string str)
{
if(str != null)
{
SHA256 sha256 = SHA256Managed.Create();
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] stream = null;
StringBuilder sb = new StringBuilder();
stream = sha256.ComputeHash(encoding.GetBytes(str));
for (int i = 0; i < stream.Length; i++)
sb.AppendFormat("{0:x2}", stream[i]);
return sb.ToString();
}
return "";
}