public ActionResult GetAllProjectUser()
        {
            GestionProjet model = new GestionProjet();
            DataTable     dt    = model.GetProjectUsers();

            return(View("GetAllProjectUser", dt));
        }
        public ActionResult create(string SelectedUsers, string SelectedProject, int ID, FormCollection frm)
        {
            string strConString = "data source=DESKTOP-6HSRCAQ\\MSSQLSERVER01; database=Ernst; integrated security=SSPI;";

            GestionProjet model = new GestionProjet();
            int           id    = Convert.ToInt32(frm["hdnID"]);
            DataTable     dt    = model.GetprojectByID(ID);

            string[] Users    = SelectedUsers.Split(',');
            string[] Projects = SelectedProject.Split(',');
            foreach (string User in Users)
            {
                if (User != "")
                {
                    foreach (string Project in Projects)
                    {
                        if (Project != "")
                        {
                            using (SqlConnection con = new SqlConnection(strConString))
                            {
                                con.Open();
                                string     query = "insert into asso(Id,ProjectId) values (@Id,@ProjectId)";
                                SqlCommand cmd   = new SqlCommand(query, con);
                                cmd.Parameters.AddWithValue("Id", Int32.Parse(User));
                                cmd.Parameters.AddWithValue("ProjectId", Int32.Parse(Project));
                                cmd.ExecuteNonQuery();
                            }
                        }
                    }
                }
            }

            return(RedirectToAction("Index", "ProjectUser"));
        }
        public ActionResult Edit1(int ID)
        {
            GestionProjet model = new GestionProjet();
            DataTable     dt    = model.GetprojectByID(ID);

            return(RedirectToAction("createUsers", dt));
        }
        public ActionResult Edit(int ID)
        {
            GestionProjet model = new GestionProjet();
            DataTable     dt    = model.GetprojectByID(ID);

            return(View("Edit", dt));
        }
        public ActionResult createUsers(string SelectedUsers, string Project)
        {
            string strConString = "data source=DESKTOP-6HSRCAQ\\MSSQLSERVER01; database=Ernst; integrated security=SSPI;";
            var    model        = new GestionProjet();


            string[] Users    = SelectedUsers.Split(',');
            string[] Projects = Project.Split(',');
            model.DeleteProjectAsso(Convert.ToInt32(Projects[1]));
            foreach (string User in Users)
            {
                if (User != "")
                {
                    foreach (string project in Projects)
                    {
                        if (project != "")
                        {
                            using (SqlConnection con = new SqlConnection(strConString))
                            {
                                con.Open();
                                string     query = "insert into asso(Id,ProjectId) values (@Id,@ProjectId)";
                                SqlCommand cmd   = new SqlCommand(query, con);
                                cmd.Parameters.AddWithValue("Id", Int32.Parse(User));
                                cmd.Parameters.AddWithValue("ProjectId", Int32.Parse(project));
                                cmd.ExecuteNonQuery();
                            }
                        }
                    }
                }
            }

            return(RedirectToAction("Index", "GestionProjet"));
        }
        // GET: GestionProjet
        public ActionResult Index()
        {
            GestionProjet model = new GestionProjet();
            DataTable     dt    = model.GetProject();

            return(View("Index", dt));
        }
        public ActionResult createUsers(int ID, FormCollection frm)
        {
            GestionProjet model = new GestionProjet();
            int           id    = Convert.ToInt32(frm["hdnID"]);


            DataTable Users = new DataTable();

            Users = GetAllUsers();
            foreach (DataRow user in Users.Rows)
            {
                model.Users.Add(new Models.GestionProjet.UsersModel
                {
                    Id       = Convert.ToInt32(user["id"].ToString()),
                    UserName = Convert.ToString(user["Name"])
                });
            }
            DataTable Projects = new DataTable();

            Projects = GetAllProjects(ID);
            foreach (DataRow project in Projects.Rows)
            {
                model.Projects.Add(new Models.GestionProjet.ProjectsModel
                {
                    Id          = Convert.ToInt32(project["ProjectId"].ToString()),
                    ProjectName = Convert.ToString(project["ProjectName"])
                });
            }
            return(View("createUsers", model));
        }
        public ActionResult Delete1(string ProjectName, string Name)
        {
            GestionProjet model  = new GestionProjet();
            GestionProjet model1 = new GestionProjet();

            model.DeleteProjectUser(ProjectName, Name);
            return(RedirectToAction("GetAllProjectUser"));
        }
        public ActionResult Delete(int ID)
        {
            GestionProjet model  = new GestionProjet();
            GestionProjet model1 = new GestionProjet();

            model.DeleteProject(ID);
            model.DeleteProjectAsso(ID);
            return(RedirectToAction("Index"));
        }
 public ActionResult UpdateRecord(FormCollection frm, string action)
 {
     if (action == "Submit")
     {
         GestionProjet model  = new GestionProjet();
         string        name   = frm["txtName"];
         int           id     = Convert.ToInt32(frm["hdnID"]);
         int           status = model.UpdateProject(id, name);
         return(RedirectToAction("Index"));
     }
     else
     {
         return(RedirectToAction("Index"));
     }
 }
        /// <returns></returns>
        public ActionResult InsertRecord(FormCollection frm, string action)
        {
            if (action == "Submit")
            {
                GestionProjet model = new GestionProjet();

                string name = frm["name"];

                int status = model.InsertProject(name);
                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
        static void Main(string[] args)
        {
            GestionProjet gs = new GestionProjet();

            Ingenieur j1 = new Ingenieur()
            {
                Id     = 1,
                Nom    = "Dhia",
                Prenom = "Saadlaui",
                Email  = "*****@*****.**", Specialite = Specialite.GL
            };
            Ingenieur j2 = new Ingenieur()
            {
                Id         = 1,
                Nom        = "Amal",
                Prenom     = "aaaaaaaaaaaa",
                Email      = "aaaaaaaaaaaa",
                Specialite = Specialite.GL
            };

            Ingenieur j3 = new Ingenieur()
            {
                Id         = 1,
                Nom        = "Dhia",
                Prenom     = "Saadlaui",
                Email      = "*****@*****.**",
                Specialite = Specialite.GL
            };

            Ingenieur j4 = new Ingenieur()
            {
                Id         = 1,
                Nom        = "Dhia",
                Prenom     = "Saadlaui",
                Email      = "*****@*****.**",
                Specialite = Specialite.GL
            };
            ChefProjet cf1 = new ChefProjet()
            {
                // here to fill object props
            };
            ChefProjet cf2 = new ChefProjet()
            {
                // here to fill object props
            };
            Affectation af1 = new Affectation()
            {
                // here to fill object props
            };
            Affectation af2 = new Affectation()
            {
                // here to fill object props
            };

            //TO TEST Extension Method
            //  gs.AjoutProjet(new Projet(){Nom = "projet1"});

            // METHOD 1

            var Query =
                from AFF in gs.Affectations
                join chef in gs.ChefProjets on AFF.Projet.chef equals chef
                group AFF by AFF.Projet into g
                where g.Key.chef.Experiance > 7
                select g;


            foreach (var aff in Query)
            {
                Console.WriteLine(aff.GetEnumerator());
            }
            // METHOD 2
            var innerJoinQuery =
                from chef in gs.ChefProjets
                where chef.Experiance > 7
                select chef;


            foreach (var chef in innerJoinQuery)
            {
                foreach (var projet in chef.Projets)
                {
                    Console.WriteLine(gs.Affectations.FindAll(affectation => affectation.Projet == projet));
                }
            }

            Console.ReadKey();
        }