コード例 #1
0
        public async Task <ProductoEntity> Update(ProductoEntity entity)
        {
            var updateEntity = _pruebaTredaDBContext.Productos.Update(entity);
            await _pruebaTredaDBContext.SaveChangesAsync();

            return(updateEntity.Entity);
        }
コード例 #2
0
ファイル: daProducto.cs プロジェクト: jonysosin/orterce-1
        public ProductoEntity CrearEntidad(OdbcDataReader dr)
        {
            ProductoEntity entidad = new ProductoEntity();

            entidad.IdProducto  = Convert.ToInt32(dr["IdProducto"]);
            entidad.IdCategoria = Convert.ToInt32(dr["IdCategoria"]);
            entidad.Nombre      = dr["Nombre"].ToString();
            entidad.Descripcion = dr["Descripcion"].ToString();
            entidad.Precio      = Convert.ToDouble(dr["Precio"]);
            entidad.Iva         = Convert.ToInt32(dr["Iva"]);
            entidad.Stock       = Convert.ToInt32(dr["Stock"]);
            entidad.Peso        = Convert.ToInt32(dr["Peso"]);
            entidad.Color       = dr["Color"].ToString();
            entidad.Modelo      = dr["Modelo"].ToString();
            entidad.Medida      = dr["Medida"].ToString();
            if (dr["Imagen"].ToString().Equals(""))
            {
                entidad.Imagen = "img/0.jpg";
            }
            else
            {
                entidad.Imagen = dr["Imagen"].ToString();
            }
            return(entidad);
        }
コード例 #3
0
ファイル: daProducto.cs プロジェクト: jonysosin/orterce-1
        public void Eliminar(int id)
        {
            ProductoEntity entidad = new ProductoEntity();

            entidad.IdProducto = id;
            EjecutarComando(daComun.TipoComandoEnum.Eliminar, entidad);
        }
コード例 #4
0
ファイル: daProducto.cs プロジェクト: jonysosin/orterce-1
        private void CrearParametros(OdbcCommand command, ProductoEntity entidad)
        {
            OdbcParameter parameter = null;

            parameter       = command.Parameters.Add("?", OdbcType.VarChar);
            parameter.Value = entidad.Nombre;

            parameter       = command.Parameters.Add("?", OdbcType.VarChar);
            parameter.Value = entidad.Descripcion;

            parameter       = command.Parameters.Add("?", OdbcType.Double);
            parameter.Value = entidad.Precio;

            parameter       = command.Parameters.Add("?", OdbcType.Int);
            parameter.Value = entidad.Iva;

            parameter       = command.Parameters.Add("?", OdbcType.Int);
            parameter.Value = entidad.Stock;

            parameter       = command.Parameters.Add("?", OdbcType.Int);
            parameter.Value = entidad.Peso;

            parameter       = command.Parameters.Add("?", OdbcType.VarChar);
            parameter.Value = entidad.Color;

            parameter       = command.Parameters.Add("?", OdbcType.VarChar);
            parameter.Value = entidad.Modelo;

            parameter       = command.Parameters.Add("?", OdbcType.VarChar);
            parameter.Value = entidad.Medida;

            parameter       = command.Parameters.Add("?", OdbcType.VarChar);
            parameter.Value = entidad.Imagen;
        }
コード例 #5
0
        public async Task <IActionResult> Create(ProductoViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    ProductoEntity producto = await _converterHelper.ToProductoAsync(model, true);

                    _context.Add(producto);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                catch (DbUpdateException dbUpdateException)
                {
                    if (dbUpdateException.InnerException.Message.Contains("duplicate"))
                    {
                        ModelState.AddModelError(string.Empty, "El código del producto ya existe.");
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, dbUpdateException.InnerException.Message);
                    }
                }
                catch (Exception exception)
                {
                    ModelState.AddModelError(string.Empty, exception.Message);
                }
            }

            model.Categorias = _combosHelper.GetComboCategorias();
            return(View(model));
        }
