Exemplo n.º 1
0
        public ActionResult ProductDetail(int idProducto)
        {
            srvProduct sProd = new srvProduct();

            ViewBag.oProducto = sProd.obtenerProducto(idProducto);
            return(View());
        }
Exemplo n.º 2
0
        public ActionResult GuardarModificarProducto(Producto oProducto, string precio, List <HttpPostedFileBase> imagen)
        {
            try
            {
                //usuario oUsuario = (usuario)Session["Usuario"];
                //if (oUsuario == null || oUsuario.idTipoUsuario != 2)
                //{
                //    Session.Clear();
                //    return RedirectToAction("Index", "Home");
                //}
                srvProduct sProducto = new srvProduct();
                oProducto.precio = Convert.ToDecimal(precio.Replace(".", ","));
                //sProducto.GuardarModificarProducto(oProducto);
                foreach (HttpPostedFileBase oImg in imagen)
                {
                    string stNombreArchivo = oImg.FileName.Substring(oImg.FileName.LastIndexOf("\\") + 1).ToString();
                    string stRuta          = "~/Images/Product/";
                    oImg.SaveAs(Server.MapPath(stRuta + stNombreArchivo));
                    sProducto.guardarImagen(oProducto.idProducto, stNombreArchivo);
                }

                return(RedirectToAction("ViewProduct", "Admin"));
            }
            catch (Exception)
            {
                //return RedirectToAction("Error", "Error", new { stError = "Se produjo un error al intentar guardar o modificar el producto." });
                return(RedirectToAction("Index", "Home"));
            }
        }
Exemplo n.º 3
0
        public ActionResult ProductList(string stSearch)
        {
            srvProduct sPro = new srvProduct();

            ViewBag.cantProductos = sPro.TotalProductosBusqueda(stSearch);
            ViewBag.search        = stSearch;
            srvCategories sCategoria = new srvCategories();

            ViewBag.lstCategorias = sCategoria.ObtenerCategorias();
            return(View());
        }
Exemplo n.º 4
0
        public JsonResult AddProduct(int idProducto, int cantidad)
        {
            try
            {
                Venta oVenta = (Venta)Session["Cart"];
                if (oVenta == null)
                {
                    oVenta = new Venta();
                }

                if (oVenta.DetalleVenta.Where(x => x.idProducto == idProducto).Count() == 1)
                {
                    if (oVenta.DetalleVenta.Where(x => x.idProducto == idProducto).FirstOrDefault().Producto.stockActual < (cantidad + oVenta.DetalleVenta.Where(x => x.idProducto == idProducto).FirstOrDefault().cantidad))
                    {
                        return(Json("Stock insuficiente."));
                    }

                    oVenta.DetalleVenta.Where(x => x.idProducto == idProducto).FirstOrDefault().cantidad += cantidad;
                    oVenta.DetalleVenta.Where(x => x.idProducto == idProducto).FirstOrDefault().subTotal += (oVenta.DetalleVenta.Where(x => x.idProducto == idProducto).FirstOrDefault().Producto.precio *cantidad) - Convert.ToDecimal(((oVenta.DetalleVenta.Where(x => x.idProducto == idProducto).FirstOrDefault().Producto.precio *cantidad) * oVenta.DetalleVenta.Where(x => x.idProducto == idProducto).FirstOrDefault().Producto.descuento) / 100);

                    oVenta.montoTotal = oVenta.DetalleVenta.Sum(x => x.subTotal);
                }
                else
                {
                    srvProduct sProduct  = new srvProduct();
                    Producto   oProducto = sProduct.obtenerProducto(idProducto);

                    if (oProducto.stockActual < cantidad)
                    {
                        return(Json("Stock insuficiente."));
                    }
                    DetalleVenta oDetalle = new DetalleVenta();
                    oDetalle.Producto       = oProducto; // <---------------- Solo para mostrar
                    oDetalle.idProducto     = oProducto.idProducto;
                    oDetalle.precioUnitario = oProducto.precio;
                    oDetalle.descuento      = oProducto.descuento;
                    oDetalle.subTotal       = (oProducto.precio * cantidad) - Convert.ToDecimal(((oProducto.precio * cantidad) * oDetalle.descuento) / 100);
                    oDetalle.cantidad       = cantidad;
                    oVenta.DetalleVenta.Add(oDetalle);
                    oVenta.montoTotal += oDetalle.subTotal;
                    Session["Cart"]    = oVenta;
                }


                return(Json("true"));
            }
            catch (Exception)
            {
                return(Json("Ocurrió un erro al agregar el producto."));
            }
        }
