Esempio n. 1
0
 public Product GetById(Guid id)
 {
     return(_context.Product
            .AsNoTracking()
            .Where(ProductQueries.GetById(id))
            .FirstOrDefault());
 }
Esempio n. 2
0
 public InventarioMpVM()
 {
     InventarioMP = new ObservableCollection <MpProduct>(ProductQueries.GetMP());
     Unidades     = new ObservableCollection <string>(ProductQueries.GetUnidades());
     editMp       = new EditMpCommand(this);
     createMp     = new NewMpCommnand(this);
 }
Esempio n. 3
0
        public FormulasVM()
        {
            //General setup
            Formulas           = new ObservableCollection <Formula>(FormulaQueries.GetFormulas());
            InactiveFormulas   = new ObservableCollection <Formula>(FormulaQueries.GetFormulasInactivas());
            NewFormulaProducts = new ObservableCollection <formulaProduct>(ProductQueries.GetFormulaProducts());

            NuevaFormulaCommand          = new NewFormulaCommand(this);
            AddDetalleNewFormulaDataGrid = new NewFormulaDetalleDatagridCommand(this);
            newFormulaAddInstruction     = new NewFormulaAddInstructionCommand(this);
            editDetalleCommand           = new EditDetalleCommand(this);
            newDetalleCommand            = new NewDetalleCommand(this);
            newInstructionCommand        = new NewInstructionCommand(this);
            editFormulacommand           = new EditFormulaCommand(this);
            Transformations = new ObservableCollection <Formula>(FormulaQueries.GetFormulasTransformaciones());


            UnidadCreada = new ObservableCollection <string> {
                "galones", "kilos"
            };
            FormasFarmaceuticas = new ObservableCollection <string> {
                "jarabe", "tableta", "pildora", "suspension"
            };


            //new formula modal window setup
            NewFormula = new Formula();
            NewFormulaSelectedProduct = new formulaProduct();
            NewFormulaNewDetalle      = new DetalleFormula();
            NewFormulaNewInstruction  = new ProcedimientoDetalle();

            SelectedFormula = Formulas[0];
        }
Esempio n. 4
0
        public FacturasVM()
        {
            Facturas = new ObservableCollection<Factura>(FacturaQueries.GetFacturaList());
            testFactura = FacturaQueries.GetFacturaList();
            Productos = new ObservableCollection<ProductoTeminadoParaLista>(ProductQueries.GetPTSimp());
            Clientes = new ObservableCollection<IdName>(PersonaQueries.getClientes());
            Vendedores = new List<string>(FacturaQueries.getVendedores());


            Zonas = new ObservableCollection<string> { "Norte", "Sur", "Este", "Oeste" };

            editModal = new EditFacturaModal(this);

            ProductPairs = new List<IdName>();


            NewFacturaCommand = new CreateFacturaCommand(this);
            NewFacturaGenerarLotes = new CreateFacturaGenerarLotes(this);
            NewFacturaAddDetalle = new CreateFacturaAddDetalle(this);
            UpdateBalanceCommand = new UpdateFacturaBalanceCommand(this);

            //FacturaEditModal = new OpenEditModal(this);


            IsProductEnabled = true;


        }
        /// <summary>
        /// Action to List any type of product based on MainCategoryId and CategoryType
        /// </summary>
        /// <param name="MainCategoryId">Marble = 1,Granite  = 2, Stone =3 </param>
        /// <param name="CategoryType">Egyptian = 1 , Imported = 2</param>
        /// <returns></returns>
        public async Task <IActionResult> ListProducts(int MainCategoryId, int CategoryType, int pageNumber = 1)
        {
            int PageSize = 10;

            StringBuilder SubImageFolder = CategoryType == 1 ? new StringBuilder("egyptian-") : new StringBuilder("imported-");

            switch (MainCategoryId)
            {
            case 2:
                SubImageFolder.Append("granite");
                break;

            case 1:
                SubImageFolder.Append("marble");
                break;

            default:
                SubImageFolder.Append("stone");
                break;
            }


            #region Get List Of products from API
            var products = await ProductQueries.ListProducts(pageNumber, PageSize, MainCategoryId, CategoryType);

            #endregion
            ViewBag.ImageFolderName = SubImageFolder.ToString();
            return(View(products));
        }
