コード例 #1
0
        public ActionResult Details(int id)
        {
            if (!AuthRepository.CheckIfUserCanAcces(GebruikerType.All, (Gebruiker)Session["LoggedInUser"]))
            {
                return(View("~/Views/Error/AuthError.cshtml"));
            }

            try
            {
                HulpvraagSqlContext hsc     = new HulpvraagSqlContext();
                HulpvraagRepository hr      = new HulpvraagRepository(hsc);
                Hulpvraag           hulpvrg = hr.GetById(id);


                ReactieSqlContext rsc = new ReactieSqlContext();
                ReactieRepository rr  = new ReactieRepository(rsc);

                List <Reactie> reacties = rr.GetReatiesByHulpvraagId(id);
                ViewBag.reacties = reacties;

                return(View(hulpvrg));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Index", "Error"));
            }
        }
コード例 #2
0
        // GET: Beheerder
        public ActionResult Index()
        {
            if (!AuthRepository.CheckIfUserCanAcces(GebruikerType.Beheerder, (Gebruiker)Session["LoggedInUser"]))
            {
                return(View("~/Views/Error/AuthError.cshtml"));
            }

            try
            {
                BeheerderViewModel model = new BeheerderViewModel();

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

                GebruikerSqlContext gsc = new GebruikerSqlContext();
                GebruikerRepository gr  = new GebruikerRepository(gsc);

                model.LstGebruiker = gr.GetUserWithType();
                model.LstHulpvraag = hr.GetAll();

                return(View(model));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Index", "Error"));
            }
        }
コード例 #3
0
        // GET: Vrijwilliger
        public ActionResult Index()
        {
            if (!AuthRepository.CheckIfUserCanAcces(GebruikerType.Vrijwilliger, (Gebruiker)Session["LoggedInUser"]))
            {
                return(View("~/Views/Error/AuthError.cshtml"));
            }

            HulpvraagSqlContext hvsc = new HulpvraagSqlContext();
            HulpvraagRepository hvr  = new HulpvraagRepository(hvsc);

            var vrijwilliger = (Vrijwilliger)Session["LoggedInUser"];

            try
            {
                //Haal mijn opdrachten op
                List <Hulpvraag> hulpvragen = hvr.GetHulpvragenByVrijwilligerId(vrijwilliger.Id);
                ViewBag.hulpvragen = hulpvragen;


                return(View("~/Views/Vrijwilliger/Hoofdscherm.cshtml"));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Index", "Error"));
            }
        }
コード例 #4
0
        public void GetAll()
        {
            HulpvraagSqlContext hvsc = new HulpvraagSqlContext();
            HulpvraagRepository hvr  = new HulpvraagRepository(hvsc);

            var Lijst = hvr.GetAll();
        }
コード例 #5
0
        public void Delete()
        {
            HulpvraagSqlContext hvsc = new HulpvraagSqlContext();
            HulpvraagRepository hvr  = new HulpvraagRepository(hvsc);

            hvr.Delete(3);
        }
コード例 #6
0
        public bool CanReview(int hulpbehoevendeId, int vrijwilligerId)
        {
            HulpvraagSqlContext hsc = new HulpvraagSqlContext();
            HulpvraagRepository hr  = new HulpvraagRepository(hsc);

            List <Hulpvraag> hulpvragen = hr.GetHulpvragenByHulpbehoevendeId(hulpbehoevendeId);
            List <Review>    reviews    = this.GetReviewByHulpbehoevendeId(hulpbehoevendeId);

            bool returnValue = false;

            foreach (Hulpvraag hv in hulpvragen)
            {
                //Hulpbehoevende zit gekoppeld aan vrijwilliger in hulpvraag
                if (hv.Vrijwilliger != null && hv.Vrijwilliger.Id == vrijwilligerId)
                {
                    returnValue = true;

                    foreach (Review r in reviews)
                    {
                        //Check of review al bestaat
                        if (r.GebruikerId == vrijwilligerId)
                        {
                            returnValue = false;
                        }
                    }
                }
            }


            return(returnValue);
        }
コード例 #7
0
        public void GetHulpvragenByVrijwilligerId()
        {
            HulpvraagSqlContext hvsc = new HulpvraagSqlContext();
            HulpvraagRepository hvr  = new HulpvraagRepository(hvsc);

            List <Hulpvraag> lijst = hvr.GetHulpvragenByVrijwilligerId(4);
        }
