Example #1
0
    public List <Kategoris> Category(string token)
    {
        var session = HttpContext.Session;

        if (session != null)
        {
            HttpContext.Session.TryGetValue("token", out var result);
            if (result != null)
            {
                string tokenSession = System.Text.Encoding.UTF8.GetString(result).Split('æ')[0];
                if (tokenSession == token)
                {
                    Console.WriteLine("Geçerli token :" + token);
                    using (GazeteContext context = new GazeteContext())
                    {
                        return(context.Kategoris.ToList());
                    }
                }
                else
                {
                    Console.WriteLine("Geçerli bir token değil:" + token);
                    //Response.Redirect("https://localhost:5001");
                    return(new List <Kategoris>());
                }
            }
            else
            {
                //Response.Redirect("https://localhost:5001");
                return(new List <Kategoris>());
            }
        }
        Console.WriteLine("Geçerli bir session yok");
        //Response.Redirect("https://localhost:5001");
        return(new List <Kategoris>());
    }
Example #2
0
    public List <Yorums> CommandNews(int id, string token)
    {
        var session = HttpContext.Session;

        if (session != null)
        {
            HttpContext.Session.TryGetValue("token", out var result);
            if (result != null)
            {
                string refreshToken = IsRefreshToken(result);
                string tokenSession = System.Text.Encoding.UTF8.GetString(result).Split('æ')[0];
                if (tokenSession == token)
                {
                    Console.WriteLine("CommandNews:" + token);
                    using (GazeteContext context = new GazeteContext())
                    {
                        var listCommand = context.Yorums.Where(yor => yor.Haber_id == id).ToList();
                        if (!String.IsNullOrWhiteSpace(refreshToken))
                        {
                            listCommand.ForEach(command =>
                            {
                                command.RefreshToken = refreshToken;
                            });
                        }
                        return(listCommand);
                    }
                }
                else
                {
                    Console.WriteLine("Geçerli bir token değil:" + token);
                    //Response.Redirect("https://localhost:5001");
                    return(new List <Yorums>());
                }
            }
            else
            {
                //Response.Redirect("https://localhost:5001");
                return(new List <Yorums>());
            }
        }
        Console.WriteLine("Geçerli bir session yok");
        //Response.Redirect("https://localhost:5001");

        return(new List <Yorums>());
    }