Esempio n. 6
0
        public void RegresarCantidades()
        {
            if (SelectedLotePT.Existencia < PlaceHolder.EmptyCantidad)
            {
                MessageBox.Show("La cantidad a desempacar no puede ser mayor a la cantidad existente");
            }
            else
            {
                NewLotePTDetalles = new ObservableCollection <LotePTDetalle>(ProductQueries.getDetallesFromPTLote(SelectedLotePT.CodigoCorrelativo));


                foreach (LotePTDetalle element in NewLotePTDetalles)
                {
                    InventoryQueries.updateLoteEntradaAmount(element.CodigoLoteMP, PlaceHolder.EmptyCantidad, element.CodigoMP);
                }

                ProductQueries.AdjustExistingLote(SelectedLotePT.CodigoCorrelativo, PlaceHolder, SelectedLotePT.CodigoPT);
                InventoryQueries.updateLoteSalidaAmount(PlaceHolder.EmptyAmount, SelectedLote.CodLote);

                string temp = createRegistro();
                InventoryQueries.CreateReempqueRegistro(temp, SelectedLotePT);

                MessageBox.Show("Producto Desempacado");

                SelectedLotePT.CantidadOriginal = (int.Parse(SelectedLotePT.CantidadOriginal) - PlaceHolder.EmptyCantidad).ToString();
                SelectedLotePT.Existencia      -= PlaceHolder.EmptyCantidad;
                desempaqueModal.Close();
            }
        }
Esempio n. 7
0
        public void OpenLoteCreationModal()
        {
            ListadoMP = new ObservableCollection <formulaProduct>(ProductQueries.GetAllContainerMPFromAmount(int.Parse(NewLotePT.CantidadOriginal)));
            createPTFromLoteCommand = new CreatePTFromLoteCommand(this);
            CanExecuteAgregar       = false;


            if (ListadoMP.Count == 0)
            {
                MessageBox.Show("No hay suficientes empaques para esta cantidad.");
            }
            else
            {
                agregarDetalleEmpaque = new AgregarDetalleEmpaque(this);
                NewLotePTDetalles     = new ObservableCollection <LotePTDetalle>();
                MpListEnabled         = true;
                LoteListEnabled       = false;


                loteModal = new CreatePTLoteModal(this);

                // EmptyMPLote = null;
                EmptyProduct = ListadoMP[0];
                PTList       = new ObservableCollection <ProductoTeminadoParaLista>(ProductQueries.GetPTSimp());
                loteModal.ShowDialog();
            }
        }
Esempio n. 8
0
        public void OpenInfoPaquetesModal(object parameter)
        {
            NewLotePTDetalles = new ObservableCollection <LotePTDetalle>(ProductQueries.getDetallesFromPTLote(SelectedLotePT.CodigoCorrelativo));
            var temp = new DataGridInfoModal(this);

            temp.ShowDialog();
        }
Esempio n. 9
0
        public void CreateProductoTerminado()
        {
            NewLotePT.CodigoLoteSalida = SelectedLote.CodLote;
            NewLotePT.CodigoPT         = SelectedPT.CodPT;
            InventoryQueries.updateLoteSalidaAmount(-PlaceHolder.EmptyAmount, SelectedLote.CodLote);



            ProductQueries.CreateProductoTerminado(NewLotePT, int.Parse(NewLotePT.CantidadOriginal));


            foreach (var element in NewLotePTDetalles)
            {
                element.CodigoLotePT = NewLotePT.CodigoCorrelativo;
                ProductQueries.CreateProductoTerminadoDetalle(element, int.Parse(NewLotePT.CantidadOriginal), element.CodigoMP);
            }



            MessageBox.Show("Lote Producto Terminado Creado");

            SelectedLote.CantidadActual -= PlaceHolder.EmptyAmount;

            loteModal.Close();
            amountModal.Close();
        }
        public static List <string> Products()
        {
            var querys = new ProductQueries();

            var products = querys.GetAllSearchProducts();

            Console.WriteLine($"Setting {products.Count} products");
            var client = ElasticClientFactory.GetElasticClient();
            var erros  = new ConcurrentBag <string>();

            Parallel.ForEach(products, (item) =>
            {
                try
                {
                    var index = client.Index(item, i => i
                                             .Id(item.SkuId));
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Erro on Set Sku :" + item.SkuId);
                    Console.WriteLine(ex.Message);
                    erros.Add(ex.Message);
                    throw ex;
                }
            }
                             );
            return(erros.ToList());
        }
Esempio n. 11
0
 public Book GetById(int id)
 {
     return(_context.Books
            .Include(b => b.Category)
            .Include(b => b.PricingGroup)
            .FirstOrDefault(ProductQueries.GetById(id)));
 }
