public IHttpActionResult GetStatistic(string type)
        {
            apiResp = new ApiResponse();
            var mng = new CarritoManager();

            return(Ok(apiResp));
        }
Esempio n. 2
0
        protected void BtnAgregarAlCarrito_Click(object sender, EventArgs e)
        {
            Carrito carrito = CarritoManager.ObtenerCarrito(UsuarioLogueado.Id, Session.SessionID);

            if (carrito == null)
            {
                carrito = new Carrito
                {
                    FechaCreacion    = DateTime.Now,
                    Usuario          = UsuarioLogueado,
                    UsuarioSessionId = Session.SessionID
                };
            }

            int vehiculoId = int.Parse(HiddenVehiculoId.Value);

            if (!carrito.Detalles.Any(d => d.Vehiculo.Id == vehiculoId))
            {
                Vehiculo vehiculo = new Vehiculo
                {
                    Id     = vehiculoId,
                    Precio = int.Parse(HiddenVehiculoPrecio.Value)
                };
                CarritoDetalle detalle = new CarritoDetalle
                {
                    Vehiculo = vehiculo,
                    Cantidad = 1
                };

                carrito.Detalles.Add(detalle);
                CarritoManager.AgregarDetalle(carrito);
            }

            Response.Redirect("ListadoCarrito.aspx");
        }
        // GET api/Carrito
        public IHttpActionResult Get()
        {
            apiResp = new ApiResponse();
            var mng = new CarritoManager();

            apiResp.Data = mng.RetrieveAll();

            return(Ok(apiResp));
        }
Esempio n. 4
0
        protected void gvCarrito_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName != "EliminarDetalle")
            {
                return;
            }
            CarritoDetalle detalle = new CarritoDetalle()
            {
                Id = Convert.ToInt32(e.CommandArgument)
            };

            CarritoManager.EliminarDetalle(detalle);
            CargarGvCarrito();
        }
Esempio n. 5
0
        protected void BtnFinalizarCompra_Click(object sender, EventArgs e)
        {
            Carrito carrito = CarritoManager.ObtenerCarrito(UsuarioLogueado.Id, Session.SessionID);

            if (carrito != null && CarritoManager.FinalizarCompra(carrito))
            {
                Response.Redirect("CompraFinalizada.aspx");
            }
            else
            {
                // Mostrar que hubo error
                FailureText.Text     = "Ocurrió un error al generar la factura";
                ErrorMessage.Visible = true;
            }
        }
        public IHttpActionResult Reserva(Carrito carrito)
        {
            try
            {
                var mng = new CarritoManager();

                apiResp      = new ApiResponse();
                apiResp.Data = mng.RetrieveByReservaId(carrito);
                return(Ok(apiResp));
            }
            catch (BussinessException bex)
            {
                return(InternalServerError(new Exception(bex.AppMessage.Message)));
            }
        }
        // POST
        // CREATE
        public IHttpActionResult Post(Carrito carrito)
        {
            try
            {
                var mng = new CarritoManager();
                mng.Create(carrito);

                apiResp         = new ApiResponse();
                apiResp.Message = "El producto fue comprado.";

                return(Ok(apiResp));
            }
            catch (BussinessException bex)
            {
                return(InternalServerError(new Exception(bex.AppMessage.Message)));
            }
        }
        // DELETE ==
        public IHttpActionResult Delete(Carrito carrito)
        {
            try
            {
                var mng = new CarritoManager();
                mng.Delete(carrito);

                apiResp         = new ApiResponse();
                apiResp.Message = "El carrito fue eliminado.";

                return(Ok(apiResp));
            }
            catch (BussinessException bex)
            {
                return(InternalServerError(new Exception(bex.AppMessage.Message)));
            }
        }
Esempio n. 9
0
        public async Task <ActionResult> Authorize(string username, string password)
        {
            UsuarioManager manager = new UsuarioManager();
            Usuario        usuario = await manager.Validar(username, password);

            if (usuario == null)
            {
                return(Redirect("~/Login?Valid=false"));
            }
            else
            {
                dynamic model = new ExpandoObject();

                model.Usuario = usuario;
                CarritoManager managerC = new CarritoManager();
                model.List = Newtonsoft.Json.JsonConvert.SerializeObject(await managerC.ObtenerCarrito(usuario.US_ID.ToString(), usuario.token));
                return(View(model));
            }
        }
Esempio n. 10
0
        public async Task <ActionResult> BorrarCarrito(int id, string token)
        {
            if (token.Equals("notValid"))
            {
                dynamic model = new ExpandoObject();
                model.Auth = "false";
                model.id   = id;
                return(View(model));
            }
            else
            {
                CarritoManager manager = new CarritoManager();
                await manager.Eliminar(id.ToString(), token);

                dynamic model = new ExpandoObject();
                model.Auth = "true";
                model.id   = id;
                return(View(model));
            }
        }
        // GET api/Carrito/5
        // Retrieve by id
        public IHttpActionResult Get(int id)
        {
            try
            {
                var mng     = new CarritoManager();
                var carrito = new Carrito
                {
                    IdCarrito = id
                };

                carrito      = mng.RetrieveById(carrito);
                apiResp      = new ApiResponse();
                apiResp.Data = carrito;
                return(Ok(apiResp));
            }
            catch (BussinessException bex)
            {
                return(InternalServerError(new Exception(bex.AppMessage.Message)));
            }
        }
Esempio n. 12
0
        public async Task <ActionResult> AñadirProductoLog(int id, int cantidad, string userID, string token)
        {
            Producto_Carrito carrito = new Producto_Carrito {
                PRO_ID = id, CAR_PRO_CANTIDAD = cantidad
            };

            try
            {
                int            idUser   = Int32.Parse(userID);
                CarritoManager manager  = new CarritoManager();
                var            response = await manager.Ingresar(new Producto_Carrito { US_ID = idUser, CAR_PRO_CANTIDAD = cantidad, PRO_ID = id }, token);

                carrito.PCR_ID = response.PCR_ID;
                carrito.US_ID  = Int32.Parse(userID);
                return(View(response));
            }
            catch
            {
            }
            return(View(carrito));
        }
Esempio n. 13
0
        private void CargarGvCarrito()
        {
            Carrito carrito = CarritoManager.ObtenerCarrito(UsuarioLogueado.Id, Session.SessionID);

            if (carrito != null && carrito.Detalles != null && carrito.Detalles.Count > 0)
            {
                gvCarrito.DataSource = carrito.Detalles;
                gvCarrito.DataBind();
                gvCarrito.Visible          = true;
                LblTotal.Text              = "Total: $" + carrito.Detalles.Sum(d => d.Precio);
                LblTotal.Visible           = true;
                BtnFinalizarCompra.Visible = true;
                LblResultado.Visible       = false;
            }
            else
            {
                gvCarrito.Visible          = false;
                LblTotal.Visible           = false;
                BtnFinalizarCompra.Visible = false;
                LblResultado.Visible       = true;
            }
        }