Beispiel #1
0
        public DataCollectionSingle <producto> AddLineaCarrito(string laip, string _sesionToken, long identificador, int cantidad)
        {
            var result = new DataCollectionSingle <producto>();

            //resultList _area;
            // string token = GetToken(laip).activeToken;
            //string de url principal
            string urlPath = "https://riews.reinfoempresa.com:8443";
            //string codeidentifier = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(identificador.ToString()));
            string codeidentifier = identificador.ToString();
            string _cantidad      = cantidad.ToString();
            //string de la url del método de llamada
            //https://riews.reinfoempresa.com:8443/RIEWS/webapi/PrivateServices/articles1
            string request2 = urlPath + "/RIEWS/webapi/PrivateServices/basketline2W";
            //creamos un webRequest con el tipo de método.
            WebRequest webRequest = WebRequest.Create(request2);

            //definimos el tipo de webrequest al que llamaremos
            webRequest.Method = "POST";
            //definimos content\
            webRequest.ContentType = "application/json; charset=utf-8";
            //cargamos los datos a enviar
            using (var streamWriter = new StreamWriter(webRequest.GetRequestStream()))
            {
                //$formData = array(
                //          "codeidentifier"    => (string)$nIdentifier,
                //          "cant"          => (string)$nCant,
                //          "long"      => (string)$nLong,
                //          "width"         => (string)$nWidth,
                //          "thick"         => (string)$nThick,
                //          "token"         => unserializeObj($_SESSION["_ObjSession"])->ActualToken,
                //          "ipbase64"  => $_SESSION["_IpAddressSession"]
                //         );

                string json = "{\"token\":\"" + _sesionToken + "\",\"ipbase64\":\"" + laip + "\",\"codeidentifier\":\"" + codeidentifier + "\",\"cant\":\"" + _cantidad + "\"}";
                streamWriter.Write(json.ToString());
                //"  "
            }
            //obtenemos la respuesta del servidor
            var httpResponse = (HttpWebResponse)webRequest.GetResponse();

            //leemos la respuesta y la tratamos
            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result2 = streamReader.ReadToEnd();
                //traducimos el resultado
                // result = JsonSerializer.Deserialize<DataCollectionSingle<producto>>(result2);
                result = JsonConvert.DeserializeObject <DataCollectionSingle <producto> >(result2);
            }
            //
            //if (_area == null)
            //{
            //    _area = new resultList();
            //    _area.result = new List<result>();
            //    _area.result[0].areaname = "vacia";
            //}

            return(result);
        }
Beispiel #2
0
        public DataCollectionSingle <producto> RecuperaArtículo(string laip, string _sesionToken, long identificador)
        {
            var result = new DataCollectionSingle <producto>();

            //resultList _area;
            // string token = GetToken(laip).activeToken;
            //string de url principal
            string urlPath = "https://riews.reinfoempresa.com:8443";
            //string codeidentifier = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(identificador.ToString()));
            string codeidentifier = identificador.ToString();

            //string de la url del método de llamada
            //https://riews.reinfoempresa.com:8443/RIEWS/webapi/PrivateServices/articles1
            string request2 = urlPath + "/RIEWS/webapi/PrivateServices/articles1W";
            //creamos un webRequest con el tipo de método.
            WebRequest webRequest = WebRequest.Create(request2);

            //definimos el tipo de webrequest al que llamaremos
            webRequest.Method = "POST";
            //definimos content\
            webRequest.ContentType = "application/json; charset=utf-8";
            //cargamos los datos a enviar
            using (var streamWriter = new StreamWriter(webRequest.GetRequestStream()))
            {
                //string json = "{\"token\":\"" + token + "\",\"ipbase64\":\"" + laip +"}";
                string json = "{\"token\":\"" + _sesionToken + "\",\"ipbase64\":\"" + laip + "\",\"codeidentifier\":\"" + codeidentifier + "\"}";
                streamWriter.Write(json.ToString());
                //"  "
            }
            //obtenemos la respuesta del servidor
            var httpResponse = (HttpWebResponse)webRequest.GetResponse();

            //leemos la respuesta y la tratamos
            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result2 = streamReader.ReadToEnd();
                //traducimos el resultado
                // result = JsonSerializer.Deserialize<DataCollectionSingle<producto>>(result2);
                result = JsonConvert.DeserializeObject <DataCollectionSingle <producto> >(result2);
            }
            //
            //if (_area == null)
            //{
            //    _area = new resultList();
            //    _area.result = new List<result>();
            //    _area.result[0].areaname = "vacia";
            //}

            return(result);
        }
Beispiel #3
0
        public void ModificaLinea(string laip, string _sesionToken, long identificador, int quant)
        {
            var result = new DataCollectionSingle <producto>();

            //string de url principal
            string urlPath        = "https://riews.reinfoempresa.com:8443";
            string codeidentifier = identificador.ToString();
            string cantidad       = quant.ToString();

            //string de la url del método de llamada
            //https://riews.reinfoempresa.com:8443/RIEWS/webapi/PrivateServices/articles1
            string request2 = urlPath + "/RIEWS/webapi/PrivateServices/basketline3W";
            //creamos un webRequest con el tipo de método.
            WebRequest webRequest = WebRequest.Create(request2);

            //definimos el tipo de webrequest al que llamaremos
            webRequest.Method = "POST";
            //definimos content\
            webRequest.ContentType = "application/json; charset=utf-8";
            //cargamos los datos a enviar
            using (var streamWriter = new StreamWriter(webRequest.GetRequestStream()))
            {
                //string json = "{\"token\":\"" + token + "\",\"ipbase64\":\"" + laip +"}";
                string json = "{\"token\":\"" + _sesionToken + "\",\"ipbase64\":\"" + laip + "\",\"cant\":\"" + cantidad + "\",\"line\":\"" + codeidentifier + "\"}";
                streamWriter.Write(json.ToString());
                //"  "
            }
            //obtenemos la respuesta del servidor
            var httpResponse = (HttpWebResponse)webRequest.GetResponse();

            //leemos la respuesta y la tratamos
            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result2 = streamReader.ReadToEnd();
                //traducimos el resultado
                result = JsonConvert.DeserializeObject <DataCollectionSingle <producto> >(result2);
                //result = JsonConvert.DeserializeObject<BasketlinestotalRecibe>(result2);
            }
            //
            //if (_area == null)
            //{
            //    _area = new resultList();
            //    _area.result = new List<result>();
            //    _area.result[0].areaname = "vacia";
            //}
        }