Esempio n. 12
0
        public void UpdateMP()
        {
            if (ProductQueries.isRepeatedMpCode(NewProduct.Id) && NewProduct.Id != SelectedMP.Id)
            {
                System.Windows.MessageBox.Show("El codigo de MP ya existe.");
            }
            else
            {
                if (NewProduct.Conversion != SelectedMP.Conversion)
                {
                    if (SelectedMP.Existencia != 0)
                    {
                        System.Windows.MessageBox.Show("No se puede cambiar la conversion al menos que el inventario de este producto este en zero.");
                    }
                    else
                    {
                        InventoryQueries.UpdateLoteConversion(SelectedMP.Id, NewProduct.Conversion);
                        ProductQueries.updateMateriaPrimaInfo(NewProduct, SelectedMP.Id);

                        updateCollectionInstance(NewProduct);
                        NewModal.Close();
                        System.Windows.MessageBox.Show("Informacion de MP actualizada.");
                    }
                }
                else
                {
                    ProductQueries.updateMateriaPrimaInfo(NewProduct, SelectedMP.Id);

                    updateCollectionInstance(NewProduct);
                    NewModal.Close();

                    System.Windows.MessageBox.Show("Informacion de MP actualizada.");
                }
            }
        }
Esempio n. 13
0
        public async Task <IActionResult> Index()
        {
            #region Get Main Categories from API
            var mainCategories = await ProductQueries.GetMainGategories();

            #endregion
            return(View(mainCategories));
        }
Esempio n. 14
0
        public IActionResult Products(String JSONFilter)
        {
            Filter filter   = JsonConvert.DeserializeObject <Filter>(JSONFilter);
            var    products = ProductQueries.FatProducts(db, filter);

            ViewData["Bag"] = GetBag();

            return(PartialView("ProductTable", products));
        }
Esempio n. 15
0
        public void Delete(Guid id)
        {
            var product = _context.Product
                          .AsNoTracking()
                          .AsQueryable()
                          .FirstOrDefault(ProductQueries.GetById(id));

            _context.Product.Remove(product);
            _context.SaveChanges();
        }
Esempio n. 16
0
    public IQueryable <TEntity> Set <TEntity>()
        where TEntity : class
    {
        if (typeof(TEntity) == typeof(Customer))
        {
            return((IQueryable <TEntity>)Customers.AsQueryable());
        }

        if (typeof(TEntity) == typeof(Employee))
        {
            return((IQueryable <TEntity>)Employees.AsQueryable());
        }

        if (typeof(TEntity) == typeof(Order))
        {
            return((IQueryable <TEntity>)Orders.AsQueryable());
        }

        if (typeof(TEntity) == typeof(OrderDetail))
        {
            return((IQueryable <TEntity>)OrderDetails.AsQueryable());
        }

        if (typeof(TEntity) == typeof(Product))
        {
            return((IQueryable <TEntity>)Products.AsQueryable());
        }

        if (typeof(TEntity) == typeof(CustomerQuery))
        {
            return((IQueryable <TEntity>)CustomerQueries.AsQueryable());
        }

        if (typeof(TEntity) == typeof(OrderQuery))
        {
            return((IQueryable <TEntity>)OrderQueries.AsQueryable());
        }

        if (typeof(TEntity) == typeof(ProductQuery))
        {
            return((IQueryable <TEntity>)ProductQueries.AsQueryable());
        }

        if (typeof(TEntity) == typeof(ProductView))
        {
            return((IQueryable <TEntity>)ProductViews.AsQueryable());
        }

        if (typeof(TEntity) == typeof(CustomerQueryWithQueryFilter))
        {
            return((IQueryable <TEntity>)CustomerQueriesWithQueryFilter.AsQueryable());
        }

        throw new InvalidOperationException("Invalid entity type: " + typeof(TEntity));
    }
        public async Task <IActionResult> SyncProductsInventory()
        {
            var errorList = new List <string>();

            try
            {
                if (_db.Connection.State == System.Data.ConnectionState.Closed)
                {
                    await _db.Connection.OpenAsync();
                }

                var query    = new ProductQueries(_db);
                var products = await query.GetAllProductInventories();

                foreach (var product in products)
                {
                    var found = _context.ProductInventory.FirstOrDefault(p => p.LocationId == int.Parse(product.warehouse_id.ToString()) && p.ProductId == int.Parse(product.product_id.ToString()));
                    if (found == null)
                    {
                        var productExists = await _context.Product.FindAsync(int.Parse(product.product_id.ToString()));

                        if (productExists != null)
                        {
                            var newProduct = new ProductInventory
                            {
                                ProductId    = int.Parse(product.product_id.ToString()),
                                Balance      = string.IsNullOrEmpty(product.stock) ? 0 : decimal.Parse(product.stock),
                                BinCode      = "",
                                LocationId   = int.Parse(product.warehouse_id.ToString()),
                                ModifiedDate = DateTime.Now,
                            };
                            await _context.ProductInventory.AddAsync(newProduct);

                            await _context.SaveChangesAsync();
                        }
                    }
                    else
                    {
                        found.Balance = string.IsNullOrEmpty(product.stock) ? 0 : decimal.Parse(product.stock);
                        await _context.SaveChangesAsync();
                    }
                }
                _db.Connection.Close();
            }
            catch (Exception ex)
            {
                errorList.Add("order taxes:" + ex.ToString());
            }

            await _emailSender.SendEmailAsync("*****@*****.**", "Sync Finished: Products Inventory", $"Sync Finished: Products Inventory. {string.Join(",", errorList)}");

            return(Ok(errorList));
        }
