public List <Beschikbaarheid> GetAllBeschikbaarheid()
        {
            List <Beschikbaarheid> returnList = new List <Beschikbaarheid>();

            try
            {
                using (SqlConnection con = new SqlConnection(Env.ConnectionString))
                {
                    con.Open();
                    string     query = "SELECT * FROM Beschikbaarheid";
                    SqlCommand cmd   = new SqlCommand(query, con);

                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        Beschikbaarheid b = new Beschikbaarheid(
                            reader.GetInt32(0),
                            (Dagnaam)Enum.Parse(typeof(Dagnaam), reader.GetString(1)),
                            (Dagdeel)Enum.Parse(typeof(Dagdeel), reader.GetString(2))
                            );
                        returnList.Add(b);
                    }

                    con.Close();
                }

                return(returnList);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
        public Beschikbaarheid GetBeschikbaarheidById(int Id)
        {
            Beschikbaarheid returnBeschikbaarheid = null;

            try
            {
                using (SqlConnection con = new SqlConnection(Env.ConnectionString))
                {
                    con.Open();
                    string     query = "select * from Beschikbaarheid where Id = @key";
                    SqlCommand cmd   = new SqlCommand(query, con);
                    cmd.Parameters.AddWithValue("@key", Id);

                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        Beschikbaarheid beschikbaarheid = new Beschikbaarheid(
                            reader.GetInt32(0),
                            (Dagnaam)Enum.Parse(typeof(Dagnaam), reader.GetString(1)),
                            (Dagdeel)Enum.Parse(typeof(Dagdeel), reader.GetString(2))
                            );
                        returnBeschikbaarheid = beschikbaarheid;
                    }

                    con.Close();
                }

                return(returnBeschikbaarheid);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
        public List <Beschikbaarheid> GetBeschikbaarheidByHulpvraagId(int id)
        {
            List <Beschikbaarheid> returnList = new List <Beschikbaarheid>();

            try
            {
                using (SqlConnection con = new SqlConnection(Env.ConnectionString))
                {
                    con.Open();
                    string query = "SELECT * FROM Beschikbaarheid WHERE Id IN (SELECT beschikbaarheidId FROM Hulpvraag_Beschikbaarheid WHERE hulpvraagId = @id)";

                    SqlCommand cmd = new SqlCommand(query, con);
                    cmd.Parameters.AddWithValue("@id", id);
                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        Beschikbaarheid b = new Beschikbaarheid(
                            reader.GetInt32(0),
                            (Dagnaam)Enum.Parse(typeof(Dagnaam), reader.GetString(1)),
                            (Dagdeel)Enum.Parse(typeof(Dagdeel), reader.GetString(2))
                            );
                        returnList.Add(b);
                    }
                    con.Close();
                }
                return(returnList);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
예제 #4
0
        public List <Beschikbaarheid> GetPlanning(Models.Student student)
        {
            SqlCommand cmd = new SqlCommand("GetPlanning");

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@StudentEmail", student.email);
            List <DataRow>         beschikbaarheidOverview = new List <DataRow>();
            List <Beschikbaarheid> beschikbaarheden        = new List <Beschikbaarheid>();

            try
            {
                beschikbaarheidOverview.AddRange(connector.ExecuteQueryCommand(cmd));

                foreach (DataRow dr in beschikbaarheidOverview)
                {
                    Beschikbaarheid beschikbaarheid = new Beschikbaarheid(Convert.ToString(dr["BeginTijd"]),
                                                                          Convert.ToString(dr["EindTijd"]), Convert.ToDateTime(dr["Date"]));
                    beschikbaarheden.Add(beschikbaarheid);
                }
                return(beschikbaarheden);
            }
            catch (Exception ex)
            {
                string message = ex.ToString();
                return(null);
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Beschikbaarheid beschikbaarheid = db.Beschikbaarheid.Find(id);

            db.Beschikbaarheid.Remove(beschikbaarheid);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public void GetById()
        {
            BeschikbaarheidSqlContext bsc = new BeschikbaarheidSqlContext();
            BeschikbaarheidRepository br  = new BeschikbaarheidRepository(bsc);

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

            Assert.AreEqual(id, beschikbaarheid.Id);
        }
예제 #7
0
 public bool RegistreerBeschikbaarheid(Beschikbaarheid Beschikbaarheid)
 {
     if (_icontextStudent.SetBeschikbaar(Beschikbaarheid))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public ActionResult Edit([Bind(Include = "ID,Inspecteur_ID,Datum")] Beschikbaarheid beschikbaarheid)
 {
     if (ModelState.IsValid)
     {
         db.Entry(beschikbaarheid).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Inspecteur_ID = new SelectList(db.Inspecteur, "ID", "Username", beschikbaarheid.Inspecteur_ID);
     return(View(beschikbaarheid));
 }
        public void Save(Beschikbaarheid beschikbaarheid, object obj)
        {
            if (obj.GetType() == typeof(Vrijwilliger))
            {
                Vrijwilliger v = (Vrijwilliger)obj;
                try
                {
                    using (SqlConnection con = new SqlConnection(Env.ConnectionString))
                    {
                        con.Open();
                        string     query = "INSERT INTO Vrijwilliger_Beschikbaarheid(VrijwilligerId, BeschikbaarheidId) VALUES(@vrijwilligerId, @beschikbaarheidId);";
                        SqlCommand cmd   = new SqlCommand(query, con);

                        cmd.Parameters.AddWithValue("@vrijwilligerId", v.Id);
                        cmd.Parameters.AddWithValue("@beschikbaarheidId", beschikbaarheid.Id);

                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }
            if (obj.GetType() == typeof(Hulpvraag))
            {
                Hulpvraag h = (Hulpvraag)obj;
                try
                {
                    using (SqlConnection con = new SqlConnection(Env.ConnectionString))
                    {
                        con.Open();
                        string     query = "INSERT INTO Hulpvraag_Beschikbaarheid(hulpvraagId, beschikbaarheidId) VALUES(@HulpvraagId, @BeschikbaarheidId);";
                        SqlCommand cmd   = new SqlCommand(query, con);

                        cmd.Parameters.AddWithValue("@HulpvraagId", h.Id);
                        cmd.Parameters.AddWithValue("@BeschikbaarheidId", beschikbaarheid.Id);

                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }
        }
        // GET: Availability/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Beschikbaarheid beschikbaarheid = db.Beschikbaarheid.Find(id);

            if (beschikbaarheid == null)
            {
                return(HttpNotFound());
            }
            return(View(beschikbaarheid));
        }
        // GET: Availability/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Beschikbaarheid beschikbaarheid = db.Beschikbaarheid.Find(id);

            if (beschikbaarheid == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Inspecteur_ID = new SelectList(db.Inspecteur, "ID", "Username", beschikbaarheid.Inspecteur_ID);
            return(View(beschikbaarheid));
        }
예제 #12
0
        public bool SetBeschikbaar(Beschikbaarheid beschikbaar)
        {
            int aantalBeschikbaarHeden = Beschikbaarheden.Count;

            Beschikbaarheden.Add(beschikbaar);
            int NieuwAantal = Beschikbaarheden.Count;

            if (NieuwAantal > aantalBeschikbaarHeden)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #13
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);
        }
예제 #14
0
        public ActionResult SetSingleBeschikbaar(DateTime Begin, DateTime Eind, DateTime Date)
        {
            Student student = new Student();

            student = (Student)Session["Student"];
            string beginTijd = Begin.ToString("t");
            string eindTijd  = Eind.ToString("t");

            Date = Date.Date;
            Models.Beschikbaarheid Beschikbaarheid = new Beschikbaarheid(student, beginTijd, eindTijd, Date);

            if (StudentRepo.RegistreerBeschikbaarheid(Beschikbaarheid))
            {
                return(RedirectToAction("StudentBase", "Student"));
            }
            else
            {
                return(RedirectToAction("StudentBase", "Student"));
            }
        }
예제 #15
0
        public bool SetBeschikbaar(Beschikbaarheid beschikbaarheid)
        {
            SqlCommand cmd = new SqlCommand("SetBeschikbaar");

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@studentMail", beschikbaarheid.Student.email);
            cmd.Parameters.AddWithValue("@Date", beschikbaarheid.Datum);
            cmd.Parameters.AddWithValue("@Begin", beschikbaarheid.StartTime);
            cmd.Parameters.AddWithValue("@Eind", beschikbaarheid.EindTime);

            try
            {
                connector.ExecuteQueryCommand(cmd);
                return(true);
            }
            catch (Exception ex)
            {
                string message = ex.ToString();
                return(false);
            }
        }
        public static void SaveBeschikbaarheid(Gebruiker gebruiker)
        {
            using (var context = new FestiSpecDBEntities())
            {
                Gebruiker geb = context.Gebruiker.Single(a => a.Id == gebruiker.Id);

                foreach (var item in gebruiker.Beschikbaarheid)
                {
                    Beschikbaarheid besch = context.Beschikbaarheid.SingleOrDefault(t => t.Datum == item.Datum);
                    if (besch == null)
                    {
                        besch = new Beschikbaarheid()
                        {
                            Datum = item.Datum
                        };
                        context.Beschikbaarheid.Add(besch);
                    }

                    geb.Beschikbaarheid.Add(besch);
                }
                context.SaveChanges();


                //context.Gebruiker.Attach(gebruiker);

                //foreach (var item in gebruiker.Beschikbaarheid)
                //{
                //    context.Beschikbaarheid.Attach(item);
                //}

                //context.Gebruiker.Add(gebruiker);
                //context.Entry(gebruiker).State = System.Data.Entity.EntityState.Modified;

                //context.SaveChanges();
            }
        }
        public void UpdateBeschikbaarheid(Beschikbaarheid obj)
        {
            try
            {
                using (SqlConnection con = new SqlConnection(Env.ConnectionString))
                {
                    con.Open();
                    string     query = "UPDATE Beschikbaarheid SET DagNaam = @dagnaam, DagDeel = @dagdeel WHERE id = @key";
                    SqlCommand cmd   = new SqlCommand(query, con);

                    cmd.Parameters.AddWithValue("@dagnaam", obj.DagNaam);
                    cmd.Parameters.AddWithValue("@dagdeel", obj.DagDeel);

                    cmd.Parameters.AddWithValue("@key", obj.Id);
                    int reader = cmd.ExecuteNonQuery();
                    con.Close();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
 public void UpdateBeschikbaarheid(Beschikbaarheid b)
 {
     _interface.UpdateBeschikbaarheid(b);
 }
예제 #19
0
 public BeschikbaarheidVM(Beschikbaarheid beschikbaarheid)
 {
     this.model = beschikbaarheid;
 }
 public void Save(Beschikbaarheid beschikbaarheid, object obj)
 {
     _interface.Save(beschikbaarheid, obj);
 }
예제 #21
0
 public BeschikbaarheidVM()
 {
     this.model = new Beschikbaarheid();
 }