public async Task <IActionResult> createOrdenAsync(Orders order)
        {
            productsOrder = new productService();
            var response = productsOrder.createOrden(order);
            var json     = await response.Content.ReadAsStringAsync();

            if (!response.IsSuccessStatusCode)
            {
                Console.WriteLine("Se presento un Error");
                return(BadRequest(json));
            }
            else
            {
                Order orderCreated = null;

                orderCreated = JsonConvert.DeserializeObject <Order>(json.ToString(), new JsonSerializerSettings()
                {
                    MissingMemberHandling = MissingMemberHandling.Ignore
                });

                int result = productsOrder.CreateProductOrden(order.OrderProducts, orderCreated.idOrden);
                Console.WriteLine("Success");
                return(Ok(json));
            }
        }
示例#2
0
 //default constructor
 public cartViewModel()
 {
     service       = new productService();
     totalList     = service.getAllProducts();
     addedList     = new ObservableCollection <product>();
     addCommand    = new DelegateCommand(add, canAdd);
     finishCommand = new DelegateCommand(finish, canFinish);
 }
 //default constructor
 public adminMainViewModel()
 {
     service = new productService();
     //storing all products in list
     list = service.getAllProducts();
     //initializing all commands
     addProductCommand    = new DelegateCommand(add, canAdd);
     showProductCommand   = new DelegateCommand(display, canDisplay);
     deleteProductCommand = new DelegateCommand(delete, canDelete);
 }
        public IActionResult deleteProduct(int productId)
        {
            products = new productService();
            var response = products.deleteProductxId(productId);
            var json     = response.Content.ReadAsStringAsync();

            if (!response.IsSuccessStatusCode)
            {
                Console.WriteLine("Se presento un Error");
                return(BadRequest(json.Result));
            }
            else
            {
                Console.WriteLine("Success");
                return(Ok(json.Result));
            }
        }
        public IActionResult getHotels(LogisticHotels transport)
        {
            products = new productService();
            var response = products.getHotels(transport);
            var json     = response.Content.ReadAsStringAsync();

            if (!response.IsSuccessStatusCode)
            {
                Console.WriteLine("Se presento un Error");
                return(BadRequest(json.Result));
            }
            else
            {
                Console.WriteLine("Success");
                return(Ok(json.Result));
            }
        }
示例#6
0
        // GET: AddToCart
        public ActionResult Index()
        {
            productService  proService  = new productService();
            CategoryService cateService = new CategoryService();
            var             pro         = Request.Cookies["Products"];
            List <Product>  products    = null;

            if (pro != null)
            {
                var IDs    = pro.Value;
                var ProIds = IDs.Split('-').Select(x => int.Parse(x)).ToList();
                products = proService.GetAllproducts(ProIds);
                foreach (var item in products)
                {
                    item.Category = cateService.GetCategoryById(item.Cat_Id);
                }
            }
            return(View(products));
        }