Пример #1
0
 public static void save(Chauffeur chauffeur)
 {
     if (chauffeur.Id == 0)
     {
         OdbcCommand cmd = new OdbcCommand("insert into chauffeur (Numero,Nom,Prenom, DateNaissance, Telephone, Adresse, Permis, Status) values(?,?,?,?,?,?,?,?)", AccesBd.getConnection());
         cmd.Parameters.Add("@Numero", OdbcType.VarChar).Value    = chauffeur.Numero;
         cmd.Parameters.Add("@nom", OdbcType.VarChar).Value       = chauffeur.Nom;
         cmd.Parameters.Add("@prenom", OdbcType.VarChar).Value    = chauffeur.Prenom;
         cmd.Parameters.Add("@DateNais", OdbcType.DateTime).Value = chauffeur.DateNais;
         cmd.Parameters.Add("@Telephone", OdbcType.VarChar).Value = chauffeur.Telephone;
         cmd.Parameters.Add("@Adresse", OdbcType.VarChar).Value   = chauffeur.Adresse;
         cmd.Parameters.Add("@Adresse", OdbcType.VarChar).Value   = chauffeur.Permis;
         cmd.Parameters.Add("@Status", OdbcType.VarChar).Value    = chauffeur.Status;
         cmd.ExecuteNonQuery();
         cmd.Dispose();
     }
     else
     {
         OdbcCommand cmd = new OdbcCommand("update chauffeur set Numero=?,Nom=?,Prenom=?, DateNaissance=?, Telephone=?, Adresse=?, Permis=?, Status=? where Id=?", AccesBd.getConnection());
         cmd.Parameters.Add("@Numero", OdbcType.VarChar).Value    = chauffeur.Numero;
         cmd.Parameters.Add("@nom", OdbcType.VarChar).Value       = chauffeur.Nom;
         cmd.Parameters.Add("@prenom", OdbcType.VarChar).Value    = chauffeur.Prenom;
         cmd.Parameters.Add("@DateNais", OdbcType.DateTime).Value = chauffeur.DateNais;
         cmd.Parameters.Add("@Telephone", OdbcType.VarChar).Value = chauffeur.Telephone;
         cmd.Parameters.Add("@Adresse", OdbcType.VarChar).Value   = chauffeur.Adresse;
         cmd.Parameters.Add("@Adresse", OdbcType.VarChar).Value   = chauffeur.Permis;
         cmd.Parameters.Add("@Status", OdbcType.VarChar).Value    = chauffeur.Status;
         cmd.Parameters.Add("@id", OdbcType.Int).Value            = chauffeur.Id;
         cmd.ExecuteNonQuery();
         cmd.Dispose();
     }
 }
Пример #2
0
        private void cbChauffeur_SelectedValueChanged(object sender, EventArgs e)
        {
            Chauffeur chau = ChauffeurDao.findByNumero(cbChauffeur.Text);

            txtNomChau.Text = chau.Nom;
            txtPreChau.Text = chau.Prenom;
        }