Beispiel #4
0
        public async Task <IActionResult> ProductDetail(long id)
        {
            DataCollectionSingle <producto> articulo = RecuperaArtículo(GetIP(), GetSession(), id);

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

            var model = new ProductDetail();

            model.Id                     = long.Parse(articulo.result.identifier);
            model.Name                   = articulo.result.description;//_contentLocalizationService.GetLocalizedProperty(articulo.result, nameof(articulo.result.description), articulo.result.description),
            model.IsCallForPricing       = false;
            model.IsAllowToOrder         = true;
            model.StockTrackingIsEnabled = true;
            int s = 0;

            _ = int.TryParse(articulo.result.stocks, out s);
            model.StockQuantity          = s;
            model.StockTrackingIsEnabled = false;
            model.ShortDescription       = articulo.result.description2;//_contentLocalizationService.GetLocalizedProperty(articulo.result, nameof(articulo.result.description2), articulo.result.description2),
            model.MetaTitle = articulo.result.description;
            if (articulo.result.description2.Length > 160)
            {
                model.MetaDescription = articulo.result.description2.Substring(0, 160);
            }
            else
            {
                model.MetaDescription = articulo.result.description2.Substring(0, articulo.result.description2.Length);
            }
            model.Description   = articulo.result.description2;          //_contentLocalizationService.GetLocalizedProperty(product, nameof(product.Description), product.Description),
            model.Specification = "";                                    // _contentLocalizationService.GetLocalizedProperty(product, nameof(product.Specification), product.Specification),
            model.ReviewsCount  = int.Parse(articulo.result.likeothers); //product.ReviewsCount,
            model.RatingAverage = int.Parse(articulo.result.likeothers);

            model.CalculatedProductPrice       = new CalculatedProductPrice(_currencyService);
            model.CalculatedProductPrice.Price = decimal.Parse(articulo.result.pricewithtax.Replace(".", ","));

            MapProductImagesToArticleVm(articulo.result, model);
            return(View(model));


            /// codigo origen

            //var product = _productRepository.Query()
            //    .Include(x => x.OptionValues)
            //    .Include(x => x.Categories).ThenInclude(c => c.Category)
            //    .Include(x => x.AttributeValues).ThenInclude(a => a.Attribute)
            //    .Include(x => x.ProductLinks).ThenInclude(p => p.LinkedProduct).ThenInclude(m => m.ThumbnailImage)
            //    .Include(x => x.ThumbnailImage)
            //    .Include(x => x.Medias).ThenInclude(m => m.Media)
            //    .Include(x => x.Brand)
            //    .FirstOrDefault(x => x.Id == id && x.IsPublished);
            //if (product == null)
            //{
            //    return NotFound();
            //}

            //var model = new ProductDetail
            //{
            //    Id = product.Id,
            //    Name = _contentLocalizationService.GetLocalizedProperty(product, nameof(product.Name), product.Name),
            //    Brand = product.Brand,
            //    CalculatedProductPrice = _productPricingService.CalculateProductPrice(product),
            //    IsCallForPricing = product.IsCallForPricing,
            //    IsAllowToOrder = product.IsAllowToOrder,
            //    StockTrackingIsEnabled = product.StockTrackingIsEnabled,
            //    StockQuantity = product.StockQuantity,
            //    ShortDescription = _contentLocalizationService.GetLocalizedProperty(product, nameof(product.ShortDescription), product.ShortDescription),
            //    MetaTitle = product.MetaTitle,
            //    MetaKeywords = product.MetaKeywords,
            //    MetaDescription = product.MetaDescription,
            //    Description = _contentLocalizationService.GetLocalizedProperty(product, nameof(product.Description), product.Description),
            //    Specification = _contentLocalizationService.GetLocalizedProperty(product, nameof(product.Specification), product.Specification),
            //    ReviewsCount = product.ReviewsCount,
            //    RatingAverage = product.RatingAverage,
            //    Attributes = product.AttributeValues.Select(x => new ProductDetailAttribute { Name = x.Attribute.Name, Value = x.Value }).ToList(),
            //    Categories = product.Categories.Select(x => new ProductDetailCategory { Id = x.CategoryId, Name = x.Category.Name, Slug = x.Category.Slug }).ToList()
            //};

            ////MapProductVariantToProductVm(product, model);
            ////MapRelatedProductToProductVm(product, model);
            ////MapProductOptionToProductVm(product, model);
            //MapProductImagesToProductVm(product, model);

            ////await _mediator.Publish(new EntityViewed { EntityId = product.Id, EntityTypeId = "Product" });
            ////_productRepository.SaveChanges();

            //return View(model);
        }