Esempio n. 18
0
 public IActionResult ProductDetails(string id)
 {
     #region Get details Of a product  by id from API
     var productDetails = ProductQueries.GetProductDetails(id, "en");
     #endregion
     if (productDetails != null)
     {
         return(View(productDetails));
     }
     else
     {
         return(View("~/Views/Shared/404.cshtml"));
     }
 }
Esempio n. 19
0
        public LoteEntVM()
        {
            LotesActivos           = new ObservableCollection <LoteEntrada>(InventoryQueries.GetLotesEntradaActivos());
            LotesPaquetes          = new ObservableCollection <LoteEntrada>(InventoryQueries.GetAllContainerLotes());
            LotesInactivos         = new ObservableCollection <LoteEntrada>(InventoryQueries.GetLotesEntradaInActivos());
            LotesPaquetesInactivos = new ObservableCollection <LoteEntrada>(InventoryQueries.GetAllContainerLotesInactivos());
            MateriaPrima           = new ObservableCollection <formulaProduct>(ProductQueries.GetAllMpSimplifiedNoWater());
            Proveedores            = new ObservableCollection <DisplayProveedor>(PersonaQueries.GetDisplayProveedores());
            PaquetesMP             = new ObservableCollection <formulaProduct>(ProductQueries.GetAllContainersMP());
            newLoteCommand         = new NewLoteEntCommand(this);
            newLotePacakgeCommand  = new NewLotePackageCommand(this);
            NewLote = new LoteEntrada();

            SelectedLoteActivo = new LoteEntrada();
        }
        public ProductsController(IMessagePipelineService pipelineService, ProductQueries productQueries, CompanyQueries companyQueries)
        {
            if (pipelineService == null)
            {
                throw new ArgumentNullException(nameof(pipelineService));
            }
            if (productQueries == null)
            {
                throw new ArgumentNullException(nameof(productQueries));
            }

            this.productQueries  = productQueries;
            this.pipelineService = pipelineService;
            this.companyQueries  = companyQueries;
        }
Esempio n. 21
0
 public void EditPT()
 {
     if (ProductQueries.isRepeatedPtCode(NewProduct.Id))
     {
         System.Windows.MessageBox.Show("Este Codigo de PT ya existe.");
     }
     else
     {
         System.Windows.MessageBox.Show(NewProduct.Id + NewProduct.Nombre + NewProduct.Precio);
         ProductQueries.updateInventarioProductoTerminadoInfo(NewProduct, SelectedProduct.Id);
         System.Windows.MessageBox.Show("Informacion de Producto Actualizada.");
         updateCollectionInstance(NewProduct);
         NewModal.Close();
     }
 }
Esempio n. 22
0
 public void CreateNewMp()
 {
     if (ProductQueries.isRepeatedMpCode(NewProduct.Id))
     {
         System.Windows.MessageBox.Show("El codigo de MP ya existe.");
     }
     else
     {
         ProductQueries.CreateMateriaPrima(NewProduct);
         NewProduct.Existencia = NewProduct.Entrada = NewProduct.Salida = 0;
         InventarioMP.Add(NewProduct);
         Limpiar("");
         System.Windows.MessageBox.Show("Nueva MP agregada al inventario.");
     }
 }
Esempio n. 23
0
        public async Task GetProductsTest()
        {
            // Arrange
            ProductQueries queries = new ProductQueries("Data Source=SupplyPoint.db");

            // Act
            IEnumerable <ProductDto> result = await queries.GetProductsAsync();

            // Assert
            Assert.IsNotNull(result);
            List <ProductDto> resultList = result.ToList();

            Assert.AreEqual(2, resultList.Count());
            Assert.AreEqual("Product 1", resultList[0].Name);
            Assert.AreEqual("Product 2", resultList[1].Name);
        }