Пример #3
0
        private void BtnValider_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(txtMatricule.Text) ||
                    string.IsNullOrWhiteSpace(txtNomChauffeur.Text) ||
                    string.IsNullOrWhiteSpace(txtPrenomsChauffeur.Text) ||
                    string.IsNullOrWhiteSpace(txtTelephone1.Text))
                {
                    MessageBox.Show("Veuillez remplir les champs obligatoires !", "mTransport", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    Chauffeur M = new Chauffeur();
                    M.Matricule           = txtMatricule.Text;
                    M.NomChauffeur        = txtNomChauffeur.Text;
                    M.PrenomChauffeur     = txtPrenomsChauffeur.Text;
                    M.AdresseChauffeur    = txtAdresse.Text;
                    M.Telephone1Chauffeur = txtTelephone1.Text;
                    M.Telephone2Chauffeur = txtTelephone2.Text;
                    M.DateEmbauche        = txtDateEmbauche.SelectedDate;
                    M.PersonneAPrevenir   = txtPersonneAPrevenir.Text;
                    if (txtImage.Source == null)
                    {
                        M.PhotoChauffeur = null;
                    }
                    else
                    {
                        M.PhotoChauffeur = Hex.ToHexString(ImageConverter.ToArray(ImageConverter.FromImage((BitmapSource)txtImage.Source)));
                    }


                    if (Id > 0)
                    {
                        M.Id = Id;
                        M.Update();
                        MessageBox.Show("Modification effectuée !", "mTransport", MessageBoxButton.OK, MessageBoxImage.Information);
                        LoadTabChauffeur();
                        GriserChamps();
                        Id = 0;
                    }
                    else
                    {
                        M.Insert();
                        ListChauffeur.Add(M);
                        TabChauffeur.Items.Refresh();
                        MessageBox.Show("Enregistrement effectué !", "mTransport", MessageBoxButton.OK, MessageBoxImage.Information);
                        GriserChamps();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 public ActionResult Edit([Bind(Include = "Id,Nom,Prenom,Courriel,Telephone,Ville,Age,Email,EmailConfirmed,PasswordHash,SecurityStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEndDateUtc,LockoutEnabled,AccessFailedCount,UserName,DatePermis,DateEmbauche")] Chauffeur chauffeur)
 {
     if (ModelState.IsValid)
     {
         db.Entry(chauffeur).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(chauffeur));
 }
Пример #5
0
 public void Model2Form(Chauffeur chauf)
 {
     chauffeur              = chauf;
     txtNumero.Text         = chauf.Numero;
     txtNom.Text            = chauf.Nom;
     txtPrenom.Text         = chauf.Numero;
     cbDate.Value           = chauf.DateNais;
     txtTelephone.Text      = chauf.Telephone;
     txtAdresse.Text        = chauf.Adresse;
     txtPermis.Text         = chauf.Permis;
     cbStatus.SelectedValue = chauf.Status;
 }
Пример #6
0
        public void ListChauffeur()
        {
            var l = Chauffeur.getAll();

            foreach (var item in l)
            {
                LoadCombo lCombo = new LoadCombo();
                lCombo.Id      = item.Id;
                lCombo.Libelle = item.NomChauffeur + " " + item.PrenomChauffeur;
                ListChauffeurs.Add(lCombo);
            }
            cmbChauffeur.ItemsSource = ListChauffeurs;
        }
Пример #7
0
        public async Task <ActionResult> RegisterChauffeur(RegisterViewModelChauffeur model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    //   bd.Trajets.Where(x => x.Id == 0).FirstOrDefault().Chauffeur.Voiture.Where(x => x.VoitureID == 1).FirstOrDefault().nbPlace;
                    //  bd.Trajets.Where(x => x.Id == 0).FirstOrDefault().Client.Count();
                    var currentUser = UserManager.Users.Where(x => x.Email == model.Email).FirstOrDefault();

                    Chauffeur chauffeur = new Chauffeur {
                        Email = model.Email, Prenom = model.Prenom, Nom = model.Nom, DateEmbauche = model.DateEmbauche, DatePermis = model.DatePermis, NumeroPermis = model.NumeroPermis, NumeroTelephone = model.NumeroTelephone, Ville = model.Ville, Voiture = new List <Voiture>(), Public = model.Public
                    };
                    chauffeur.Voiture.Add(new Voiture {
                        nbPlace = model.NbPlace, ModeleVoiture = model.VehiculeModel, dateMiseRoute = model.DateEnRoute
                    });
                    bd.Chauffeur.Add(chauffeur);

                    bd.SaveChanges();
                    var roleManager = new RoleManager <IdentityRole>(new
                                                                     RoleStore <IdentityRole>(new ApplicationDbContext()));
                    if (!roleManager.RoleExists("Chauffeur"))
                    {
                        var role = new IdentityRole();
                        role.Name = "Chauffeur";
                        roleManager.Create(role);
                    }
                    // Attribution du rôle
                    var addRole = await UserManager.AddToRoleAsync(user.Id, "Chauffeur");

                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // Pour plus d'informations sur l'activation de la confirmation de compte et de la réinitialisation de mot de passe, visitez https://go.microsoft.com/fwlink/?LinkID=320771
                    // Envoyer un message électronique avec ce lien
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirmez votre compte", "Confirmez votre compte en cliquant <a href=\"" + callbackUrl + "\">ici</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // Si nous sommes arrivés là, un échec s’est produit. Réafficher le formulaire
            return(View(model));
        }
Пример #8
0
        private void btnChange_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < dgDriver.RowCount; i++)
            {
                if ((bool)dgDriver.Rows[i].Selected)
                {
                    AddDriverForm adf       = new AddDriverForm();
                    Chauffeur     chauffeur = ChauffeurDao.findByNumero(dgDriver.Rows[i].Cells[0].Value.ToString());
                    adf.Model2Form(chauffeur);

                    adf.ShowDialog();
                }
            }
        }
Пример #9
0
        public static List <Chauffeur> findby(string tab, string val)
        {
            List <Chauffeur> chauffeurs = new List <Chauffeur>();
            OdbcCommand      cmd        = new OdbcCommand("select Id from chauffeur where " + tab + " LIKE('%" + val + "%') ", AccesBd.getConnection());
            OdbcDataReader   dr         = cmd.ExecuteReader();

            while (dr.Read())
            {
                Chauffeur chau = find(dr.GetInt32(0));
                chauffeurs.Add(chau);
            }
            cmd.Dispose();
            return(chauffeurs);
        }
Пример #10
0
        public static List <Chauffeur> findAll()
        {
            List <Chauffeur> chauffeurs = new List <Chauffeur>();
            OdbcCommand      cmd        = new OdbcCommand("select Id from chauffeur", AccesBd.getConnection());
            OdbcDataReader   dr         = cmd.ExecuteReader();

            while (dr.Read())
            {
                Chauffeur chauffeur = find(dr.GetInt32(0));
                chauffeurs.Add(chauffeur);
            }
            cmd.Dispose();
            return(chauffeurs);
        }
Пример #11
0
 private void BtnSupprimer_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Chauffeur T = TabChauffeur.SelectedItem as Chauffeur;
         T.Supprime = true;
         T.Update();
         ListChauffeur.Remove(T);
         TabChauffeur.Items.Refresh();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #12
0
        public async Task <ActionResult> RegisterChauffeur(RegisterViewModelChauffeur model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser
                {
                    UserName  = model.Email,
                    Email     = model.Email,
                    Age       = model.Age,
                    Nom       = model.Nom,
                    Telephone = model.Telephone,
                    Prenom    = model.Prenom,
                    Ville     = model.ville
                };

                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    //La creation du role se fait dans le startup
                    //attribution du role
                    UserManager.AddToRole(user.Id, "Chauffeur");

                    Chauffeur chauffeur = new Chauffeur
                    {
                        Id           = user.Id,
                        DateEmbauche = DateTime.Now,
                        DatePermis   = model.DatePermis,
                        Vehicule     = new Vehicule {
                            Id = user.Id, Modele = model.Modele, DateMiseEnRoute = model.DateMiseEnRoute, NombrePlace = model.NombrePlace
                        },
                        Trajets = new List <Trajet>()
                    };

                    _serviceChauffeur.CreateVehicule(chauffeur.Vehicule);
                    _serviceChauffeur.CreateChauffeur(chauffeur);

                    // TODO rediriger vers les detail du chauffeur id cree dans le controleur chauffeur
                    return(RedirectToAction("Details", "Chauffeurs", chauffeur));
                }
                AddErrors(result);
            }

            // Si nous sommes arrivés là, un échec s’est produit. Réafficher le formulaire
            return(View(model));
        }
