コード例 #1
0
        public List <FavoritosViewModel> Listar(int id)
        {
            using (SqlConnection connection = new SqlConnection(StringConexao))
            {
                string Query = "SELECT * FROM Favoritos where IdUsuario = @IdUsuario";
                connection.Open();
                SqlDataReader sdr;


                using (SqlCommand command = new SqlCommand(Query, connection))
                {
                    command.Parameters.AddWithValue("@IdUsuario", id);
                    sdr = command.ExecuteReader();

                    while (sdr.Read())
                    {
                        FavoritosViewModel favorito = new FavoritosViewModel
                        {
                            UsuarioId = Convert.ToInt32(sdr["IdUsuario"]),
                            TituloId  = Convert.ToInt32(sdr["IdTitulo"])
                        };
                        favoritos.Add(favorito);
                    }
                }
                return(favoritos);
            }
        }
コード例 #2
0
        public FavoritosList()
        {
            this.InitializeComponent();
            _navigationHelper = new NavigationHelper(this);

            FavoritosModel = new FavoritosViewModel();

            SizeChanged += OnSizeChanged;
        }
コード例 #3
0
        public FavoritosDetail()
        {
            this.InitializeComponent();
            _navigationHelper = new NavigationHelper(this);

            FavoritosModel = new FavoritosViewModel();

            ApplicationView.GetForCurrentView().
            SetDesiredBoundsMode(ApplicationViewBoundsMode.UseVisible);
        }
コード例 #4
0
        public void Favoritar(FavoritosViewModel favorito)
        {
            using (SqlConnection con = new SqlConnection(StringConexao))
            {
                string Query = "insert into Favoritos (IdTitulo, IdUsuario) values(@IdTitulo,@IdUsuario);";

                SqlCommand cmd = new SqlCommand(Query, con);
                cmd.Parameters.AddWithValue("@IdTitulo", favorito.TituloId);
                cmd.Parameters.AddWithValue("@IdUsuario", favorito.UsuarioId);
                con.Open();

                cmd.ExecuteNonQuery();
            }
        }
コード例 #5
0
        public IActionResult Favoritar(int tituloId)
        {
            FavoritosViewModel favorito = new FavoritosViewModel();

            try
            {
                favorito.UsuarioId = Convert.ToInt32(User.Claims.FirstOrDefault(claim => claim.Type == JwtRegisteredClaimNames.Jti).Value);
                favorito.TituloId  = tituloId;
                FavoritoRepository.Favoritar(favorito);
                return(Ok());
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #6
0
        public FavoritosPage()
        {
            InitializeComponent();

            BindingContext = viewModel = new FavoritosViewModel();
        }