Exemple #1
0
        public void Update()
        {
            GebruikerSQLContext gsc = new GebruikerSQLContext();
            GebruikerRepository gr  = new GebruikerRepository(gsc);

            Gebruiker user = gr.Retrieve("1");

            user.Voornaam = "aangepast";
            gr.Update(user);
        }
        public void Update()
        {
            GebruikerSqlContext gsc = new GebruikerSqlContext();
            GebruikerRepository gr  = new GebruikerRepository(gsc);

            Gebruiker g = gr.GetById(1);

            g.Uitschrijfdatum = DateTime.Now;
            g.Naam            = g.Naam + "aangepast";
            gr.Update(g);
        }
        public void UpdateGebruiker()
        {
            Gebruiker harry = new Gebruiker(1, 0, "Harry", "henrie", "Niew", "Nieuwe gebruiker", 0,
                                            "*****@*****.**",
                                            Functie.Gebruiker);

            repo.Update(harry);

            //Assert
            Assert.AreEqual(repo.GetById(1), harry);
        }
Exemple #4
0
        public string SaveOrUpdate()
        {
            GebruikerSQLContext gsc = new GebruikerSQLContext();
            GebruikerRepository gr  = new GebruikerRepository(gsc);

            if (Id != 0)
            {
                gr.Update(this);
                return(this.Id.ToString());
            }
            else
            {
                return(gr.Create(this));
            }
        }
Exemple #5
0
        public ActionResult Update(FormCollection form, int id, HttpPostedFileBase foto)
        {
            if (!AuthRepository.CheckIfUserCanAcces(GebruikerType.All, (Gebruiker)Session["LoggedInUser"]))
            {
                return(View("~/Views/Error/AuthError.cshtml"));
            }

            try
            {
                if (Session["LoggedInUser"] != null)
                {
                    Gebruiker              loggedinGebruiker = Session["LoggedInUser"] as Gebruiker;
                    GebruikerSqlContext    sql       = new GebruikerSqlContext();
                    GebruikerRepository    repo      = new GebruikerRepository(sql);
                    VrijwilligerSqlContext vsql      = new VrijwilligerSqlContext();
                    VrijwilligerRepository vrepo     = new VrijwilligerRepository(vsql);
                    Gebruiker              gebruiker = new Gebruiker();
                    gebruiker.Id = id;
                    string path     = "";
                    string fotoPath = "";
                    if (foto != null)
                    {
                        if (foto.ContentLength > 0)
                        {
                            if (Path.GetExtension(foto.FileName).ToLower() == ".png" || Path.GetExtension(foto.FileName).ToLower() == ".jpg" ||
                                Path.GetExtension(foto.FileName).ToLower() == ".jpeg")
                            {
                                path = Path.Combine(Server.MapPath("~/Content/Foto"), foto.FileName);
                                foto.SaveAs(path);
                                fotoPath        = "/Content/Foto/" + foto.FileName;
                                gebruiker.Image = fotoPath;
                            }
                        }
                    }
                    else
                    {
                        gebruiker.Image = loggedinGebruiker.Image;
                    }
                    if (form["wachtwoord"] != "" && form["wachtwoordnieuw"] != "")
                    {
                        if (form["wachtwoord"] == form["wachtwoordnieuw"])
                        {
                            gebruiker.Wachtwoord = form["wachtwoord"];
                        }
                    }
                    else
                    {
                        gebruiker.Wachtwoord = loggedinGebruiker.Wachtwoord;
                    }

                    gebruiker.Geslacht = (Geslacht)Enum.Parse(typeof(Geslacht), form["geslacht"]);
                    gebruiker.Adres    = form["adres"];
                    gebruiker.Email    = form["email"];

                    gebruiker.Woonplaats     = form["plaats"];
                    gebruiker.Land           = form["land"];
                    gebruiker.Postcode       = form["postcode"];
                    gebruiker.Telefoonnummer = form["telnr"];
                    gebruiker.Gebruikersnaam = form["gebruikersnaam"];
                    gebruiker.Naam           = form["naam"];
                    gebruiker.HeeftAuto      = Convert.ToBoolean(form["auto"]);
                    gebruiker.HeeftRijbewijs = Convert.ToBoolean(form["rijbewijs"]);
                    gebruiker.HeeftOv        = Convert.ToBoolean(form["ov"]);
                    gebruiker.Barcode        = form["barcode"];

                    string[]   vaardigheidIds    = form.GetValues("vaardigheden");
                    List <int> vaardigheidIdList = new List <int>();
                    if (vaardigheidIds != null)
                    {
                        foreach (string vaardigheidId in vaardigheidIds)
                        {
                            vaardigheidIdList.Add(Convert.ToInt32(vaardigheidId));
                        }
                    }
                    if (vaardigheidIdList.Count != 0)
                    {
                        vrepo.CreateVrijwilligerWithVaardigheid(gebruiker.Id, vaardigheidIdList);
                    }
                    repo.Update(gebruiker);

                    return(RedirectToAction("Gegevens", "Gebruiker", new { id = gebruiker.Id }));
                }
                return(RedirectToAction("Index", "Login"));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Index", "Error"));
            }
        }