Пример #13
0
        public static Chauffeur findByNumero(string Numero)
        {
            Chauffeur   chauffeur = null;
            OdbcCommand cmd       = new OdbcCommand("select * from chauffeur where Numero=?", AccesBd.getConnection());

            cmd.Parameters.Add("@Numero", OdbcType.VarChar).Value = Numero;
            OdbcDataReader dr = cmd.ExecuteReader();

            if (dr.Read())
            {
                chauffeur = new Chauffeur {
                    Id = dr.GetInt32(0), Numero = dr.GetString(1), Nom = dr.GetString(2), Prenom = dr.GetString(3), DateNais = dr.GetDate(4), Telephone = dr.GetString(5), Adresse = dr.GetString(6), Permis = dr.GetString(6), Status = dr.GetString(7)
                };
            }
            cmd.Dispose();
            return(chauffeur);
        }
Пример #14
0
        public ActionResult Create([Bind(Include = "Id,VilleDepart,PointDepart,PointArrivee,Prix,VilleDestination,DateDepart,HeureDepart,DateArrivee,HeureArrivee,PlaceRestante, Kilometrage")] TrajetHeureDate trajet)
        {
            if (ModelState.IsValid)
            {
                Chauffeur chauffeur   = db.Chauffeur.Where(x => x.Email == User.Identity.Name).FirstOrDefault();
                DateTime  heurearrive = new DateTime(trajet.DateArrivee.Year, trajet.DateArrivee.Month, trajet.DateArrivee.Day, trajet.HeureArrivee.Hour, trajet.HeureArrivee.Minute, trajet.HeureArrivee.Second);
                DateTime  heuredepart = new DateTime(trajet.DateDepart.Year, trajet.DateDepart.Month, trajet.DateDepart.Day, trajet.HeureDepart.Hour, trajet.HeureDepart.Minute, trajet.HeureDepart.Second);
                Trajet    newtrajet   = new Trajet {
                    Chauffeur = chauffeur, HeureArrivee = heurearrive, HeureDepart = heuredepart, PointDepart = trajet.PointDepart, PointArrivee = trajet.PointArrivee, Id = trajet.Id,
                    Prix      = trajet.Prix, VilleDepart = trajet.VilleDepart, VilleDestination = trajet.VilleDestination, PlaceRestante = trajet.PlaceRestante, Kilometrage = trajet.Kilometrage
                };
                db.Trajets.Add(newtrajet);
                db.SaveChanges();
                return(RedirectToAction("FiltreTrajets"));
            }

            return(View(trajet));
        }
