public void Delete()
        {
            GebruikerSqlContext gsc = new GebruikerSqlContext();
            GebruikerRepository gr  = new GebruikerRepository(gsc);

            int oudeCount = gr.GetAll().Count;

            // gr.Delete(3);

            int nieuweCount = gr.GetAll().Count;

            Assert.AreEqual(oudeCount, (nieuweCount - 1));
        }
Exemple #2
0
        //GET : Chat/{AnderegebruikerId}

        public ActionResult ChatScherm(string id)
        {
            if (!AuthRepository.CheckIfUserCanAcces(GebruikerType.All, (Gebruiker)Session["LoggedInUser"]))
            {
                return(View("~/Views/Error/AuthError.cshtml"));
            }

            try
            {
                GebruikerSqlContext gsc = new GebruikerSqlContext();
                GebruikerRepository gr  = new GebruikerRepository(gsc);
                var sql      = new ChatSqlContext();
                var chatRepo = new ChatRepository(sql);

                Gebruiker loggedInUser = (Gebruiker)Session["LoggedInUser"];
                //  Gebruiker loggedInUser = gr.GetById(1);

                ViewBag.LoggedInUser = loggedInUser;
                ViewBag.Gebruikers   = gr.GetAll();
                ViewBag.EnableChat   = "true";
                return(View("~/Views/Chat/Index.cshtml"));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Index", "Error"));
            }
        }
        public void GetAll()
        {
            GebruikerSqlContext gsc = new GebruikerSqlContext();
            GebruikerRepository gr  = new GebruikerRepository(gsc);

            var Lijst = gr.GetAll();

            Assert.IsTrue(Lijst.Count > 0);
        }
        public void Barcodetest()
        {
            GebruikerSqlContext gsc = new GebruikerSqlContext();
            GebruikerRepository gr  = new GebruikerRepository(gsc);

            var Lijst = gr.GetAll();

            Assert.IsTrue(Lijst[0].Barcode == null);
            Assert.IsTrue(Lijst[1].Barcode == "12345");
        }
        //Get: Beheerder/Chat
        public ActionResult Chat(FormCollection f)
        {
            GebruikerSqlContext gsc = new GebruikerSqlContext();
            GebruikerRepository gr  = new GebruikerRepository(gsc);

            ChatSqlContext csc = new ChatSqlContext();
            ChatRepository cr  = new ChatRepository(csc);

            List <Gebruiker> users = gr.GetAll();


            int id1 = Convert.ToInt32(f["user1"]);
            int id2 = Convert.ToInt32(f["user2"]);



            if (id1 != 0 && id2 != 0 && (id1 != id2))
            {
                List <Chat> chat       = cr.GetChatByUsers(id1, id2);
                string      chatString = "";

                if (chat.Count > 0)
                {
                    for (int i = 0; i < chat.Count; i++)
                    {
                        chatString = chatString + chat[i].Auteur.Naam + " | " + chat[i].Bericht + "\r";
                    }

                    ViewBag.Chatstring = chatString;
                }
                else
                {
                    ViewBag.Chatstring = "Geen chat gevonden";
                }
            }
            else
            {
                ViewBag.Chatstring = "";
            }


            ViewBag.Users = users;

            return(View("~/Views/Chat/Beheer.cshtml"));
        }
Exemple #6
0
        // GET: Chat
        public ActionResult Index()
        {
            if (!AuthRepository.CheckIfUserCanAcces(GebruikerType.All, (Gebruiker)Session["LoggedInUser"]))
            {
                return(View("~/Views/Error/AuthError.cshtml"));
            }

            try {
                GebruikerSqlContext gsc = new GebruikerSqlContext();
                GebruikerRepository gr  = new GebruikerRepository(gsc);
                Gebruiker           g   = (Gebruiker)Session["LoggedInUser"];
                ViewBag.Gebruikers = gr.GetAll().Where(x => x.Id != g.Id).ToList();
                return(View("~/Views/Chat/Index.cshtml"));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Index", "Error"));
            }
        }
        public void DeleteGebruiker()
        {
            Gebruiker henrie = new Gebruiker(1, 0, "Henrie", "henrie", "Niew", "Nieuwe gebruiker", 0,
                                             "*****@*****.**",
                                             Functie.Gebruiker);

            List <Gebruiker> gebruikers = new List <Gebruiker>
            {
                henrie,
                new Gebruiker(2, 0, "Dirk", "dirk", "Niew", "Nieuwe gebruiker", 0, "*****@*****.**",
                              Functie.Beheerder)
            };

            //Act
            foreach (Gebruiker gebruiker in gebruikers)
            {
                repo.InsertNonAsyncTest(gebruiker);
            }

            repo.Delete(henrie);

            //Assert
            Assert.AreNotEqual(gebruikers, repo.GetAll());
        }