public ActionResult Cancelar(int idOrden) { var cancela = new ServiceProxyB2CClient(); RespuestaGenerica rpta; var valorcancela = new RespuestaCancelacionModel(); var idOrdenes = new[] { idOrden }; try { rpta = cancela.CancelarOrdenes(idOrdenes); } catch (FaultException <CancelarOrdenesFault> exf) { valorcancela.Respuesta = "Se presento un error al cancelar la orden " + idOrden + ". Intentelo más tarde (" + exf.Message + ")"; return(View("_Cancelar", valorcancela)); } catch (Exception) { valorcancela.Respuesta = "Se presento un error al cancelar la orden " + idOrden + ". Intentelo más tarde"; return(View("_Cancelar", valorcancela)); } if (rpta == RespuestaGenerica.OK) { valorcancela.Respuesta = "Se cancelo la orden " + idOrden + " de forma exitosa"; } else { valorcancela.Respuesta = "Se presento un problema al cancelar la orden " + idOrden + ". Intentelo más tarde"; } return(View("_Cancelar", valorcancela)); }
// GET: Orden public ActionResult Index() { try { var currentUser = System.Web.HttpContext.Current.User as CustomPrincipal; if (currentUser == null) { return(RedirectToAction("Index", "Account")); } var proxy = new ServiceProxyB2CClient(); var lstOrden = proxy.ConsultarClientesOrdenes((int)currentUser.CustId); return(View(lstOrden)); } catch (FaultException <ConsultarClientesOrdenesFault> exf) { throw new Exception("Error al traer las ordenes " + exf.Detail.ConsultarClientesOrdenesFault1.mensaje); } catch (CommunicationException cex) { throw new CommunicationException("Error de conmunicacion " + cex); } }
// GET: Product/Details/5 public ActionResult Details(int idProducto) { var proxy = new ServiceProxyB2CClient(); var productos = new ProductosModel { Productos = proxy.ConsultarProducto(TipoConsultaProducto.ID, idProducto.ToString(), null, null) }; return(View(productos.Productos)); }
// GET: /Home/ public ActionResult Index() { var proxy = new ServiceProxyB2CClient(); var productos = new PromocionesModel { Promociones = proxy.ConsultarCampaniaProducto() }; return(View(productos)); }
public ActionResult Details(int idProducto) { var proxy = new ServiceProxyB2CClient(); var productos = new ProductosModel { Productos = proxy.ConsultarProducto(TipoConsultaProducto.ID, idProducto.ToString()), ProductosRelacionados = proxy.ConsultaTop5Productos(new[] { idProducto.ToString() }) }; return(View(productos)); }
public ActionResult Index(string searchString, int page) { var proxy = new ServiceProxyB2CClient(); var productos = new ProductosModel { Productos = proxy.ConsultarProducto(TipoConsultaProducto.DESCRIPCION, page + "@" + searchString), Page = page, SearchString = searchString }; return(View(productos)); }
// GET: Product public ActionResult Index(string searchString) { if (string.IsNullOrEmpty(searchString)) { var proxy = new ServiceProxyB2CClient(); var productos = new ProductosModel { Productos = proxy.ConsultarCampaniaProducto() }; return(View(productos)); } else { var proxy = new ServiceProxyB2CClient(); var productos = new ProductosModel { Productos = proxy.ConsultarProducto(TipoConsultaProducto.DESCRIPCION, null, searchString, null) }; return(View(productos)); } }
public ActionResult Create(CheckoutModel checkout) { var items = new List <Item>(); try { var proxy = new ServiceProxyB2CClient(); var currentUser = System.Web.HttpContext.Current.User as CustomPrincipal; if (currentUser == null) { return(RedirectToAction("Index", "Account")); } var clientConfiguration = new MemcachedClientConfiguration { Protocol = MemcachedProtocol.Binary }; clientConfiguration.Servers.Add(new IPEndPoint(IPAddress.Parse("192.168.99.100"), 32768)); using (var cartCacheClient = new MemcachedClient(clientConfiguration)) { checkout.Cart = cartCacheClient.Get <Cart>("Cart-" + currentUser.UserName); foreach (var item in checkout.Cart.Items) { checkout.Total = checkout.Total + item.Cantidad * (item.Producto.tipo_espectaculo.precio + item.Producto.tipo_hospedaje.precio + item.Producto.tipo_transporte.precio); } if (checkout.Cart == null) { return(RedirectToAction("Index", "Home")); } } items.AddRange(checkout.Cart.Items.Select(i => new Item { precio = i.Producto.tipo_espectaculo.precio + i.Producto.tipo_hospedaje.precio + i.Producto.tipo_transporte.precio, cantidad = i.Cantidad, id_prod = i.Producto.id_producto, nombre_prod = i.Producto.descripcion })); var orden = new Orden { precio = checkout.Total, estatus = EstatusOrden.VALIDACION, fecha_orden = DateTime.Now, id_cliente = checkout.CustomerId, item = items.ToArray() }; var orderId = proxy.CrearOrdenes(orden); if (orderId == null) { return(View()); } using (var cartCacheClient = new MemcachedClient(clientConfiguration)) { cartCacheClient.Remove("Cart-" + currentUser.UserName); } return(RedirectToAction("Index", "Orden", new { OrderId = orderId })); } catch { return(View()); } }
public ActionResult AddItem(int idProducto, int cantidad) { if (!ModelState.IsValid) { return(View("Index")); } //consulto el usuario logueado var currentUser = System.Web.HttpContext.Current.User as CustomPrincipal; if (currentUser == null) { return(RedirectToAction("Index", "Account")); } var clientConfiguration = new MemcachedClientConfiguration { Protocol = MemcachedProtocol.Binary }; clientConfiguration.Servers.Add(new IPEndPoint(IPAddress.Parse("192.168.99.100"), 32768)); using (var memcachedclient = new MemcachedClient(clientConfiguration)) { //consulto el cache del usuario logueado var cart = memcachedclient.Get <Cart>("Cart-" + currentUser.UserName); var proxy = new ServiceProxyB2CClient(); var producto = proxy.ConsultarProducto(TipoConsultaProducto.ID, idProducto.ToString()).First(); if (null == cart) { //si el carrito es vacio cree uno nuevo cart = new Cart { UserId = (int)currentUser.CustId, Items = new List <Item>() }; var item = new Item { Producto = producto, Cantidad = cantidad }; cart.Items.Add(item); memcachedclient.Store(StoreMode.Set, "Cart-" + currentUser.UserName, cart); } else { foreach (var i in cart.Items.Where(i => i.Producto.id_producto == idProducto)) { //Si existe un carrito busco el item y adiciono la cantidad i.Cantidad = i.Cantidad + cantidad; memcachedclient.Store(StoreMode.Set, "Cart-" + currentUser.UserName, cart); return(View("cart", cart)); } //si no existe el item en el carrito lo agrego a la coleccion y guardo el carro var item = new Item { Producto = producto, Cantidad = cantidad }; cart.Items.Add(item); memcachedclient.Store(StoreMode.Set, "Cart-" + currentUser.UserName, cart); } return(View("Cart", cart)); } }
public ActionResult Pagar() { if (!ModelState.IsValid) { return(View("Index")); } //consulto el usuario logueado var currentUser = System.Web.HttpContext.Current.User as CustomPrincipal; if (currentUser == null) { return(RedirectToAction("Index", "Account")); } var clientConfiguration = new MemcachedClientConfiguration { Protocol = MemcachedProtocol.Binary }; clientConfiguration.Servers.Add(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 32769)); ServiceProxyB2C.CrearOrdenResponse response = new ServiceProxyB2C.CrearOrdenResponse(); using (var client = new MemcachedClient(clientConfiguration)) { //consulto el cache del usuario logueado var cart = client.Get <Cart>("Cart-" + currentUser.UserName); if (cart != null) { var proxy = new ServiceProxyB2CClient(); // se crea una nueva orden Orden orden = new Orden(); // se deja el estado en validacion orden.estatus = EstatusOrden.VALIDACION; orden.fecha_orden = DateTime.Now; // se crea una nueva lista de items del carrito List <ServiceProxyB2C.Item> lstitem = new List <ServiceProxyB2C.Item>(); foreach (Models.Item item in cart.Items) { ServiceProxyB2C.Item itemorden = new ServiceProxyB2C.Item(); itemorden.id_prod = item.Producto.id_producto; // el servicio pide el nombre del producto, en el carrito no hay se coloca el nombre del espectaculo itemorden.nombre_prod = item.Producto.espectaculo; // en el servicio se pide el precio, se deja un valor fijo para ajustar modelo itemorden.precio = 100000; itemorden.cantidad = item.Cantidad; lstitem.Add(itemorden); } orden.item = lstitem.ToArray(); response = proxy.CrearOrdenes(orden); } else { response.id_orden = ""; response.estatus_orden = EstatusOrden.RECHAZADA; response.estatus_ordenSpecified = false; } } return(View("_Compra", response)); }
// GET: Orden public ActionResult Index() { //for (int i=0;i<=10; i++) //{ // OrdenModel ord = new OrdenModel(); // ord.estatus = SrvProxyB2C.EstatusOrden.VALIDACION; // ord.fechaOrden = DateTime.Now.AddDays(i); // Random r = new Random(i); // ord.id_orden = "ORD-" + (Math.Round(r.NextDouble()*10000,0)).ToString() ; // ord.detalle = new List<SrvProxyB2C.Item>(); // double valsum = 0; ; // for (int j = 0; j <= 3; j++) // { // SrvProxyB2C.Item item = new SrvProxyB2C.Item(); // item.id_item = "ITM-" + j.ToString(); // item.id_prod = j; // item.nombre_prod = "Prod-" + j.ToString(); // item.part_num = "Part-" + j.ToString(); // item.cantidad = 1; // item.precio = Math.Round( r.NextDouble()*100000,0); // valsum = valsum + item.precio; // ord.detalle.Add(item); // } // ord.precio = valsum; // lstordenes.Add(ord); //} IEnumerable <Orden> lstOrden; var currentUser = System.Web.HttpContext.Current.User as CustomPrincipal; var ordenes = new ServiceProxyB2CClient(); //Orden o = new Orden(); //o.estatus = EstatusOrden.VALIDACION try { lstOrden = ordenes.ConsultarClientesOrdenes(currentUser.CustId.ToString()); } catch (FaultException <ConsultarClientesOrdenesFault> exf) { throw new Exception("Error al traer las ordenes " + exf.Detail.ConsultarClientesOrdenesFault1.mensaje); } catch (CommunicationException cex) { throw new CommunicationException("Error de conmunicacion " + cex.ToString()); } var clientConfiguration = new MemcachedClientConfiguration { Protocol = MemcachedProtocol.Binary }; //clientConfiguration.Servers.Add(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 32768)); clientConfiguration.Servers.Add(new IPEndPoint(IPAddress.Parse("192.168.99.100"), 32769)); using (var ordencache = new MemcachedClient(clientConfiguration)) { // se almacena en cache el listado de ordenes del cliente ordencache.Store(StoreMode.Set, "Orden-" + currentUser.UserName, lstOrden); //HttpContext.Session["ListaOrden"] = lstorden; } return(View(lstOrden.ToList())); }