Пример #15
0
        protected override void Seed(Context context)
        {
            var test = new Appelant {
                Id = 795, Nom = "Doe", Prenom = "John", Adresse = "qque part", NumTel = "04/546 64 45"
            };
            var test2 = new Chauffeur {
                Nom = "Valjean", Prenom = "Jean", Adresse = "qque part aussi", NumTel = "04/546 64 45"
            };
            var test3 = new Chauffeur {
                Nom = "Val", Prenom = "Jean", Adresse = "qque part aussi", NumTel = "04/546 64 45"
            };

            context.Appelants.Add(test);
            context.Chauffeurs.Add(test2);
            context.Chauffeurs.Add(test3);

            context.SaveChanges();
        }
Пример #16
0
        private void data()
        {
            Chauffeur chauffeur = new Chauffeur {
                Nom = "Valjean", Prenom = "Jean", Adresse = "qque part aussi", NumTel = "04/546 64 45"
            };

            chauffeurs.Add(chauffeur);
            chauffeur = new Chauffeur {
                Nom = "Val", Prenom = "Jean", Adresse = "qque part aussi", NumTel = "04/546 64 45"
            };
            chauffeurs.Add(chauffeur);


            Appelant appelant = new Appelant {
                Id = 795, Nom = "Doe", Prenom = "John", Adresse = "qque part", NumTel = "04/546 64 45"
            };

            appelants.Add(appelant);
        }
        public ActionResult Details(Chauffeur chauffeur)
        {
            if (chauffeur == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ChauffeurInfoViewModel vm = new ChauffeurInfoViewModel
            {
                Confort     = serviceChauffeur.GetConfortAVGFor(chauffeur.Id),
                Courtoisie  = serviceChauffeur.GetCourtoisieAVGFor(chauffeur.Id),
                Fiabilite   = serviceChauffeur.GetFiabiliteAVGFor(chauffeur.Id),
                Ponctualite = serviceChauffeur.GetPonctualiteAVGFor(chauffeur.Id),
                Securite    = serviceChauffeur.GetSecuriteAVGFor(chauffeur.Id),

                // a mettre lorsque le service acceptera
                Trajets  = serviceChauffeur.GetTrajetsFor(chauffeur.Id).ToList(),
                Vehicule = serviceChauffeur.GetVehiculeFor(chauffeur.Id)
            };

            return(View(vm));
        }
Пример #18
0
        private void dgDriver_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (DroitDao.findDroit(administrateur.Numero, "Chauffeur", "Modifier"))
            {
                for (int i = 0; i < dgDriver.RowCount; i++)
                {
                    if ((bool)dgDriver.Rows[i].Selected)
                    {
                        AddDriverForm adf       = new AddDriverForm();
                        Chauffeur     chauffeur = ChauffeurDao.findByNumero(dgDriver.Rows[i].Cells[0].Value.ToString());
                        adf.Model2Form(chauffeur);

                        adf.ShowDialog();
                    }
                }
            }
            else
            {
                MessageBox.Show("Vous n\'avez pas ce droit");
            }
        }
