public void Retrieve()
        {
            VrijwilligerSqlContext vsc = new VrijwilligerSqlContext();
            VrijwilligerRepository vr  = new VrijwilligerRepository(vsc);

            Vrijwilliger v = vr.GetVrijwilligerById(4);

            Assert.IsTrue(v.Id == 4);
            Assert.IsTrue(v.Telefoonnummer == "0634810013");
            Assert.IsTrue(v.VOG == "/VOG/Test");
        }
示例#2
0
        public Reactie(int id, string bericht, DateTime datum, int vrijwilligerId, int hulpvraagId)
        {
            Id             = id;
            Bericht        = bericht;
            Datum          = datum;
            VrijwilligerId = vrijwilligerId;
            HulpvraagId    = hulpvraagId;

            VrijwilligerSqlContext context = new VrijwilligerSqlContext();
            VrijwilligerRepository rr      = new VrijwilligerRepository(context);

            Vrijwilliger = rr.GetVrijwilligerById(vrijwilligerId);
        }
        public void GetByVrijwilligerId()
        {
            BeschikbaarheidSqlContext bsc = new BeschikbaarheidSqlContext();
            BeschikbaarheidRepository br  = new BeschikbaarheidRepository(bsc);

            VrijwilligerSqlContext vsc = new VrijwilligerSqlContext();
            VrijwilligerRepository vr  = new VrijwilligerRepository(vsc);

            Vrijwilliger vrijw = vr.GetVrijwilligerById(4);

            List <Beschikbaarheid> LstBsch = br.GetBeschikbaarheidByVrijwilligerId(vrijw.Id);

            Assert.IsTrue(LstBsch.Count > 0);
        }
        public void Save()
        {
            BeschikbaarheidSqlContext bsc = new BeschikbaarheidSqlContext();
            BeschikbaarheidRepository br  = new BeschikbaarheidRepository(bsc);

            VrijwilligerSqlContext vsc = new VrijwilligerSqlContext();
            VrijwilligerRepository vr  = new VrijwilligerRepository(vsc);

            Vrijwilliger vrijw = vr.GetVrijwilligerById(4);

            HulpvraagSqlContext hsc = new HulpvraagSqlContext();
            HulpvraagRepository hr  = new HulpvraagRepository(hsc);

            Hulpvraag hulpvrg = hr.GetById(5);

            int             id = 19;
            Beschikbaarheid beschikbaarheid = br.GetBeschikbaarheidById(id);

            br.Save(beschikbaarheid, hulpvrg);
        }
        public ActionResult KeuzeRedirect(string id)
        {
            GebruikerSqlContext gsc = new GebruikerSqlContext();
            GebruikerRepository gr  = new GebruikerRepository(gsc);

            GebruikerType    gt    = (GebruikerType)Enum.Parse(typeof(GebruikerType), id);
            List <Gebruiker> users = gr.GetUserTypesByUserId((int)Session["UserId"]);

            List <GebruikerType> types = new List <GebruikerType>();

            foreach (Gebruiker gebr in users)
            {
                types.Add((GebruikerType)Enum.Parse(typeof(GebruikerType), gebr.GetType().Name));
            }

            foreach (GebruikerType type in types)
            {
                if (type == gt)
                {
                    if (type == GebruikerType.Vrijwilliger)
                    {
                        VrijwilligerSqlContext vsc = new VrijwilligerSqlContext();
                        VrijwilligerRepository vr  = new VrijwilligerRepository(vsc);
                        Session["LoggedInUser"] = vr.GetVrijwilligerById((int)Session["UserId"]);
                        return(RedirectToAction("Index", "Vrijwilliger"));
                    }
                    if (type == GebruikerType.Hulpbehoevende)
                    {
                        HulpbehoevendeSqlContext hsc = new HulpbehoevendeSqlContext();
                        HulpbehoevendeRepository hr  = new HulpbehoevendeRepository(hsc);

                        Session["LoggedInUser"] = hr.GetHulpbehoevendeById((int)Session["UserId"]);
                        return(RedirectToAction("Index", "Hulpbehoevende"));
                    }
                }
            }

            return(null);
        }
        public List <Hulpvraag> GetAll()
        {
            List <Hulpvraag> returnList = new List <Hulpvraag>();

            try
            {
                using (SqlConnection con = new SqlConnection(Env.ConnectionString))
                {
                    con.Open();
                    var cmdString = "SELECT * FROM Hulpvraag";
                    var command   = new SqlCommand(cmdString, con);
                    var reader    = command.ExecuteReader();

                    while (reader.Read())
                    {
                        Hulpvraag hv = new Hulpvraag(
                            reader.GetInt32(0),                                                //Id
                            reader.GetString(1),                                               //Titel
                            reader.GetString(2),                                               //Omschrijving
                            reader.GetDateTime(3),                                             //OpdrachtDatum
                            reader.GetDateTime(4),                                             //CreatedDatum
                            reader.GetString(5),                                               //Locatie
                            Convert.ToBoolean(reader.GetInt32(6)),                             //Urgent
                            (VervoerType)Enum.Parse(typeof(VervoerType), reader.GetString(7)), //Vervoertype
                            Convert.ToBoolean(reader.GetInt32(8)));                            //IsAfgerond

                        //Hulpbehoevende ophalen
                        HulpbehoevendeSqlContext hbcontext = new HulpbehoevendeSqlContext();
                        HulpbehoevendeRepository hr        = new HulpbehoevendeRepository(hbcontext);

                        hv.Hulpbehoevende = hr.GetHulpbehoevendeById(reader.GetInt32(9));

                        //Vrijwilliger ophalen als deze gezet is
                        if (!reader.IsDBNull(10))
                        {
                            VrijwilligerSqlContext vcontext = new VrijwilligerSqlContext();
                            VrijwilligerRepository vr       = new VrijwilligerRepository(vcontext);

                            hv.Vrijwilliger = vr.GetVrijwilligerById(reader.GetInt32(10));
                        }

                        //Vaardigheiden ophalen als deze er zijn
                        VaardigheidSqlContext vaarcontext = new VaardigheidSqlContext();
                        VaardigheidRepository vaarrepo    = new VaardigheidRepository(vaarcontext);

                        List <Vaardigheid> vaardighedenlijst = vaarrepo.GetVaardigheidByHulpvraagId(hv.Id);

                        if (vaardighedenlijst.Count > 0)
                        {
                            hv.Vaardigheden = vaardighedenlijst;
                        }

                        returnList.Add(hv);
                    }
                    con.Close();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            return(returnList);
        }
        public ActionResult Barcode(FormCollection form)
        {
            try
            {
                Gebruiker           g   = AuthRepository.CheckAuthBarcode(form["barcode"]);
                GebruikerSqlContext gsc = new GebruikerSqlContext();
                GebruikerRepository gr  = new GebruikerRepository(gsc);

                if (g == null)
                {
                    ViewBag.LoginResult = false;
                    return(View("~/Views/Login/Login.cshtml"));
                }
                List <Gebruiker>     users = gr.GetUserTypesByUserId(g.Id);
                List <GebruikerType> types = new List <GebruikerType>();

                foreach (Gebruiker gebr in users)
                {
                    types.Add((GebruikerType)Enum.Parse(typeof(GebruikerType), gebr.GetType().Name));
                }

                if (types.Contains(GebruikerType.Hulpbehoevende) && types.Contains(GebruikerType.Vrijwilliger))
                {
                    ViewBag.Accounts  = users;
                    ViewBag.Types     = types;
                    Session["UserId"] = g.Id;
                    return(Keuze());
                }
                if (types.Contains(GebruikerType.Hulpbehoevende))
                {
                    HulpbehoevendeSqlContext hsc = new HulpbehoevendeSqlContext();
                    HulpbehoevendeRepository hr  = new HulpbehoevendeRepository(hsc);

                    Session["LoggedInUser"] = hr.GetHulpbehoevendeById(g.Id);
                    return(RedirectToAction("Index", "Hulpbehoevende"));
                }
                if (types.Contains(GebruikerType.Vrijwilliger))
                {
                    VrijwilligerSqlContext vsc = new VrijwilligerSqlContext();
                    VrijwilligerRepository vr  = new VrijwilligerRepository(vsc);
                    Session["LoggedInUser"] = vr.GetVrijwilligerById(g.Id);
                    return(RedirectToAction("Index", "Vrijwilliger"));
                }
                if (types.Contains(GebruikerType.Beheerder))
                {
                    BeheerderSqlContext bsc = new BeheerderSqlContext();
                    BeheerderRepository br  = new BeheerderRepository(bsc);
                    Session["LoggedInUser"] = br.GetById(g.Id);
                    return(RedirectToAction("Index", "Beheerder"));
                }
                if (types.Contains(GebruikerType.Hulpverlener))
                {
                    HulpverlenerSqlContext hsc = new HulpverlenerSqlContext();
                    HulpverlenerRepository hr  = new HulpverlenerRepository(hsc);
                    Session["LoggedInUser"] = hr.GetById(g.Id);
                    return(RedirectToAction("Index", "Hulpverlener"));
                }
                return(RedirectToAction("Index", "Login"));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Index", "Error"));
            }
        }