예제 #1
0
        public List <Profiel> SelectVriend(Tijdlijn tijdlijn)
        {
            string         query     = "SELECT * FROM dbo.Gebruiker WHERE GebruikerID IN (SELECT VolgendID2 FROM dbo.Volgers WHERE VolgerID1 = @param1)";
            List <Profiel> profielen = new List <Profiel>();

            using (SqlConnection connection = new SqlConnection(DbContext.GetConnectionString()))
                using (SqlCommand cmd = new SqlCommand(query, connection))
                {
                    DbContext.OpenConnection(connection);

                    cmd.Parameters.AddWithValue("@param1", tijdlijn.Profiel.ID);

                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        byte[] ba = null;
                        if (reader["foto"] != DBNull.Value)
                        {
                            ba = (byte[])reader["foto"];
                        }
                        Profiel profielVriend = new Profiel
                        {
                            Gebruikersnaam = reader["gebruikersnaam"].ToString(),
                            Foto           = ba,
                            ID             = Convert.ToInt32(reader["GebruikerID"]),
                            Beschrijving   = reader["beschrijving"].ToString(),
                            Volgend        = true
                        };

                        profielen.Add(profielVriend);
                    }
                }
            return(profielen);
        }
예제 #2
0
        private bool CheckVolgend(int id)
        {
            Profiel profiel = new Profiel
            {
                ID = Convert.ToInt32(Request.Cookies["ProfielID"])
            };
            Tijdlijn tijdlijn = new Tijdlijn(profiel);

            tijdlijn.Vrienden = tRepo.VriendenOphalen(tijdlijn);

            var vriend = tijdlijn.Vrienden.FirstOrDefault(x => x.ID == id);

            if (vriend != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #3
0
        public IActionResult Index()
        {
            TempData.Clear();
            profiel = new Profiel
            {
                Account = new Account()
            };
            var identity = (ClaimsIdentity)HttpContext.User.Identity;

            profiel.Account.ID = Convert.ToInt32(identity.FindFirst(ClaimTypes.NameIdentifier).Value);
            tijdlijn           = new Tijdlijn(profiel);

            pRepo.ProfielOphalen(profiel);
            tijdlijn.Twoots   = tRepo.TwootsOphalen(tijdlijn);
            tijdlijn.Vrienden = tRepo.VriendenOphalen(tijdlijn);
            Response.Cookies.Append("ProfielID", profiel.ID.ToString());

            GetTijdlijn get = new GetTijdlijn(tijdlijn);

            return(View(get));
        }
예제 #4
0
        public IActionResult Bezoek(string id)
        {
            if (id != null)
            {
                profiel = new Profiel
                {
                    Account = new Account(),
                    ID      = Convert.ToInt32(id)
                };

                profiel           = pRepo.ProfielOphalen(profiel.ID);
                tijdlijn          = new Tijdlijn(profiel);
                tijdlijn.Twoots   = tRepo.TwootsOphalen(tijdlijn);
                tijdlijn.Vrienden = tRepo.VriendenOphalen(tijdlijn);
                bool volgend = CheckVolgend(Convert.ToInt32(id));

                GetTijdlijn get = new GetTijdlijn(tijdlijn, volgend);

                return(View(get));
            }
            return(View());
        }
예제 #5
0
        public void TestJuisteTwootsOphalen()
        {
            ProfielMSSQLContext  profielContext  = new ProfielMSSQLContext();
            TijdlijnMSSQLContext tijdlijnContext = new TijdlijnMSSQLContext();

            Profiel profiel = new Profiel
            {
                Account = new Account {
                    ID = 17
                }
            };
            Tijdlijn tijdlijn = new Tijdlijn(profiel);

            tijdlijn.Twoots   = tijdlijnContext.SelectTwoot(tijdlijn);
            tijdlijn.Vrienden = tijdlijnContext.SelectVriend(tijdlijn);

            foreach (Twoot twoot in tijdlijn.Twoots)
            {
                Profiel vriend = tijdlijn.Vrienden.FirstOrDefault(m => m.ID == twoot.ID);
                Assert.IsTrue(twoot.ProfielID == tijdlijn.Profiel.ID || vriend != null);
            }
        }
예제 #6
0
        public static Tijdlijn ToTijdlijn(this JObject obj)
        {
            var retval = new Tijdlijn();

            //ondersteunt nog niet: nested properties (behalve periode)
            foreach (var property in obj.Properties())
            {
                if (property.Name == "Periode")
                {
                    var periode = property.Children <JObject>();
                    var van     = periode.Properties().First(x => x.Name == "Van");
                    var tot     = periode.Properties().First(x => x.Name == "TotEnMet");
                    retval.Periode = new Periode(DateTime.Parse(van.Value.ToString()), DateTime.Parse(tot.Value.ToString()));
                }
                else
                {
                    retval.Waarden.Add(property.Name, property.Value.ToString());
                }
            }

            return(retval);
        }
예제 #7
0
        public void TestVolgen()
        {
            ProfielMSSQLContext  profielContext  = new ProfielMSSQLContext();
            TijdlijnMSSQLContext tijdlijnContext = new TijdlijnMSSQLContext();
            Profiel volgendProfiel = new Profiel
            {
                ID = 1020
            };
            Profiel profiel = new Profiel
            {
                ID = 1019
            };

            Tijdlijn tijdlijn = new Tijdlijn(profiel);

            profielContext.Volg(volgendProfiel.ID, profiel.ID);
            tijdlijn.Vrienden = tijdlijnContext.SelectVriend(tijdlijn);

            Profiel vriendProfiel = tijdlijn.Vrienden.FirstOrDefault(m => m.ID == volgendProfiel.ID);

            Assert.IsNotNull(vriendProfiel);
        }
예제 #8
0
        public List <Twoot> SelectFavoTwoot(Tijdlijn tijdlijn)
        {
            string       query      = "SELECT * FROM Twoot INNER JOIN Favoriete_twoot ON Twoot.GebruikerID = Favoriete_twoot.GebruikerID AND Twoot.TweetID = Favoriete_twoot.TweetID WHERE Favoriete_twoot.GebruikerID = @param1";
            List <Twoot> favoTwoots = new List <Twoot>();

            using (SqlConnection connection = new SqlConnection(DbContext.GetConnectionString()))
                using (SqlCommand cmd = new SqlCommand(query, connection))
                {
                    DbContext.OpenConnection(connection);

                    cmd.Parameters.AddWithValue("@param1", tijdlijn.Profiel.ID);
                    try
                    {
                        SqlDataReader reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            Twoot twoot = new Twoot
                            {
                                ID        = Convert.ToInt32(reader["TweetID"]),
                                Bericht   = reader["bericht"].ToString(),
                                ProfielID = Convert.ToInt32(reader["GebruikerID"]),
                                date      = Convert.ToDateTime(reader["datum"]),
                                Favoriet  = true
                            };

                            favoTwoots.Add(twoot);
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
            return(favoTwoots);
        }
예제 #9
0
 public GetTijdlijn(Tijdlijn tijdlijn)
 {
     this.Tijdlijn = tijdlijn;
 }
예제 #10
0
 public List <Profiel> VriendenOphalen(Tijdlijn tijdlijn)
 {
     return(_context.SelectVriend(tijdlijn));
 }
예제 #11
0
        public List <Twoot> TwootsOphalen(Tijdlijn tijdlijn)
        {
            List <Twoot> uncensoredTwoots = _context.SelectTwoot(tijdlijn);

            return(TwootsCensoren(uncensoredTwoots));
        }
예제 #12
0
        public List <Twoot> SelectTwoot(Tijdlijn tijdlijn)
        {
            string       query  = "dbo.spGetTwoots";
            List <Twoot> twoots = new List <Twoot>();

            using (SqlConnection connection = new SqlConnection(DbContext.GetConnectionString()))
                using (SqlCommand cmd = new SqlCommand(query, connection))
                {
                    DbContext.OpenConnection(connection);

                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@ProfielID", SqlDbType.Int).Value = tijdlijn.Profiel.ID;
                    try
                    {
                        SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                        DataSet        ds      = new DataSet();
                        adapter.Fill(ds);

                        DataTable tableA = ds.Tables[0];
                        DataTable tableB = ds.Tables[1];


                        foreach (DataRow dr in tableA.Rows)
                        {
                            Twoot twoot = new Twoot
                            {
                                ID         = Convert.ToInt32(dr["TweetID"]),
                                Bericht    = dr["bericht"].ToString(),
                                ProfielID  = Convert.ToInt32(dr["GebruikerID"]),
                                date       = Convert.ToDateTime(dr["datum"]),
                                naamPoster = dr["gebruikersnaam"].ToString()
                            };

                            if (dr.IsNull("favoriet"))
                            {
                                twoot.Favoriet = false;
                            }
                            else
                            {
                                twoot.Favoriet = true;
                            }
                            twoots.Add(twoot);
                        }

                        foreach (DataRow dr in tableB.Rows)
                        {
                            Twoot twoot = new Twoot
                            {
                                ID         = Convert.ToInt32(dr["TweetID"]),
                                Bericht    = dr["bericht"].ToString(),
                                ProfielID  = Convert.ToInt32(dr["GebruikerID"]),
                                date       = Convert.ToDateTime(dr["datum"]),
                                naamPoster = dr["gebruikersnaam"].ToString()
                            };

                            if (dr.IsNull("favoriet"))
                            {
                                twoot.Favoriet = false;
                            }
                            else
                            {
                                twoot.Favoriet = true;
                            }

                            twoots.Add(twoot);
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                }
            return(twoots.OrderByDescending(x => x.date).ToList());
        }
예제 #13
0
 public GetTijdlijn(Tijdlijn tijdlijn, bool volgend)
 {
     this.Tijdlijn = tijdlijn;
     this.Volgend  = volgend;
 }
예제 #14
0
 public void ZetDetailOverzicht(Tijdlijn tijdlijn)
 {
     GeselecteerdTijdlijn = tijdlijn;
 }
예제 #15
0
 public TijdlijnPositie BepaalTijdlijnPositie(Tijdlijn tijdlijn)
 {
     return(tijdlijn.BepaaldTijdlijnPositie(Jaar));
 }
예제 #16
0
        public bool HeeftOverlapOpDezeRij(int rij, Tijdlijn tijdlijn)
        {
            var tijdlijnenOpRij = TijdlijnenGeplaatst.Where(x => x.Rij == rij);

            return(tijdlijnenOpRij.Any(x => x.Periode.HeeftOverlapMet(tijdlijn.Periode)));
        }
예제 #17
0
 public int GetAantalTijdlijnenMetOverlap(Tijdlijn tijdlijn)
 {
     return(TijdlijnenGeplaatst.Count(x => x.Periode.HeeftOverlapMet(tijdlijn.Periode)));
 }
예제 #18
0
 public async Task ToonInfo(MouseEventArgs e, Tijdlijn tijdlijn)
 {
     TijdlijnenGeplaatst.Clear();
     await TijdlijnGeselecteerd.InvokeAsync(tijdlijn);
 }