public IActionResult Agregar(ProductosViewModel vm) { fruteriashopContext context = new fruteriashopContext(); if (vm.Archivo.ContentType != "image/jpeg" || vm.Archivo.Length > 1024 * 1024 * 2) { ModelState.AddModelError("", "Debe selecionar un archivo jpg de menos de 2mb"); CategoriasRepository categoriasRepository = new CategoriasRepository(context); vm.Categorias = categoriasRepository.GetAll(); return(View(vm)); } try { ProductosRepository repos = new ProductosRepository(context); repos.Insert(vm.Producto); //Guardar archivo de inserción FileStream fs = new FileStream(Environment.WebRootPath + "/img_frutas/" + vm.Producto.Id + ".jpg", FileMode.Create); vm.Archivo.CopyTo(fs); fs.Close(); return(RedirectToAction("Index")); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); CategoriasRepository categoriasRepository = new CategoriasRepository(context); vm.Categorias = categoriasRepository.GetAll(); return(View(vm)); } }
public IActionResult Editar(int Id) { fruteriashopContext context = new fruteriashopContext(); ProductosRepository repos = new ProductosRepository(context); ProductosViewModel vm = new ProductosViewModel(); vm.Producto = repos.Get(Id); if (vm.Producto == null) { return(RedirectToAction("Index")); } CategoriasRepository cr = new CategoriasRepository(context); vm.Categorias = cr.GetAll().Where(x => x.Eliminado == false).OrderBy(x => x.Nombre); if (System.IO.File.Exists(Enviroment.WebRootPath + $"/img_frutas/{vm.Producto.Id}.jpg")) { vm.Imagen = vm.Producto.Id + ".jpg"; } else { vm.Imagen = "no-disponible.png"; } return(View(vm)); }
public IActionResult Editar(int id) { fruteriashopContext context = new fruteriashopContext(); ProductosViewModel vm = new ProductosViewModel(); ProductosRepository pr = new ProductosRepository(context); vm.Producto = pr.Get(id); if (vm.Producto == null) { return(RedirectToAction("Index")); } CategoriasRepository cr = new CategoriasRepository(context); vm.Categorias = cr.GetAll(); if (System.IO.File.Exists(Environment.WebRootPath + $"/img_frutas/{vm.Producto.Id}.jpg")) { vm.Imagen = vm.Producto.Id + ".jpg"; } else { vm.Imagen = "no-disponible.png"; } return(View(vm)); }
public PosUnitOfWork(PosDbContext context) { _context = context; AlmacenesRepository = new AlmacenesRepository(_context); CatalogoSatRepository = new CatalogoSatRepository(_context); ComprasRepository = new ComprasRepository(_context); CortesRepository = new CortesRepository(_context); DepartamentosRepository = new DepartamentosRepository(_context); ImpuestoProductosRepository = new ImpuestoProductosRepository(_context); ImpuestosRepository = new ImpuestosRepository(_context); MarcaRepository = new MarcaRepository(_context); OrdenesRepository = new OrdenesRepository(_context); PantallasRepository = new PantallasRepository(_context); PantallasUsuarioRepository = new PantallasUsuarioRepository(_context); PLUProductoRepository = new PLUProductosRepository(_context); ProductoAlmacenRepository = new ProductoAlmacenRepository(_context); ProductosCompraRepository = new ProductosCompraRepository(_context); ProductosOrdenRepository = new ProductosOrdenRepository(_context); ProductosPromocionRepository = new ProductosPromocionRepository(_context); ProductosProveedorRepository = new ProductosProveedorRepository(_context); ProductosRepository = new ProductosRepository(_context); ProductosVentaRepository = new ProductosVentaRepository(_context); PromocionesRepository = new PromocionesRepository(_context); ProveedoresRepository = new ProveedoresRepository(_context); RetirosRepository = new RetirosRepository(_context); TipoPagoRepository = new TipoPagoRepository(_context); TipoUsuarioRepository = new TipoUsuarioRepository(_context); TurnosRepository = new TurnosRepository(_context); UnidadesRepository = new UnidadesRepository(_context); UnidadSatRepository = new UnidadSatRepository(_context); UsuariosRepository = new UsuariosRepository(_context); VentaImpuestosRepository = new VentaImpuestosRepository(_context); VentaPagosRepository = new VentaPagosRepository(_context); VentasRepository = new VentasRepository(_context); }
public UnitOfWork(OrionDbContext dbContext) { _dbContext = dbContext; TiposUsuarios = new TiposUsuarioRepository(_dbContext); Usuarios = new UsuariosRepository(_dbContext); Productos = new ProductosRepository(_dbContext); Ventas = new VentasRepository(_dbContext); }
public IActionResult Agregar(ProductosViewModel pvm) { fruteriashopContext context = new fruteriashopContext(); //guardar el archivo de la imagen try { if (pvm.Archivo == null) { ModelState.AddModelError("", "Debe seleccionar una imagen para el producto"); CategoriasRepository categoriasRepository = new CategoriasRepository(context); pvm.Categorias = categoriasRepository.GetAll(); return(View(pvm)); } else { if (pvm.Archivo.ContentType != "image/jpeg" || pvm.Archivo.Length > 1024 * 1024 * 2) { ModelState.AddModelError("", "Debe seleccionar un archivo jpg de menos de 2MB."); CategoriasRepository categoriasRepository = new CategoriasRepository(context); pvm.Categorias = categoriasRepository.GetAll(); return(View(pvm)); } } ProductosRepository repos = new ProductosRepository(context); repos.Insert(pvm.Producto); if (pvm.Archivo != null) { FileStream fs = new FileStream(Enviroment.WebRootPath + "/img_frutas/" + pvm.Producto.Id + ".jpg", FileMode.Create); pvm.Archivo.CopyTo(fs); fs.Close(); } return(RedirectToAction("Index")); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); CategoriasRepository categoriasRepository = new CategoriasRepository(context); pvm.Categorias = categoriasRepository.GetAll(); return(View(pvm)); } }
public IActionResult Ver(string categoria, string id) { using (fruteriashopContext context = new fruteriashopContext()) { ProductosRepository repos = new ProductosRepository(context); Productos p = repos.GetProductosByCategoriaNombre(categoria, id.Replace("-", " ")); return(View(p)); } }
public ClientController(ClientRepository repository, IMapper mapper, BeneficiarioRepository Brepository, IbankingContext context, ProductosRepository Prepository) { _repository = repository; _mapper = mapper; _Brepository = Brepository; _context = context; _Prepository = Prepository; }
public IActionResult Index(ProductosIndexViewModel vm) { fruteriashopContext context = new fruteriashopContext(); CategoriasRepository categoriasRepos = new CategoriasRepository(context); ProductosRepository productosRepos = new ProductosRepository(context); vm.Categorias = categoriasRepos.GetAll(); vm.Productos = productosRepos.GetProductosByCategoria(vm.IdCategoria); return(View(vm)); }
public AdminController(AdminRepository repository, IbankingContext context, IMapper mapper, UserManager <IdentityUser> userManager, SignInManager <IdentityUser> signInManager, ProductosRepository Prepository) { _repository = repository; _context = context; _mapper = mapper; _userManager = userManager; _signInManager = signInManager; _Prepository = Prepository; }
public IActionResult Categoria(string id) { using (fruteriashopContext context = new fruteriashopContext()) { ProductosRepository repos = new ProductosRepository(context); CategoriaViewModel vm = new CategoriaViewModel(); vm.Nombre = id; vm.Productos = repos.GetProductosByCategoria(id).ToList(); return(View(vm)); } }
public IActionResult Ver(string categoria, string id) { using (fruteriashopContext context = new fruteriashopContext())//el contexto no se instancia dentro del repositorio ya que no queremos que se hagan multiples conexiones { ProductosRepository repos = new ProductosRepository(context); Productos p = repos.GetProductosbyCategoriaNombre(categoria, id.Replace("-", " ")); return(View(p)); } }
public IActionResult Index() { ProductosIndexViewModel pivm = new ProductosIndexViewModel(); fruteriashopContext context = new fruteriashopContext(); CategoriasRepository cr = new CategoriasRepository(context); ProductosRepository pr = new ProductosRepository(context); int?id = null; pivm.Categorias = cr.GetAll(); pivm.Productos = pr.GetProductosByCategoria(id); return(View(pivm)); }
public IActionResult Editar(ProductosViewModel pvm) { fruteriashopContext context = new fruteriashopContext(); if (pvm.Archivo != null) { if (pvm.Archivo.ContentType != "image/jpeg" || pvm.Archivo.Length > 1024 * 1024 * 2) { ModelState.AddModelError("", "Debe seleccionar un archivo jpg de menos de 2MB."); CategoriasRepository categoriasRepository = new CategoriasRepository(context); pvm.Categorias = categoriasRepository.GetAll(); return(View(pvm)); } } try { ProductosRepository repos = new ProductosRepository(context); //busca el producto que queremos editar var p = repos.Get(pvm.Producto.Id); if (p != null) { p.Nombre = pvm.Producto.Nombre; p.IdCategoria = pvm.Producto.IdCategoria; p.Precio = pvm.Producto.Precio; p.Descripcion = pvm.Producto.Descripcion; p.UnidadMedida = pvm.Producto.UnidadMedida; repos.Update(p); } if (pvm.Archivo != null) { FileStream fs = new FileStream(Enviroment.WebRootPath + "/img_frutas/" + pvm.Producto.Id + ".jpg", FileMode.Create); pvm.Archivo.CopyTo(fs); fs.Close(); } return(RedirectToAction("Index")); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); CategoriasRepository categoriasRepository = new CategoriasRepository(context); pvm.Categorias = categoriasRepository.GetAll(); return(View(pvm)); } }
public AdminController(UserManager <IdentityUser> userManager, SignInManager <IdentityUser> signInManager, RoleManager <IdentityRole> role, IMapper mapper, AdminRepository adminrepository, ProductosRepository productsrepository, PagosRepository pagosrepository, TransferenciasRepository transrepository) { _userManager = userManager; _signInManager = signInManager; _role = role; this._mapper = mapper; this._adminrepository = adminrepository; this._productsrepository = productsrepository; this._pagosrepository = pagosrepository; this._transrepository = transrepository; }
public IActionResult Categoria(string id) { using (fruteriashopContext context = new fruteriashopContext()) { //fruteriashopContext context = new fruteriashopContext(); ProductosRepository repos = new ProductosRepository(context); CategoriaViewModel vm = new CategoriaViewModel(); vm.Nombre = id; vm.Productos = repos.GetProductosByCategoria(id).ToList();//to list es mas rapido porque no lo consulta en la bd si no que ya se encuentra en la memoria return(View(vm)); } }
public IActionResult Index() { ProductosIndexViewModel vm = new ProductosIndexViewModel(); fruteriashopContext context = new fruteriashopContext(); CategoriasRepository categoriasRepository = new CategoriasRepository(context); ProductosRepository productosRepository = new ProductosRepository(context); int?id = null; vm.Categorias = categoriasRepository.GetAll().Where(x => x.Eliminado == 0); vm.Productos = productosRepository.GetProductosByCategoria(id); return(View(vm)); }
public IActionResult Index() { ProductosIndexViewModel vm = new ProductosIndexViewModel(); fruteriashopContext context = new fruteriashopContext(); //Una sola conexion pero dla utilizan los dos repositorios CategoriasRepository categoriasrepository = new CategoriasRepository(context); ProductosRepository productosRepository = new ProductosRepository(context); int?id = 0; vm.Categorias = categoriasrepository.GetAll(); vm.Productos = productosRepository.GetProductosByCategoria(id); return(View(vm)); }
public IActionResult Editar(ProductosViewModel vm) { fruteriashopContext context = new fruteriashopContext(); if (vm.Archivo != null) { if (vm.Archivo.ContentType != "image/jpeg" || vm.Archivo.Length > 1024 * 1024 * 2) { ModelState.AddModelError("", "Debe seleccionar un archivo jpg de menos de 2MB."); CategoriasRepository repos = new CategoriasRepository(context); vm.Categorias = repos.GetAll().Where(x => x.Eliminado == false).OrderBy(x => x.Nombre); return(View(vm)); } } try { ProductosRepository repos = new ProductosRepository(context); var producto = repos.Get(vm.Producto.Id); if (producto != null) { producto.Nombre = vm.Producto.Nombre; producto.Precio = vm.Producto.Precio; producto.IdCategoria = vm.Producto.IdCategoria; producto.Descripcion = vm.Producto.Descripcion; producto.UnidadMedida = vm.Producto.UnidadMedida; repos.Update(producto); if (vm.Archivo != null) { FileStream fs = new FileStream(Enviroment.WebRootPath + "/img_frutas/" + vm.Producto.Id + ".jpg", FileMode.Create); vm.Archivo.CopyTo(fs); fs.Close(); } } return(RedirectToAction("Index")); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); CategoriasRepository repos = new CategoriasRepository(context); vm.Categorias = repos.GetAll().OrderBy(x => x.Nombre); return(View(vm)); } }
public IActionResult Eliminar(int id) { using (fruteriashopContext context = new fruteriashopContext()) { ProductosRepository repos = new ProductosRepository(context); var p = repos.Get(id); if (p != null) { return(View(p)); } else { return(RedirectToAction("Index")); } } }
public IActionResult Index() { ProductosIndexViewModel vm = new ProductosIndexViewModel(); fruteriashopContext context = new fruteriashopContext(); CategoriasRepository categoriarepos = new CategoriasRepository(context); ProductosRepository productosrepos = new ProductosRepository(context); int?id = null; // AGREGUÉ EL WHERE PARA QUE NO SE MUESTRE LA CATEGORÍA SI FUÉ ELIMINADA DE MANERA LOGICA vm.Categorias = categoriarepos.GetAll().Where(x => x.Eliminado == false).OrderBy(x => x.Nombre); vm.Productos = productosrepos.GetProductosByCategoria(id); return(View(vm)); }
public IActionResult Agregar(ProductosViewModel vm) { fruteriashopContext context = new fruteriashopContext(); try { if (vm.Archivo == null) { ModelState.AddModelError("", "Debe seleccionar la imagen del producto."); CategoriasRepository categoriasrepos = new CategoriasRepository(context); vm.Categorias = categoriasrepos.GetAll().Where(x => x.Eliminado == false).OrderBy(x => x.Nombre); return(View(vm)); } else { if (vm.Archivo.ContentType != "image/jpeg" || vm.Archivo.Length > 1024 * 1024 * 2) { ModelState.AddModelError("", "Debe seleccionar un archivo jpg de menos de 2MB."); CategoriasRepository repos = new CategoriasRepository(context); vm.Categorias = repos.GetAll().Where(x => x.Eliminado == false).OrderBy(x => x.Nombre); return(View(vm)); } } ProductosRepository productosrepos = new ProductosRepository(context); productosrepos.Insert(vm.Producto); if (vm.Archivo != null) { FileStream fs = new FileStream(Enviroment.WebRootPath + "/img_frutas/" + vm.Producto.Id + ".jpg", FileMode.Create); vm.Archivo.CopyTo(fs); fs.Close(); } return(RedirectToAction("Index")); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); CategoriasRepository repos = new CategoriasRepository(context); vm.Categorias = repos.GetAll().OrderBy(x => x.Nombre); return(View(vm)); } }
public IActionResult Eliminar(Productos p) { using (fruteriashopContext context = new fruteriashopContext()) { ProductosRepository repos = new ProductosRepository(context); var producto = repos.Get(p.Id); if (producto != null) { repos.Delete(producto); return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "El producto no existe o ya ha sido eliminado."); return(View(p)); } } }
public PostearDatosEnPortalWebService(Serilog.ILogger logger, IMapper mapper, IConfiguration configuration, BonificacionesRepository _bonificacionesRepository, ClientesRepository _clientesRepository, ClienteDireccionesDeEntregaRepository _clientesDireccionesEntregaRepository, ListasDePrecioRepository _listasDePrecioRepository, ProductosRepository _productosRepository, ProvinciasRepository _provinciasRepository, TransportistasRedespachoRepository _transportistasRedespachoRepository, UsuariosRepository _usuariosRepository, VendedoresRepository _vendedoresRepository) { _logger = logger; _mapper = mapper; _configuration = configuration; BonificacionesRepository = _bonificacionesRepository; ClientesRepository = _clientesRepository; ClientesDireccionesEntregaRepository = _clientesDireccionesEntregaRepository; ListasDePrecioRepository = _listasDePrecioRepository; ProductosRepository = _productosRepository; ProvinciasRepository = _provinciasRepository; TransportistasRedespachoRepository = _transportistasRedespachoRepository; UsuariosRepository = _usuariosRepository; VendedoresRepository = _vendedoresRepository; }
public ProductosService(string connectionString, string providerName) { conexion = new ConnectionManager(connectionString); repositorio = new ProductosRepository(conexion); }
//private readonly IUnitOfWork unitOfWork; public ProductosController(ProductosRepository productos, Repository <Categoria> categorias) { this.productos = productos; this.categorias = categorias; }
public ProductoController(ProductosRepository p) { pr = p; }
public ProductosController() { repositorio = new ProductosRepository(); }
//private readonly IUnitOfWork unitOfWork; public ProductosController(ProductosRepository productos, Repository<Categoria> categorias) { this.productos = productos; this.categorias = categorias; }