Пример #19
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // Ceci ne comptabilise pas les échecs de connexion pour le verrouillage du compte
            // Pour que les échecs de mot de passe déclenchent le verrouillage du compte, utilisez shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout : false);

            var user = await UserManager.FindByNameAsync(model.Email);

            switch (result)
            {
            case SignInStatus.Success:
                //un client se login rediriger au trajet
                if (await UserManager.IsInRoleAsync(user.Id, "Client"))
                {
                    return(RedirectToAction("Index", "Trajets"));
                }
                else
                {
                    // un chauffeur se login rediriger a ses details
                    Chauffeur chauffeur = _serviceChauffeur.GetChauffeur(user.Id);
                    return(RedirectToAction("Details", "Chauffeurs", chauffeur));
                }

            case SignInStatus.LockedOut:
                return(View("Lockout"));

            case SignInStatus.RequiresVerification:
                return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }));

            case SignInStatus.Failure:
            default:
                ModelState.AddModelError("", "Tentative de connexion non valide.");
                return(View(model));
            }
        }
Пример #20
0
 private void LoadTabChauffeur()
 {
     ListChauffeur            = Chauffeur.getAll();
     TabChauffeur.ItemsSource = ListChauffeur;
 }
Пример #21
0
        private void BtnValider_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(txtDateDbuAffectation.Text) ||
                    string.IsNullOrWhiteSpace(txtDateFinAffectation.Text) ||
                    cmbChauffeur.SelectedIndex == -1 ||
                    cmbVehicule.SelectedIndex == -1
                    )
                {
                    MessageBox.Show("Veuillez remplir tous les champs !", "mTransport", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    if (Outils.VerifDate((DateTime)txtDateDbuAffectation.SelectedDate, (DateTime)txtDateFinAffectation.SelectedDate, "date début affectation", "date fin affectation"))
                    {
                        return;
                    }

                    AffectationVehicule T = new AffectationVehicule();
                    T.DateDebutAffectation = (DateTime)txtDateDbuAffectation.SelectedDate;
                    T.DateFinAffectation   = txtDateFinAffectation.SelectedDate;
                    var ch = cmbChauffeur.SelectedItem as LoadCombo;
                    T.IdChauffeur = ch.Id;
                    var ve = cmbVehicule.SelectedItem as LoadCombo;
                    T.IdVehicule = ve.Id;

                    if (Outils.VerifDateExist(ch.Id, ve.Id, (DateTime)txtDateDbuAffectation.SelectedDate))
                    {
                        MessageBox.Show("Ce véhicule est déjà affecté au chauffeur sur la même période!", "mTransport", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                        return;
                    }

                    if (Id > 0)
                    {
                        T.Id = Id;
                        var k = Vehicule.getVehicule(ve.Id);
                        T.Vehicule = k;
                        var m = Chauffeur.getUnChauffeur(ch.Id);
                        T.Chauffeur = m;
                        T.Update();
                        MessageBox.Show("Modification effectuée !");
                        LoadTabAffectationVehicule();
                        GriserChamps();
                        Id = 0;
                    }
                    else
                    {
                        T.Insert();
                        var k = Vehicule.getVehicule(ve.Id);
                        T.Vehicule = k;
                        var m = Chauffeur.getUnChauffeur(ch.Id);
                        T.Chauffeur = m;
                        ListAffectationVehicule.Add(T);
                        TabAffectationVehicule.Items.Refresh();
                        MessageBox.Show("Enregistrement effectué !");
                        GriserChamps();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #22
0
        public async Task CreateRoles()
        {
            ApplicationDbContext context = new ApplicationDbContext();

            var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context));
            var UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));

            var user = new ApplicationUser();

            // In Startup iam creating first Admin Role and creating a default Admin User
            if (!roleManager.RoleExists("Chauffeur"))
            {
                // first we create Admin rool
                var role = new IdentityRole();
                role.Name = "Chauffeur";
                roleManager.Create(role);



                user.UserName = "******";
                user.Email    = "*****@*****.**";

                string userPWD = "Password1!";

                var result = await UserManager.CreateAsync(user, userPWD);

                //Add default User to Role Admin
                if (result.Succeeded)
                {
                    var result1 = UserManager.AddToRole(user.Id, "chauffeur");
                }
            }

            // creating Creating Membre role
            if (!roleManager.RoleExists("Client"))
            {
                var role = new IdentityRole();
                role.Name = "Client";
                roleManager.Create(role);
            }

            //Create basic user for test purposes
            var user2 = new ApplicationUser();

            user2.Email    = "*****@*****.**";
            user2.UserName = "******";
            string userPWD2 = "Password1!";
            var    result2  = await UserManager.CreateAsync(user2, userPWD2);

            if (result2.Succeeded)
            {
                var result1 = UserManager.AddToRole(user2.Id, "Client");
            }

            List <Trajet> list   = new List <Trajet>();
            Trajet        voyage = new Trajet {
                Id = "0", VilleDepart = "tamere", VilleDestination = "ton autre mere", DateDepart = DateTime.Now, HeureArrivee = DateTime.Now.AddHours(24)
            };

            list.Add(voyage);
            Chauffeur bob = new Chauffeur
            {
                Id           = user.Id,
                DateEmbauche = DateTime.Now.AddDays(-10),
                DatePermis   = DateTime.Now.AddDays(-10),
                Trajets      = list,
                Vehicule     = new Vehicule
                {
                    Id = "0",
                    DateMiseEnRoute = DateTime.Now,
                    Modele          = "gros char",
                    NombrePlace     = 3
                }
            };

            voyage.Chauffeur = bob;
            ApplicationUser bobQuiChauffe = UserManager.Find("*****@*****.**", "Password1!");

            bobQuiChauffe.Chauffeur = bob;
            UserManager.Update(bobQuiChauffe);
            context.Chauffeurs.Add(bob);
            voyage.Chauffeur = bob;
            context.Trajets.Add(voyage);
            context.SaveChanges();
        }