コード例 #8
0
        public ActionResult RemoveVrijwilliger(int id)
        {
            HulpvraagSqlContext hvsc = new HulpvraagSqlContext();
            HulpvraagRepository hvr  = new HulpvraagRepository(hvsc);

            hvr.RemoveVrijwilligerFromHulpvraag(id);

            return(RedirectToAction("Details", "Hulpvraag", new { id = id }));
        }
コード例 #9
0
        public void Update()
        {
            HulpvraagSqlContext hvsc = new HulpvraagSqlContext();
            HulpvraagRepository hvr  = new HulpvraagRepository(hvsc);

            Hulpvraag hulpvraag = hvr.GetById(1);

            hvr.Update(1, hulpvraag);
        }
コード例 #10
0
        public void GetById()
        {
            HulpvraagSqlContext hvsc = new HulpvraagSqlContext();
            HulpvraagRepository hvr  = new HulpvraagRepository(hvsc);

            Hulpvraag hulpvraag = hvr.GetById(1);

            Assert.AreEqual(1, hulpvraag.Vaardigheden[0].Omschrijving);
        }
コード例 #11
0
        public void GetHulpvragenByHulpbehoevendeId()
        {
            HulpvraagSqlContext hvsc = new HulpvraagSqlContext();
            HulpvraagRepository hvr  = new HulpvraagRepository(hvsc);

            List <Hulpvraag> lijst = new List <Hulpvraag>();

            lijst = hvr.GetHulpvragenByHulpbehoevendeId(4);
            Assert.AreEqual(5, lijst.Count);
        }
コード例 #12
0
        public void GetByHulpvraagId()
        {
            BeschikbaarheidSqlContext bsc = new BeschikbaarheidSqlContext();
            BeschikbaarheidRepository br  = new BeschikbaarheidRepository(bsc);

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

            Hulpvraag hulpvrg = hr.GetById(5);

            List <Beschikbaarheid> LstBsch = br.GetBeschikbaarheidByHulpvraagId(hulpvrg.Id);

            Assert.IsTrue(LstBsch.Count > 0);
        }
コード例 #13
0
        public void Create()
        {
            HulpvraagSqlContext hvsc = new HulpvraagSqlContext();
            HulpvraagRepository hvr  = new HulpvraagRepository(hvsc);

            Hulpvraag hulpvraag = hvr.GetById(1);


            VaardigheidSqlContext vsc = new VaardigheidSqlContext();
            VaardigheidRepository vr  = new VaardigheidRepository(vsc);

            hulpvraag.Vaardigheden = vr.GetAll();

            hvr.Create(hulpvraag);
        }
コード例 #14
0
        // GET: Beheerder/Details/5
        public ActionResult Details(int id)
        {
            if (!AuthRepository.CheckIfUserCanAcces(GebruikerType.Beheerder, (Gebruiker)Session["LoggedInUser"]))
            {
                return(View("~/Views/Error/AuthError.cshtml"));
            }

            try
            {
                HulpvraagSqlContext hsc     = new HulpvraagSqlContext();
                HulpvraagRepository hr      = new HulpvraagRepository(hsc);
                Hulpvraag           hulpvrg = hr.GetById(id);
                return(View(hulpvrg));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Index", "Error"));
            }
        }
コード例 #15
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);
        }
コード例 #16
0
        public ActionResult DeleteHulpvraag(int id)
        {
            if (!AuthRepository.CheckIfUserCanAcces(GebruikerType.All, (Gebruiker)Session["LoggedInUser"]))
            {
                return(View("~/Views/Error/AuthError.cshtml"));
            }
            try
            {
                HulpvraagSqlContext hvsc = new HulpvraagSqlContext();
                HulpvraagRepository hvr  = new HulpvraagRepository(hvsc);

                hvr.Delete(id);

                return(RedirectToAction("Index", "Hulpbehoevende"));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Index", "Error"));
            }
        }
コード例 #17
0
        public ActionResult OpdrachtOverzicht()
        {
            if (!AuthRepository.CheckIfUserCanAcces(GebruikerType.Vrijwilliger, (Gebruiker)Session["LoggedInUser"]))
            {
                return(View("~/Views/Error/AuthError.cshtml"));
            }

            HulpvraagSqlContext hvsc = new HulpvraagSqlContext();
            HulpvraagRepository hvr  = new HulpvraagRepository(hvsc);

            try
            {
                //Haal alle opdrachten op die nog geen vrijwilliger hebben.
                List <Hulpvraag> hulpvragen = hvr.GetHulpvragenZonderVrijwilliger();
                ViewBag.hulpvragen = hulpvragen;

                return(View("~/Views/Vrijwilliger/OpdrachtOverzicht.cshtml"));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Index", "Error"));
            }
        }