Esempio n. 24
0
 public void CreatePT()
 {
     if (ProductQueries.isRepeatedPtCode(NewProduct.Id))
     {
         System.Windows.MessageBox.Show("Este Codigo de PT ya existe.");
     }
     else
     {
         ProductQueries.CreateInventarioProductoTerminado(NewProduct);
         NewProduct.Existencia = 0;
         NewProduct.Entrada    = 0;
         NewProduct.Salida     = 0;
         System.Windows.MessageBox.Show("Producto creado en el inventario.");
         InventarioPt.Add(NewProduct);
         Limpiar();
     }
 }
Esempio n. 25
0
        public IActionResult Index()
        {
            var productList = new ProductListModel()
            {
                FatProducts = ProductQueries.FatProducts(db, null as Filter)
            };

            FilterData Data = new FilterData()
            {
                Characteristics = CharacteristicQueries.Characteristics(db),
                Kinds           = KindQueries.Kinds(db)
            };

            ViewData["FilterData"] = Data;
            ViewData["Bag"]        = GetBag();

            return(View(productList));
        }
        public void showStoreProducts()
        {
            int          storeID = 0;
            StoreQueries stores  = new StoreQueries();

            #region get storeID
            Console.WriteLine("Please enter a StoreID for the location you would like to place your order at");
            string input   = Console.ReadLine();
            bool   invalid = true;
            int    result;
            while (invalid)
            {
                if (!int.TryParse(input, out result) || !stores.existsStore(result))
                {
                    Console.WriteLine("Invalid Input, Please try again.");
                    input = Console.ReadLine();
                }
                else
                {
                    storeID = result;
                    invalid = false;
                }
            }
            #endregion

            #region display products
            ProductQueries products    = new ProductQueries();
            var            productList = products.getProducts(storeID);

            Console.Clear();
            Console.WriteLine("ID\tStore\t\tName\t\tInventory\tPrice");
            foreach (var p in productList)
            {
                Console.WriteLine($"{p.ProductID}\t{p.Store.Location}\t{p.Name}" +
                                  $"\t{p.Inventory}\t\t{p.Price}");
            }
            #endregion

            Console.WriteLine("Press enter to return to the menu");
            Console.ReadLine();
        }
Esempio n. 27
0
        public ReferenciasVM()
        {
            FacturaResults     = new ObservableCollection <Factura>();
            PlaceHolder        = new emptyObject();
            getFacturasCommand = new GetFacturasCommand(this);
            getLotesSalCommand = new GetLotesSalCommand(this);
            Productos          = new ObservableCollection <formulaProduct>(ProductQueries.GetAllMpSimplified());
            Lotes          = new ObservableCollection <LoteEntrada>();
            IsEnabledLotes = false;
            IsEnabledMP    = true;

            PlaceHolder.EmptyCantidad = 12;
            PlaceHolder.EmptyAmount   = 12.21;

            SelectedLote    = new LoteEntrada();
            SelectedProduct = new formulaProduct();

            Tipos = new ObservableCollection <string> {
                "Lote Salida", "Lote Producto Terminado"
            };
        }
Esempio n. 28
0
        public void donateCantidadLoteSal()
        {
            if (SelectedLotePT.Existencia < PlaceHolder.EmptyCantidad)
            {
                MessageBox.Show("La cantidad a donar no puede ser mayor a la cantidad existente");
            }
            else
            {
                NewLotePTDetalles = new ObservableCollection <LotePTDetalle>(ProductQueries.getDetallesFromPTLote(SelectedLotePT.CodigoCorrelativo));



                InventoryQueries.CreateDonacionRegistro(PlaceHolder.EmptyWord, SelectedLotePT, PlaceHolder.EmptyCantidad);
                ProductQueries.updateProductoTermnadoRemoveAmount(SelectedLotePT.CodigoCorrelativo, PlaceHolder.EmptyCantidad);
                ProductQueries.InventarioPTSellAmount(SelectedLotePT.CodigoPT, PlaceHolder.EmptyCantidad);

                MessageBox.Show("Cantidad Donada");

                SelectedLotePT.Existencia -= PlaceHolder.EmptyCantidad;
                donateModal.Close();
            }
        }
        public void Dado_a_consulta_de_produtos_inativos_deve_retornar_2()
        {
            var result = _products.AsQueryable().Where(ProductQueries.GetInactiveProducts());

            Assert.AreEqual(result.Count(), 2);
        }
        public void DadoAhConsultaDeProdutosAtivosDeveRetorna3()
        {
            var result = _products.AsQueryable().Where(ProductQueries.GetActiveProducts());

            Assert.AreEqual(result.Count(), 3);
        }