コード例 #6
0
        public async Task <ActionResult> Create(IFormCollection collection)
        {
            try
            {
                IProductoService servicioProductos = ObtenerServicio();
                string           strAux            = DateTime.Now.ToString();
                ProductoEntity   pe = new ProductoEntity()
                {
                    Id             = int.Parse(collection["Id"].ToString()),
                    Nombre         = collection["Nombre"].ToString(),
                    FechaCaducidad = DateTime.Parse(collection["FechaCaducidad"].ToString()),
                    Tipo           = collection["Tipo"].ToString(),
                    Expirado       = collection["Expirado"].ToString(),
                };


                ProductoEntity pc = await servicioProductos.CreateProductoAsync(pe);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
コード例 #7
0
        // GET: ProductoController/Edit/5
        public async Task <ActionResult> Edit(int id)
        {
            IProductoService servicioProductos = ObtenerServicio();
            ProductoEntity   productoAsync     = await servicioProductos.GetProductoAsync(id);

            return(View(productoAsync));
        }
コード例 #8
0
ファイル: AbmProductos.aspx.cs プロジェクト: mcosta97/orterce
    protected void btnBaja_Click(object sender, EventArgs e)
    {
        ProductoEntity producto = new ProductoEntity();

        producto.IdProducto = Convert.ToInt32(txtId.Text);
        obProducto.EliminarProducto(producto);
        Response.Redirect("AbmProductos.aspx");
    }
コード例 #9
0
        public async Task <ProductoEntity> Add(ProductoEntity entity)
        {
            await _pruebaTredaDBContext.Productos.AddAsync(entity);

            await _pruebaTredaDBContext.SaveChangesAsync();

            return(entity);
        }
コード例 #10
0
 public static void CrearProducto(ProductoEntity producto)
 {
     if (ValidarProducto(producto))
     {
         daProducto da = new daProducto();
         da.Insertar(producto);
     }
 }
コード例 #11
0
ファイル: daProducto.cs プロジェクト: jonysosin/orterce-1
        public void Insertar(ProductoEntity entidad)
        {
            daContadores da = new daContadores();

            entidad.IdProducto = da.TraerContador(daComun.Contador.Producto) + 1;
            EjecutarComando(daComun.TipoComandoEnum.Insertar, entidad);
            da.Sumar(daComun.Contador.Producto);
        }
コード例 #12
0
 public async Task <IActionResult> Put([FromBody] ProductoEntity Producto)
 {
     try
     {
         return(Ok(await _productService.ActualizarProducto(Producto)));
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #13
0
 public static Producto Map(ProductoEntity entity)
 {
     return(new Producto()
     {
         Sku = entity.Sku,
         Nombre = entity.Nombre,
         Descripcion = entity.Descripcion,
         Valor = entity.Valor,
         Imagen = entity.Imagen,
         TiendaId = entity.TiendaId
     });
 }
コード例 #14
0
ファイル: ConverterHelper.cs プロジェクト: JaguarPoeta/Store
 public ProductoViewModel ToProductViewModel(ProductoEntity product)
 {
     return(new ProductoViewModel
     {
         Categorias = _combosHelper.GetComboCategorias(),
         Categoria = product.Categoria,
         CategoriaId = product.Categoria.Id,
         Id = product.Id,
         IsActive = product.IsActive,
         Nombre = product.Nombre,
         Precio = product.Precio,
     });
 }
コード例 #15
0
        public async Task <IActionResult> Post([FromBody] ProductoEntity producto)
        {
            try
            {
                var productResult = await _productService.CrearProducto(producto);

                return(Ok(productResult));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
コード例 #16
0
        public async Task <ProductoEntity> UpdateProductoAsync(ProductoEntity producto)
        {
            var content      = JsonConvert.SerializeObject(producto);
            var httpResponse = await _client.PutAsync($"{BaseUrl}/{producto.Id}/", new StringContent(content, Encoding.Default, "application/json"));

            if (!httpResponse.IsSuccessStatusCode)
            {
                throw new Exception("Cannot update producto");
            }

            var productoCreado = JsonConvert.DeserializeObject <ProductoEntity>(await httpResponse.Content.ReadAsStringAsync());

            return(productoCreado);
        }
コード例 #17
0
        public async Task <ProductoEntity> Update(string sku, ProductoEntity updateEnt)
        {
            var entity = await Get(sku);

            entity.Nombre      = updateEnt.Nombre;
            entity.Descripcion = updateEnt.Descripcion;
            entity.Valor       = updateEnt.Valor;
            entity.TiendaId    = updateEnt.TiendaId;
            entity.Imagen      = updateEnt.Imagen;
            _pruebaTredaDBContext.Productos.Update(entity);
            await _pruebaTredaDBContext.SaveChangesAsync();

            return(entity);
        }
コード例 #18
0
 protected void TraerProducto(ProductoEntity producto)
 {
     this.producto    = producto;
     imagen.ImageUrl  = producto.Imagen;
     titulo.Text      = producto.Nombre;
     descripcion.Text = "Descripcion: " + producto.Descripcion;
     stock.Text       = "Stock: " + producto.Stock.ToString();
     precio.Text      = "$" + obProducto.CalcularPrecioIva(producto);
     iva.Text         = "IVA: " + producto.Iva.ToString() + "%";
     modelo.Text      = producto.Modelo;
     medidas.Text     = "Medidas: " + producto.Medida;
     color.Text       = "Color: " + producto.Color;
     peso.Text        = "Peso: " + producto.Peso.ToString();
 }
コード例 #19
0
        public OrdenEntity CreateOrder()
        {
            bool existeOrden = OrdenHelper.CheckOrdenActivaEnMercadoByIdProducto(IdProducto);

            if (Tasa != 0 && !existeOrden)
            {
                OrdenEntity    orden = new OrdenEntity();
                ProductoEntity p     = CachingManager.Instance.GetProductoById(IdProducto);

                orden.CompraVenta         = "V";
                orden.FechaConcertacion   = DateTime.Now.ToUniversalTime();
                orden.IdMercado           = 1;
                orden.IdProducto          = IdProducto;
                orden.IdMoneda            = p.IdMoneda;
                orden.IdPersona           = IdEmpresa;
                orden.IdEnNombreDe        = null;
                orden.Cantidad            = (decimal)PrecioReferencia;
                orden.IdSourceApplication = (byte)SourceEnum.Web;
                orden.PrecioLimite        = Tasa;
                orden.IdTipoOrden         = 1;
                orden.Plazo          = (byte)PlazoOrdenEnum.ContadoInmediato;
                orden.IdEstado       = (int)EstadoOrden.Ingresada;
                orden.IdTipoVigencia = TipoVigencia.NoAplica;
                orden.Rueda          = p.Rueda;
                orden.Tasa           = Tasa;
                orden.IdUsuario      = MAEUserSession.InstanciaCargada ? (int?)MAEUserSession.Instancia.IdUsuario : null;
                if (p.IdTipoProducto == (byte)TiposProducto.FACTURAS)
                {
                    orden.OperoPorTasa   = true;
                    orden.CantidadMinima = orden.Cantidad;
                }


                try
                {
                    OrdenHelper.AltaOrdenDMA(orden);

                    string key = orden.GetProductKey();
                    OrdenHelper.NotificarAsociacionProductoPortfolio(p, orden.Valorizacion, key, IdPersonas, IdEmpresa, portfolio, orden.IdMercado);
                }
                catch (Exception e)
                {
                    throw new M4TraderApplicationException(e.Message);
                }
                return(orden);
            }
            return(null);
        }
コード例 #20
0
        public async Task <ProductoEntity> CrearProducto(ProductoEntity producto)
        {
            try
            {
                producto.RowKey       = Guid.NewGuid().ToString();
                producto.PartitionKey = DateTime.Now.Year.ToString();
                TableOperation operation = TableOperation.Insert(producto);
                await _table.ExecuteAsync(operation);

                return(producto);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #21
0
ファイル: daProducto.cs プロジェクト: jonysosin/orterce-1
        private void EjecutarComando(daComun.TipoComandoEnum sqlCommandType, ProductoEntity entidad)
        {
            OdbcConnection connection = null;
            OdbcCommand    command    = null;

            try {
                connection = (OdbcConnection)connectionDA.GetOpenedConnection();
                IDataParameter paramId = new OdbcParameter("?", OdbcType.Int);
                paramId.Value = entidad.IdProducto;

                switch (sqlCommandType)
                {
                case daComun.TipoComandoEnum.Insertar:
                    command = new OdbcCommand(SQLInsert, connection);
                    command.Parameters.Add(paramId);
                    CrearParametros(command, entidad);
                    break;

                case daComun.TipoComandoEnum.Actualizar:
                    command = new OdbcCommand(SQLUpdate, connection);
                    command.Parameters.Add(paramId);
                    CrearParametros(command, entidad);
                    break;

                case daComun.TipoComandoEnum.Eliminar:
                    command = new OdbcCommand(SQLDelete, connection);
                    command.Parameters.Add(paramId);
                    CrearParametros(command, entidad);
                    break;
                }

                command.ExecuteNonQuery();
                connection.Close();
            } catch (Exception ex) {
                throw new daException(ex);
            } finally {
                if (command != null)
                {
                    command.Dispose();
                }

                if (connection != null)
                {
                    connection.Dispose();
                }
            }
        }
コード例 #22
0
ファイル: AbmProductos.aspx.cs プロジェクト: mcosta97/orterce
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        ProductoEntity producto = new ProductoEntity();

        producto.IdCategoria = new daCategoria().ObtenerCategoriaNombre(ddCategoria.Text).IdCategoria;
        producto.Descripcion = txtDescripcion.Text;
        producto.Nombre      = txtNombre.Text;
        producto.Imagen      = txtImagen.Text;
        producto.Iva         = Convert.ToDouble(txtIva.Text);
        producto.Medida      = txtMedida.Text;
        producto.Modelo      = txtModelo.Text;
        producto.Peso        = Convert.ToInt32(txtPeso.Text);
        producto.Precio      = Convert.ToDouble(txtPrecio.Text);
        producto.Stock       = Convert.ToInt32(txtStock.Text);
        obProducto.ActualizarProducto(producto);
        Response.Redirect("AbmProductos.aspx");
    }
コード例 #23
0
        public static bool TieneStock(ProductoEntity producto, int cantidad)
        {
            ProductoEntity prod;
            bool           tieneStock;

            prod = new daProducto().ObtenerProductosPorId(producto.IdProducto);

            if (prod.Stock >= cantidad)
            {
                tieneStock = true;
            }
            else
            {
                tieneStock = false;
            }

            return(tieneStock);
        }
コード例 #24
0
        public async Task <IActionResult> Edit(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ProductoEntity producto = await _context.ProductoEntities
                                      .Include(p => p.Categoria)
                                      .FirstOrDefaultAsync(p => p.Id == id);

            if (producto == null)
            {
                return(NotFound());
            }

            ProductoViewModel model = _converterHelper.ToProductViewModel(producto);

            return(View(model));
        }
コード例 #25
0
        public async Task <bool> EliminarProducto(string partitionKey, string rowKey)
        {
            try
            {
                ProductoEntity product = await ObtenerProducto(partitionKey, rowKey);

                if (product != null)
                {
                    TableOperation delteOeration = TableOperation.Delete(product);
                    var            delete        = await _table.ExecuteAsync(delteOeration);

                    return(delete.Result != null);
                }
                return(false);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #26
0
ファイル: daProducto.cs プロジェクト: jonysosin/orterce-1
        public ProductoEntity ObtenerProductosPorId(int id)
        {
            OdbcConnection connection = null;
            OdbcCommand    command    = null;
            OdbcDataReader dr         = null;
            ProductoEntity producto;

            try {
                connection = (OdbcConnection)connectionDA.GetOpenedConnection();
                command    = new OdbcCommand(SQLSearchTablaId, connection);
                command.Parameters.Add("?", OdbcType.Int);
                command.Parameters[0].Value = id;
                dr       = command.ExecuteReader();
                producto = new ProductoEntity();

                while (dr.Read())
                {
                    producto = CrearEntidad(dr);
                }

                connection.Close();
            } catch (Exception ex) {
                throw new daException(ex);
            } finally {
                dr = null;
                if (command != null)
                {
                    command.Dispose();
                }
                if (connection != null)
                {
                    connection.Dispose();
                }
            }

            return(producto);
        }
コード例 #27
0
        public async Task <ProductoEntity> ActualizarProducto(ProductoEntity producto)
        {
            try
            {
                ProductoEntity productoResult = await ObtenerProducto(producto.PartitionKey, producto.RowKey);

                if (productoResult != null)
                {
                    TableOperation operation       = TableOperation.InsertOrReplace(producto);
                    var            productResponse = await _table.ExecuteAsync(operation);

                    return(productResponse.Result as ProductoEntity);
                }
                else
                {
                    throw new Exception("El producto no exite");
                }
                return(await ObtenerProducto(producto.PartitionKey, producto.RowKey));
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #28
0
        public override ExecutionResult ExecuteCommand(InCourseRequest inCourseRequest)
        {
            if (OrdenHelper.ObtenerOrdenOperacionByProducto(IdProducto.Value))
            {
                throw new M4TraderApplicationException("Ya se cerró una orden para este producto");
            }

            OrdenEntity orden = new OrdenEntity();

            orden.CompraVenta       = CompraOVenta;
            orden.FechaConcertacion = DateTime.Now.ToUniversalTime();

            orden.IdMercado = IdMercado;
            ProductoEntity producto = new ProductoEntity();

            if (CodigoProducto != null)
            {
                producto = CachingManager.Instance.GetProductoByCodigoMonedaDefaultAndRueda(CodigoProducto, orden.IdMercado, SegmentMarketId);
            }
            else
            {
                producto = CachingManager.Instance.GetProductoById(IdProducto.Value);
            }
            orden.IdProducto          = producto.IdProducto;
            orden.IdMoneda            = IdMoneda.HasValue ? IdMoneda.Value : producto.IdMoneda;
            orden.Rueda               = SegmentMarketId;
            orden.IdPersona           = IdPersona.HasValue ? IdPersona.Value : MAEUserSession.Instancia.IdPersona;
            orden.IdEnNombreDe        = IdEnNombreDe;
            orden.Cantidad            = Cantidad;
            orden.CantidadMinima      = OfertaParcial ? CantidadMinima : Cantidad;
            orden.IdSourceApplication = (byte)Source;
            orden.IdEstado            = (int)EstadoOrden.Ingresada;
            orden.OperoPorTasa        = OperoPorTasa;
            orden.Tasa      = Tasa;
            orden.IdUsuario = MAEUserSession.InstanciaCargada ? (int?)MAEUserSession.Instancia.IdUsuario : null;
            if (!StopType)
            {
                orden.PrecioLimite = PrecioLimite;
            }

            if (CodigoPlazoType == "")
            {
                CodigoPlazoType = "CI";
            }

            orden.Plazo = PlazoType.HasValue ? PlazoType.Value : CachingManager.Instance.GetAllPlazos().Find(x => x.Descripcion == CodigoPlazoType).IdPlazo;
            //if (orden.Plazo == (byte)PlazoOrdenEnum.Futuro)
            //{
            //    orden.FechaLiquidacion = CachingManager.Instance.GetFechaLiquidacionByIdProductoAndPlazo(orden.Plazo, orden.IdProducto).FechaLiquidacion;
            //}
            orden.IdTipoVigencia = IdTipoVigencia.HasValue ? (TipoVigencia)IdTipoVigencia.Value : TipoVigencia.NoAplica;

            if (orden.IdTipoVigencia != TipoVigencia.NoAplica)
            {
                orden.FechaVencimiento = FechaVencimiento;
            }

            if (OrderType == "")
            {
                OrderType = "0";
            }

            if (producto.IdTipoProducto == (byte)TiposProducto.FACTURAS)
            {
                OrderType            = "3";
                orden.OperoPorTasa   = true;
                orden.Tasa           = Tasa;
                orden.CantidadMinima = orden.Cantidad;
            }
            TipoOrdenEntity tipoOrden = CachingManager.Instance.GetTipoOrdenByCodigo(OrderType);

            if (tipoOrden != null)
            {
                orden.IdTipoOrden = tipoOrden.IdTipoOrden;
            }
            ResponseGenerico resultado = new ResponseGenerico();

            ordenes = new List <OrdenEntity>();
            ordenes.Add(orden);

            resultado.Resultado = (byte)eResult.Ok;
            OrdenHelper.AltaOrdenDMA(orden);
            orden.TimestampStr = BitConverter.ToString(orden.Timestamp, 0);
            resultado.Detalle  = JsonConvert.SerializeObject(orden);
            return(ExecutionResult.ReturnInmediatelyAndQueueOthers(resultado));
        }
コード例 #29
0
 public void Put(int id, [FromBody] ProductoEntity value)
 {
     listaProductos.RemoveAll(p => p.Id == id);
     listaProductos.Add(value);
 }
コード例 #30
0
 public void Post([FromBody] ProductoEntity value)
 {
     listaProductos.Add(value);
 }