コード例 #18
0
        public ActionResult Opdrachten(string id)
        {
            if (!AuthRepository.CheckIfUserCanAcces(GebruikerType.Hulpverlener, (Gebruiker)Session["LoggedInUser"]))
            {
                return(View("~/Views/Error/AuthError.cshtml"));
            }
            try
            {
                Hulpverlener loggedInHulpverlener = (Hulpverlener)Session["LoggedInUser"];

                if (loggedInHulpverlener != null)
                {
                    HulpbehoevendeSqlContext hsc = new HulpbehoevendeSqlContext();
                    HulpbehoevendeRepository hr  = new HulpbehoevendeRepository(hsc);

                    HulpvraagSqlContext hulpvraagsc = new HulpvraagSqlContext();
                    HulpvraagRepository hulpvraagr  = new HulpvraagRepository(hulpvraagsc);

                    //Alle hulpbehoevenden
                    ViewBag.HulpBehoevenden = hr.GetHulpbehoevendenByHulpverlenerId(loggedInHulpverlener.Id);


                    //Opdrachten van hulpbehoevenden
                    ViewBag.hulpvragen = hulpvraagr.GetHulpvragenByHulpbehoevendeId(Convert.ToInt32(id));

                    return(View("~/Views/Hulpverlener/Hulpverlener.cshtml"));
                }
                else
                {
                    return(View("~/Views/Login/Login.cshtml"));
                }
            }
            catch (Exception e)
            {
                return(RedirectToAction("Index", "Error"));
            }
        }
コード例 #19
0
        // GET: Hulpbehoevende
        public ActionResult Index()
        {
            if (!AuthRepository.CheckIfUserCanAcces(GebruikerType.Hulpbehoevende, (Gebruiker)Session["LoggedInUser"]))
            {
                return(View("~/Views/Error/AuthError.cshtml"));
            }

            try
            {
                var hulpbehoevende = (Hulpbehoevende)Session["LoggedInUser"];

                HulpvraagSqlContext hvsc = new HulpvraagSqlContext();
                HulpvraagRepository hvr  = new HulpvraagRepository(hvsc);

                List <Hulpvraag> hulpvragen = hvr.GetHulpvragenByHulpbehoevendeId(hulpbehoevende.Id);
                ViewBag.hulpvragen = hulpvragen;

                return(View("~/Views/Hulpbehoevende/Opdrachten.cshtml"));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Index", "Error"));
            }
        }
コード例 #20
0
        public ActionResult CreateOpdracht(FormCollection form)
        {
            if (!AuthRepository.CheckIfUserCanAcces(GebruikerType.Hulpbehoevende, (Gebruiker)Session["LoggedInUser"]))
            {
                return(View("~/Views/Error/AuthError.cshtml"));
            }
            try
            {
                //Vervoerstype parsen
                VervoerType vervoerstype = (VervoerType)Enum.Parse(typeof(VervoerType), form["vervoertype"]);

                //Urgentie controleren
                bool urgent = false;

                if (form["urgent"] == "urgent")
                {
                    urgent = true;
                }

                //Haal de ingelogde gebruiker op
                var hulpbehoevende = (Hulpbehoevende)Session["LoggedInUser"];

                Hulpvraag hulpvraag = new Hulpvraag(
                    form["titel"],
                    form["beschrijving"],
                    DateTime.Parse(form["opdrachtdatum"]),
                    DateTime.Now,
                    form["locatie"],
                    urgent,
                    vervoerstype,
                    false,
                    hulpbehoevende
                    );

                if (form["vaardigheden[]"] != null)
                {
                    string s = form["vaardigheden[]"];

                    if (s != null)
                    {
                        int[] vaardighedenids = Array.ConvertAll(s.Split(','), int.Parse);

                        hulpvraag.Vaardigheden = new List <Vaardigheid>();

                        foreach (int id in vaardighedenids)
                        {
                            Vaardigheid vaardigheid = new Vaardigheid(id);
                            hulpvraag.Vaardigheden.Add(vaardigheid);
                        }
                    }
                }

                HulpvraagSqlContext hvsc = new HulpvraagSqlContext();
                HulpvraagRepository hvr  = new HulpvraagRepository(hvsc);

                hvr.Create(hulpvraag);

                return(RedirectToAction("Index", "Hulpbehoevende"));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Index", "Error"));
            }
        }