Exemplo n.º 5
0
        // VISTAS PARCIALES

        public ActionResult _ProductList(int pageIndex, int pageSize, string stSearch)
        {
            srvProduct sPro          = new srvProduct();
            int        cantProductos = sPro.TotalProductosBusqueda(stSearch);

            if (pageIndex * pageSize >= cantProductos)
            {
                ViewBag.complete     = true;
                ViewBag.lstProductos = new List <Producto>();
            }
            else
            {
                ViewBag.complete     = false;
                ViewBag.lstProductos = sPro.obtenerProductos(pageIndex, pageSize, stSearch);
            }
            return(PartialView());
        }
Exemplo n.º 6
0
        private async Task GetServerProductList(
            string serverImageProductCode
            , string regionNo
            , string zoneNo
            )
        {
            try
            {
                string endpoint = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint);
                string action   = @"/server/v2/getServerProductList";
                List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >();
                parameters.Add(new KeyValuePair <string, string>("responseFormatType", "json"));
                parameters.Add(new KeyValuePair <string, string>("serverImageProductCode", serverImageProductCode));
                parameters.Add(new KeyValuePair <string, string>("regionNo", regionNo));
                parameters.Add(new KeyValuePair <string, string>("zoneNo", zoneNo));
                SoaCall soaCall  = new SoaCall();
                var     task     = soaCall.WebApiCall(endpoint, RequestType.POST, action, parameters, LogClient.Config.Instance.GetValue(Category.Api, Key.AccessKey), LogClient.Config.Instance.GetValue(Category.Api, Key.SecretKey));
                string  response = await task;

                JsonSerializerSettings options = new JsonSerializerSettings
                {
                    NullValueHandling     = NullValueHandling.Ignore,
                    MissingMemberHandling = MissingMemberHandling.Ignore
                };


                comboBoxServer.InvokeIfRequired(s => {
                    if (response.Contains("responseError"))
                    {
                        hasError hasError = JsonConvert.DeserializeObject <hasError>(response, options);
                        throw new Exception(hasError.responseError.returnMessage);
                    }
                    else
                    {
                        getServerProductList getServerProductList = JsonConvert.DeserializeObject <getServerProductList>(response, options);
                        if (getServerProductList.getServerProductListResponse.returnCode.Equals("0"))
                        {
                            s.Items.Clear();
                            foreach (var a in getServerProductList.getServerProductListResponse.productList)
                            {
                                var item = new srvProduct
                                {
                                    productCode = a.productCode,
                                    productName = a.productName,
                                    productType = new codeCodeName
                                    {
                                        code     = a.productType.code,
                                        codeName = a.productType.codeName
                                    },
                                    productDescription = a.productDescription,
                                    infraResourceType  = new codeCodeName
                                    {
                                        code     = a.infraResourceType.code,
                                        codeName = a.infraResourceType.codeName
                                    },
                                    cpuCount             = a.cpuCount,
                                    memorySize           = a.memorySize,
                                    baseBlockStorageSize = a.baseBlockStorageSize,

                                    osInformation = a.osInformation,
                                    diskType      = new codeCodeName
                                    {
                                        code     = a.diskType.code,
                                        codeName = a.diskType.codeName
                                    },
                                    dbKindCode          = a.dbKindCode,
                                    addBlockStorageSize = a.addBlockStorageSize,
                                };
                                s.Items.Add(item);
                            }
                        }
                    }
                    s.SelectedIndex = 0;
                });
            }
            catch (Exception)
            {
                throw;
            }
        }