Пример #23
0
 public bool Retournee(Chauffeur chauffeur)
 {
     return(true);
 }
Пример #24
0
 public bool Verhuur(Chauffeur chauffeur, DateTime datum)
 {
     return(true);
 }
Пример #25
0
 public void SupprimerChauffeur(Chauffeur unChauffeur)
 {
     uw.ChauffeurRepository.Delete(unChauffeur);
     uw.Save();
 }
Пример #26
0
 public void ModifierChauffeur(Chauffeur unChauffeur)
 {
     uw.ChauffeurRepository.Update(unChauffeur);
     uw.Save();
 }
Пример #27
0
 public void AjouterChauffeur(Chauffeur unChauffeur)
 {
     uw.ChauffeurRepository.Insert(unChauffeur);
     uw.Save();
 }
 public void UpdateChauffeur(Chauffeur chauffeur)
 {
     uow.ChauffeurRepository.Update(chauffeur);
 }
 public void CreateChauffeur(Chauffeur chauffeur)
 {
     uow.ChauffeurRepository.Insert(chauffeur);
 }
Пример #30
0
        protected override void Seed(ProjetCovoiturage.Models.ApplicationDbContext context)
        {
            var UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context)); ////dobavil
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.

            List <Chauffeur> chauffeurs = new List <Chauffeur>()
            {
                new Chauffeur {
                    Nom        = "Mc", Prenom = "Donald", NumeroPermis = "123456789", NumeroTelephone = 438911911, Ville = "Montreal",
                    DatePermis = new DateTime(2010, 01, 01), DateEmbauche = new DateTime(2015, 01, 01), Email = "*****@*****.**", Public = true
                },
                new Chauffeur {
                    Nom        = "Max", Prenom = "Degouet", NumeroPermis = "987654321", NumeroTelephone = 450911911, Ville = "Toronto",
                    DatePermis = new DateTime(2011, 01, 01), DateEmbauche = new DateTime(2014, 01, 01), Email = "*****@*****.**", Public = false
                }
            };

            List <Client> clients = new List <Client>()
            {
                new Client {
                    ClientID = 1
                },
                new Client {
                    ClientID = 2
                }
            };

            Client cl1 = clients[0];
            Client cl2 = clients[1];

            Chauffeur c  = chauffeurs[0];
            Chauffeur c2 = chauffeurs[1];

            List <Trajet> trajets = new List <Trajet>()
            {
                new Trajet {
                    Id          = 1, Chauffeur = c, HeureDepart = new DateTime(2019, 01, 01), HeureArrivee = new DateTime(2019, 01, 02), Kilometrage = 700,
                    VilleDepart = "Montreal", VilleDestination = "Toronto", PlaceRestante = 4, PointDepart = "college", PointArrivee = "airport", Prix = 50
                },
                new Trajet {
                    Id          = 2, Chauffeur = c, HeureDepart = new DateTime(2019, 01, 11), HeureArrivee = new DateTime(2019, 01, 12), Kilometrage = 500,
                    VilleDepart = "Montreal", VilleDestination = "Kingston", PlaceRestante = 3, PointDepart = "port", PointArrivee = "airport", Prix = 20
                },
                new Trajet {
                    Id          = 3, Chauffeur = c, HeureDepart = new DateTime(2018, 01, 11), HeureArrivee = new DateTime(2018, 01, 12), Kilometrage = 500,
                    VilleDepart = "Montreal", VilleDestination = "Kingston", PlaceRestante = 3, PointDepart = "port", PointArrivee = "airport", Prix = 20
                },
                new Trajet {
                    Id          = 4, Chauffeur = c, HeureDepart = new DateTime(2018, 01, 01), HeureArrivee = new DateTime(2018, 01, 02), Kilometrage = 700,
                    VilleDepart = "Montreal", VilleDestination = "Toronto", PlaceRestante = 3, PointDepart = "college", PointArrivee = "airport", Prix = 20
                },

                new Trajet {
                    Id          = 5, Chauffeur = c2, HeureDepart = new DateTime(2019, 01, 01), HeureArrivee = new DateTime(2019, 01, 02), Kilometrage = 700,
                    VilleDepart = "Toronto", VilleDestination = "Montreal", PlaceRestante = 4, PointDepart = "college", PointArrivee = "airport", Prix = 50
                },
                new Trajet {
                    Id          = 6, Chauffeur = c2, HeureDepart = new DateTime(2018, 01, 11), HeureArrivee = new DateTime(2018, 01, 12), Kilometrage = 500,
                    VilleDepart = "Kingston", VilleDestination = "Montreal", PlaceRestante = 3, PointDepart = "port", PointArrivee = "airport", Prix = 20
                },
                new Trajet {
                    Id          = 7, Chauffeur = c2, HeureDepart = new DateTime(2018, 01, 11), HeureArrivee = new DateTime(2018, 01, 12), Kilometrage = 500,
                    VilleDepart = "Kingston", VilleDestination = "Montreal", PlaceRestante = 3, PointDepart = "port", PointArrivee = "airport", Prix = 20
                },
                new Trajet {
                    Id          = 8, Chauffeur = c2, HeureDepart = new DateTime(2018, 01, 01), HeureArrivee = new DateTime(2018, 01, 02), Kilometrage = 700,
                    VilleDepart = "Toronto", VilleDestination = "Montreal", PlaceRestante = 3, PointDepart = "college", PointArrivee = "airport", Prix = 20
                },
            };
            List <NotesChauffeurs> notes = new List <NotesChauffeurs>()
            {
                new NotesChauffeurs {
                    chaufeurs = c, noteConfort = 1, noteCourtoisie = 2, noteFiabilite = 3, notePonctualite = 4, noteSecurite = 5
                },
                new NotesChauffeurs {
                    chaufeurs = c, noteConfort = 5, noteCourtoisie = 4, noteFiabilite = 2, notePonctualite = 3, noteSecurite = 1
                },
                new NotesChauffeurs {
                    chaufeurs = c, noteConfort = 4, noteCourtoisie = 3, noteFiabilite = 4, notePonctualite = 4, noteSecurite = 1
                },
                new NotesChauffeurs {
                    chaufeurs = c, noteConfort = 3, noteCourtoisie = 1, noteFiabilite = 1, notePonctualite = 3, noteSecurite = 1
                },
                new NotesChauffeurs {
                    chaufeurs = c, noteConfort = 1, noteCourtoisie = 2, noteFiabilite = 3, notePonctualite = 4, noteSecurite = 5
                },
                new NotesChauffeurs {
                    chaufeurs = c, noteConfort = 1, noteCourtoisie = 4, noteFiabilite = 2, notePonctualite = 3, noteSecurite = 1
                },
                new NotesChauffeurs {
                    chaufeurs = c, noteConfort = 1, noteCourtoisie = 5, noteFiabilite = 4, notePonctualite = 4, noteSecurite = 1
                },
                new NotesChauffeurs {
                    chaufeurs = c, noteConfort = 3, noteCourtoisie = 1, noteFiabilite = 1, notePonctualite = 3, noteSecurite = 1
                },

                new NotesChauffeurs {
                    chaufeurs = c2, noteConfort = 1, noteCourtoisie = 2, noteFiabilite = 3, notePonctualite = 4, noteSecurite = 5
                },
                new NotesChauffeurs {
                    chaufeurs = c2, noteConfort = 5, noteCourtoisie = 4, noteFiabilite = 2, notePonctualite = 3, noteSecurite = 1
                },
                new NotesChauffeurs {
                    chaufeurs = c2, noteConfort = 4, noteCourtoisie = 5, noteFiabilite = 4, notePonctualite = 1, noteSecurite = 4
                },
                new NotesChauffeurs {
                    chaufeurs = c2, noteConfort = 3, noteCourtoisie = 1, noteFiabilite = 3, notePonctualite = 3, noteSecurite = 1
                },
                new NotesChauffeurs {
                    chaufeurs = c2, noteConfort = 5, noteCourtoisie = 2, noteFiabilite = 3, notePonctualite = 4, noteSecurite = 5
                },
                new NotesChauffeurs {
                    chaufeurs = c2, noteConfort = 1, noteCourtoisie = 4, noteFiabilite = 2, notePonctualite = 3, noteSecurite = 4
                },
                new NotesChauffeurs {
                    chaufeurs = c2, noteConfort = 5, noteCourtoisie = 5, noteFiabilite = 4, notePonctualite = 1, noteSecurite = 4
                },
                new NotesChauffeurs {
                    chaufeurs = c2, noteConfort = 3, noteCourtoisie = 1, noteFiabilite = 1, notePonctualite = 3, noteSecurite = 1
                }
            };

            List <NotesClient> notesClients = new List <NotesClient>()
            {
                new NotesClient {
                    clientID = cl1.ClientID, note = 1, trajetID = 8
                },
                new NotesClient {
                    clientID = cl2.ClientID, note = 5, trajetID = 3
                },
                new NotesClient {
                    clientID = cl1.ClientID, note = 4, trajetID = 2
                },
                new NotesClient {
                    clientID = cl2.ClientID, note = 5, trajetID = 1
                },
                new NotesClient {
                    clientID = cl1.ClientID, note = 3, trajetID = 5
                },
                new NotesClient {
                    clientID = cl1.ClientID, note = 2, trajetID = 8
                },
                new NotesClient {
                    clientID = cl2.ClientID, note = 5, trajetID = 6
                },
                new NotesClient {
                    clientID = cl1.ClientID, note = 4, trajetID = 2
                },
                new NotesClient {
                    clientID = cl2.ClientID, note = 5, trajetID = 1
                },
                new NotesClient {
                    clientID = cl1.ClientID, note = 3, trajetID = 5
                }
            };

            context.NotesClients.AddRange(notesClients);
            context.Clients.AddRange(clients);
            context.Chauffeur.AddRange(chauffeurs);
            context.Trajets.AddRange(trajets);
            context.NotesChauffeurs.AddRange(notes);

            context.SaveChanges();
        }