Exemple #1
0
            /// <summary>
            /// Return the list of Clients where the collab is a project manager or assigner to
            /// </summary>
            /// <param name="collaborateur"></param>
            /// <returns>the list of client where the current collab has work in common with (project or task in a project)</returns>
            public List <Client> GetByCollaborateur(Collaborateurs collaborateur)
            {
                var clientList = new List <Client>();
                var projetList = new List <Projet>();



                foreach (var projet in _context.Projet.ToList())
                {
                    if (projet.Responsable == collaborateur.Id)
                    {
                        projetList.Add(projet);
                        break;
                    }

                    foreach (var tache in _context.Tache.Where(t => t.IdProj == projet.Id && t.CollabId == collaborateur.Id).ToList())
                    {
                        projetList.Add(projet);
                        break;
                    }
                }

                projetList.Distinct().ToList();

                foreach (var projet in projetList)
                {
                    clientList.Add(/*ClientTranslator.DalToDto*/ (projet.ClientNavigation));
                }

                clientList.Distinct().ToList();

                return(clientList);
            }
Exemple #2
0
        /// <summary>
        /// Prepare task creation
        /// </summary>
        /// <returns>a viewModel for a new task </returns>
        public IActionResult TaskCreation(int?id)
        {
            Dal            dal            = new Dal();
            Collaborateurs c              = dal.GetCollaborateurs(HttpContext.User.Identity.Name);
            var            collaborateurs = dal.GetCollaborateurs(c.Id);

            List <Collaborateurs> listCollaborator          = dal.AllCollaborateurs;
            List <Tache>          listEligiblePreviousTasks = dal.GetPotentialPreviousTasks((int)id, new List <int>(), -1);
            List <Tache>          potentialSuperTask        = dal.GetPotentialSuperTache((int)id, new List <int>());

            var model = new TaskViewModel
            {
                ProjectId              = (int)id,
                TaskId                 = -1,
                TaskName               = "",
                StartDate              = DateTime.Now,
                EndDate                = DateTime.Now,
                _collaboratorList      = listCollaborator,
                _EligiblePreviousTasks = listEligiblePreviousTasks,
                _superTaskList         = potentialSuperTask,
            };

            this.ViewBag.Depends = model.ListEligiblePreviousTask;


            return(View("TaskCreation", model));
        }
        // GET: Clients
        public IActionResult Profile()
        {
            IDal dal = new Dal();
            // TODO changer 2 en numéro actuel du collab connecté
            Collaborateurs   c     = dal.GetCollaborateurs(HttpContext.User.Identity.Name);
            ProfileViewModel model = new ProfileViewModel
            {
                notifications = dal.GetNotifications(c).ToList(),
                taches        = dal.GetTaches(c).ToList(),
                projet        = dal.GetProjets(c).ToList()
            };

            foreach (Tache t in model.taches)
            {
                t.IdProjNavigation = dal.GetProjet(t.IdProj);
            }

            foreach (Notification n in model.notifications)
            {
                if (n.IdProjet != null)
                {
                    n.IdProjetNavigation = dal.GetProjet((int)n.IdProjet);
                }
            }

            /*foreach (Notification n in model.notifications)
             * {
             *  if (n.IdProjet.HasValue)
             *      n.ProjetNavigation = d.GetProjet(n.IdProjet.Value);
             *  if (n.IdTache.HasValue)
             *      n.TacheNavigation = d.GetTache(n.IdTache.Value);
             * }*/

            return(View(model));
        }
        /// <summary>
        /// Function to prepare the display of a single project
        /// </summary>
        /// <param name="id">the id of the project which will be displayed</param>
        /// <returns>a view with it's view model</returns>
        public IActionResult Project(int?id)
        {
            Dal            dal = new Dal();
            Collaborateurs c   = dal.GetCollaborateurs(HttpContext.User.Identity.Name);

            Projet projectToDisplay = dal.GetProjet((int)id);

            projectToDisplay.ClientNavigation      = dal.GetClient(projectToDisplay.Client);
            projectToDisplay.ResponsableNavigation = dal.GetCollaborateurs(projectToDisplay.Responsable);

            projectToDisplay.Tache = dal.GetTaskByProjects(projectToDisplay.Id, c.Id);

            bool IsProjectManagerTemp = dal.IsProjectManager(HttpContext.User.Identity.Name, projectToDisplay.Id);

            if (id.HasValue)
            {
                pId = (int)id;
                var model = new ProjectViewModel
                {
                    Project          = projectToDisplay,
                    IsProjectManager = IsProjectManagerTemp
                };

                return(View("Project", model));
            }

            return(View("Error"));
        }
Exemple #5
0
        /// <summary>
        /// Get all the projects linked to a collaborator, by a task or being the project manager
        /// </summary>
        /// <param name="collaborateur">The collaborator considered</param>
        /// <returns>A list of projects</returns>
        public List <Projet> GetProjets(Collaborateurs collaborateur)
        {
            var projetList = new List <Projet>();

            if (collaborateur == null)
            {
                return(projetList);
            }

            foreach (var projet in bdd.Projet)
            {
                if (projet.Responsable == collaborateur.Id)
                {
                    projetList.Add(projet);
                    continue;
                }

                foreach (var tache in bdd.Tache.Where(t => t.IdProj == projet.Id && t.CollabId == collaborateur.Id))
                {
                    projetList.Add(projet);
                    break;
                }
            }

            return(projetList);
        }
        public IActionResult SaveNewClient(ClientCreationViewModel model)
        {
            Dal dal = new Dal();

            if (ModelState.IsValid)
            {
                var newClient = new Leaf.DAL.ScaffoldedModels.Client {
                    Compagnie = model.Company, Adresse = model.Adress, Nom = model.ReferentName, Telephone = model.ReferentPhone, Mail = model.ReferentMail, Projet = new List <Projet>()
                };

                bool result;

                result = dal.SaveNewClient(newClient);

                if (result)
                {
                    Collaborateurs c           = dal.GetCollaborateurs(HttpContext.User.Identity.Name);
                    var            returnModel = new ClientListViewModel
                    {
                        clients = dal.GetClients(c)
                    };
                    return(View("ClientList", returnModel));
                }
            }

            return(View(model));
        }
        public IActionResult SaveClient(ClientCreationViewModel model, int?id)
        {
            Dal dal = new Dal();

            if (ModelState.IsValid)
            {
                model.Clientnew = dal.GetClient((int)id);

                model.Clientnew.Adresse   = model.Adress;
                model.Clientnew.Compagnie = model.Company;
                model.Clientnew.Nom       = model.ReferentName;
                model.Clientnew.Telephone = model.ReferentPhone;
                model.Clientnew.Mail      = model.ReferentMail;

                bool result;

                result = dal.ModifyClient(model.Clientnew);

                if (result)
                {
                    Collaborateurs c           = dal.GetCollaborateurs(HttpContext.User.Identity.Name);
                    var            returnModel = new ClientListViewModel
                    {
                        clients = dal.GetClients(c)
                    };
                    return(View("ClientList", returnModel));
                }
            }

            return(View("ClientModification", model));
        }
        /// <summary>
        /// Delete a notification from the list and from the BDD
        /// </summary>
        /// <param name="notifTemp">The id of the notif to delete</param>
        /// <returns>the new view to diplay</returns>
        public IActionResult DeleteNotif(int?notifTemp)
        {
            Dal dal = new Dal();

            if (notifTemp != null)
            {
                dal.DeleteNotification(dal.GetCollaborateurs(HttpContext.User.Identity.Name), dal.GetNotification((int)notifTemp));
            }

            Collaborateurs   c     = dal.GetCollaborateurs(HttpContext.User.Identity.Name);
            ProfileViewModel model = new ProfileViewModel
            {
                notifications = dal.GetNotifications(c).ToList(),
                taches        = dal.GetTaches(c).ToList(),
                projet        = dal.GetProjets(c).ToList()
            };

            foreach (Tache t in model.taches)
            {
                t.IdProjNavigation = dal.GetProjet(t.IdProj);
            }

            foreach (Notification n in model.notifications)
            {
                if (n.IdProjet != null)
                {
                    n.IdProjetNavigation = dal.GetProjet((int)n.IdProjet);
                }
            }
            return(View("Profile", model));
        }
Exemple #9
0
 /// <summary>
 /// Get all tasks of a collaborator
 /// </summary>
 /// <param name="c">The collaborator form which we want to get the tasks</param>
 /// <returns>The list of tasks of the collaborator</returns>
 public List <Tache> GetTaches(Collaborateurs c)
 {
     if (c == null)
     {
         return(new List <Tache>());
     }
     return(bdd.Tache.Where(t => t.Collab.Id == c.Id).ToList());
 }
Exemple #10
0
 /// <summary>
 /// Get all notifications for a collaborator
 /// </summary>
 /// <param name="c">The collaborator to consider</param>
 /// <returns>The list of notifications for the collaborator</returns>
 public List <Notification> GetNotifications(Collaborateurs c)
 {
     if (c == null)
     {
         return(new List <Notification>());
     }
     return(bdd.Notification.Where(n => n.DestinataireNavigation.Id == c.Id).ToList());
 }
Exemple #11
0
        public List <Notification> GetRecentNotifications(Collaborateurs c, int n)
        {
            List <Notification> ret = new List <Notification>();
            int i = n;

            while (n >= 0)
            {
                ret.Add(bdd.Notification.Where(notif => notif.DestinataireNavigation == c).OrderByDescending(no => no.Id).ToList()[i - n]);
            }
            return(ret);
        }
Exemple #12
0
        /**
         *
         * Please see see and make documentation in the IDal.cs file
         *
         */

        #region Single return-type
        public bool DeleteNotification(Collaborateurs c, Notification n)
        {
            //Checking if notification actually exists.
            if (c == null || !c.Notification.Contains(n))
            {
                return(false);
            }


            bdd.Notification.Remove(n);
            bdd.SaveChanges();
            return(true);
        }
Exemple #13
0
        public bool ModifyCollab(Collaborateurs c)
        {
            Collaborateurs k = bdd.Collaborateurs.Find(c.Id);

            if (k == null)
            {
                return(false);
            }

            bdd.Entry(k).CurrentValues.SetValues(c);
            bdd.SaveChanges();
            return(true);
        }
Exemple #14
0
        /// <summary>
        /// Preparation to display a list of tasks
        /// </summary>
        /// <returns>a taskListViewModel for display</returns>
        public IActionResult TaskList()
        {
            Dal            dal            = new Dal();
            Collaborateurs c              = dal.GetCollaborateurs(HttpContext.User.Identity.Name);
            var            collaborateurs = dal.GetCollaborateurs(c.Id);

            var model = new TaskListViewModel
            {
                TaskList = dal.GetTaches(collaborateurs)
            };

            return(View(model));
        }
        public IActionResult SaveNewProject(ProjectViewModel model)
        {
            Dal            dal = new Dal();
            Collaborateurs c   = dal.GetCollaborateurs(HttpContext.User.Identity.Name);

            if (ModelState.IsValid)
            {
                var project = new Leaf.DAL.ScaffoldedModels.Projet {
                    Nom = model.ProjectName, Debut = model.StartDate, Echeance = model.EndDate, Client = model.ProjectClient, Responsable = model.ProjectLeader
                };

                bool result = dal.SaveNewProject(project);

                if (result)
                {
                    var returnModel = new ProjectsViewModel
                    {
                        projets = dal.GetProjets(c)
                    };
                    foreach (var projet in returnModel.projets)
                    {
                        projet.ClientNavigation      = dal.GetClient(projet.Client);
                        projet.ResponsableNavigation = dal.GetCollaborateurs(projet.Responsable);
                    }
                    if (c.Id == project.Responsable)
                    {
                        dal.AddNotification(project.Responsable, project.Id, null, "Votre nouveau projet a bien été créé.", DateTime.Now);
                    }
                    else
                    {
                        if (dal.IsProjectManager(c.Mail, project.Id))
                        {
                            dal.AddNotification(project.Responsable, project.Id, null, "Vous avez été assigné à un nouveau projet par son chef :  " + c.Prenom + " " + c.Nom + ".", DateTime.Now);
                        }
                        else
                        {
                            dal.AddNotification(project.Responsable, project.Id, null, "Vous avez été assigné à un nouveau projet par un administrateur.", DateTime.Now);
                        }
                    }

                    return(View("ProjectList", returnModel));
                }
            }
            ;


            model._clients            = dal.GetClients(c);
            model._projectManagerList = dal.getProjectManagers();

            return(View("ProjectCreation", model));
        }
        /// <summary>
        /// Preparation to display the formular for creating a task
        /// </summary>
        /// <returns>a ClientCreationViewModel to display the task creation formular</returns>
        public IActionResult ClientCreation()
        {
            Dal            dal            = new Dal();
            Collaborateurs c              = dal.GetCollaborateurs(HttpContext.User.Identity.Name);
            var            collaborateurs = dal.GetCollaborateurs(c.Id);

            var model = new ClientCreationViewModel
            {
                Clientnew      = new Client(),
                IsModification = false
            };

            return(View(model));
        }
Exemple #17
0
            public List <Projet> GetByCollaborateur(Collaborateurs collaborateur)
            {
                var projetList = new List <Projet>();

                foreach (var projet in _context.Projet.ToList())
                {
                    foreach (var tache in _context.Tache.Where(t => t.IdProj == projet.Id && t.CollabId == collaborateur.Id).ToList())
                    {
                        projetList.Add(projet);
                        break;
                    }
                }

                return(projetList);
            }
Exemple #18
0
        /// <summary>
        /// Get all the clients linked by a task or a project to the collaborator
        /// </summary>
        /// <param name="collaborateur">the collaborator considered</param>
        /// <returns>A list of the clients linked one way or another to the collaborator in parameter</returns>
        public List <Client> GetClients(Collaborateurs collaborateur)
        {
            var clientList = new List <Client>();
            var projetList = new List <Projet>();

            var temp = new List <Projet>();

            temp = bdd.Projet.ToList();
            var inTemp = temp.Count;

            //Si c'est un admin ou un chef de projet, on retourne tous les clients
            if (collaborateur.Statut == "SUPER_ADMIN" || collaborateur.Statut == "ADMIN" || collaborateur.Statut == "CHEF_PROJET")
            {
                foreach (var client in bdd.Client)
                {
                    clientList.Add(client);
                }

                return(clientList);
            }

            foreach (var projet in bdd.Projet.ToList())
            {
                if (projet.Responsable == collaborateur.Id)
                {
                    projetList.Add(projet);
                    continue;
                }

                foreach (var tache in bdd.Tache.Where(t => t.IdProj == projet.Id && t.CollabId == collaborateur.Id).ToList())
                {
                    projetList.Add(projet);
                    break;
                }
            }

            projetList.Distinct().ToList();

            foreach (var projet in projetList)
            {
                Client clientTemp = bdd.Client.Where((client => client.Id == projet.Client)).SingleOrDefault();
                clientList.Add(clientTemp);
            }

            clientList.Distinct().ToList();

            return(clientList);
        }
Exemple #19
0
        /// <summary>
        /// Returns a list containing all tasks linked to a project
        /// </summary>
        /// <param name="projectId">The id of the project linked to the tasks</param>
        /// <returns>The list of all task linked to the project, the id project being the parameter</returns>
        public List <Leaf.DAL.ScaffoldedModels.Tache> GetTaskByProjects(int projectId, int collabId)
        {
            List <Tache>   taskList = new List <Tache>();
            Collaborateurs collabro = this.GetCollaborateurs(collabId);

            foreach (var taskTemp in bdd.Tache.Where(t => t.IdProj == projectId))
            {
                if (collabro.Statut == "ADMIN" || collabro.Statut == "SUPER_ADMIN" ||
                    (collabro.Statut == "CHEF_PROJET" && this.GetProjet(projectId).Responsable == collabId) || taskTemp.CollabId == collabId)
                {
                    taskList.Add(taskTemp);
                }
            }

            return(taskList);
        }
Exemple #20
0
        // GET: Clients
        public IActionResult Index()
        {
            /*
             *
             *
             *
             *
             *
             * Exemple d'accès aux données de l'utilisateur, ici
             *
             *
             *
             */
            IDal           dal            = new Dal();
            Collaborateurs collaborateurs = dal.GetCollaborateurs(HttpContext.User.Identity.Name);



            StatutEnum status;

            if (collaborateurs.Statut == "CHEF_PROJET")
            {
                status = StatutEnum.ChefDeProjet;
            }
            else if (collaborateurs.Statut == "COLLABORATEUR")
            {
                status = StatutEnum.Collaborateur;
            }
            else if (collaborateurs.Statut == "ADMIN")
            {
                status = StatutEnum.Admin;
            }
            else
            {
                status = StatutEnum.SuperAdmin;
            }

            var model = new HomeViewModel
            {
                Statut        = status,
                displayName   = collaborateurs.Prenom + " " + collaborateurs.Nom,
                notifications = dal.GetRecentNotifications(collaborateurs, 5),
                taches        = dal.GetTaches(collaborateurs)
            };

            return(View(model));
        }
Exemple #21
0
        /// <summary>
        /// Get the list of the recent notification linked to a collaborator
        /// </summary>
        /// <param name="c">The collaborator</param>
        /// <param name="n">the max number oof notificcation returned, the number of notifications returned can be less than n</param>
        /// <returns>A list of notifications</returns>
        public List <Notification> GetRecentNotifications(Collaborateurs c, int n)
        {
            if (c == null)
            {
                return(new List <Notification>());
            }

            List <Notification> notifications = bdd.Notification.Where(notif => notif.DestinataireNavigation == c).OrderByDescending(no => no.Horodatage).ToList();
            List <Notification> ret           = new List <Notification>(Math.Min(n, notifications.Count));

            for (int i = 0; i < notifications.Count && i < n; i++)
            {
                ret.Add(notifications[i]);
            }

            return(ret);
        }
        /// <summary>
        /// Function called when the creation formular is displayed
        /// </summary>
        /// <returns>A view with the ProjectViewModel associated</returns>
        public IActionResult ProjectCreation()
        {
            Dal            dal = new Dal();
            Collaborateurs c   = dal.GetCollaborateurs(HttpContext.User.Identity.Name);

            var model = new ProjectViewModel
            {
                Project             = new Leaf.DAL.ScaffoldedModels.Projet(),
                IsModification      = false,
                StartDate           = DateTime.Today,
                EndDate             = DateTime.Today,
                _clients            = dal.GetClients(c),
                _projectManagerList = dal.getProjectManagers()
            };

            return(View(model));
        }
Exemple #23
0
        public IActionResult CollabModif(int?id)
        {
            Dal            dal   = new Dal();
            Collaborateurs c     = dal.GetCollaborateurs((int)id);
            var            model = new CollabViewModel
            {
                isMod           = true,
                CollabFirstName = c.Prenom,
                CollabId        = c.Identifiant,
                IsSuperAdmin    = dal.IsSuperAdmin(HttpContext.User.Identity.Name),
                CollabLastName  = c.Nom,
                CollabMail      = c.Mail,
                CollabIdn       = (int)id,
                Collaborateur   = c
            };

            return(View("CollabCreation", model));
        }
        // GET: /<controller>/
        public IActionResult ProjectList()
        {
            Dal            dal = new Dal();
            Collaborateurs c   = dal.GetCollaborateurs(HttpContext.User.Identity.Name);

            var model = new ProjectsViewModel
            {
                projets = dal.GetProjets(c).ToList()
            };

            foreach (var projet in model.projets)
            {
                projet.ClientNavigation      = dal.GetClient(projet.Client);
                projet.ResponsableNavigation = dal.GetCollaborateurs(projet.Responsable);
            }

            return(View(model));
        }
Exemple #25
0
        /// <summary>
        /// prepare data for task modification
        /// </summary>
        /// <param name="id">The id of the task to modify</param>
        /// <returns>the view to display</returns>
        public IActionResult TaskModification(int?id, int?projId)
        {
            Dal            dal            = new Dal();
            Collaborateurs c              = dal.GetCollaborateurs(HttpContext.User.Identity.Name);
            var            collaborateurs = dal.GetCollaborateurs(c.Id);

            List <Collaborateurs> listCollaborator          = dal.AllCollaborateurs;
            List <Tache>          listEligiblePreviousTasks = dal.GetPotentialPreviousTasks((int)projId, new List <int>(), -1, (int)id);

            List <Tache> potentialSuperTask = dal.GetPotentialSuperTache((int)projId, new List <int>(), (int)id);

            Tache taskTemp = dal.GetTache((int)id);

            var model = new TaskViewModel
            {
                Task                   = taskTemp,
                TaskId                 = (int)id,
                TaskName               = taskTemp.Nom,
                TaskDescription        = taskTemp.Description,
                StartDate              = (System.DateTime)taskTemp.Debut,
                EndDate                = (System.DateTime)taskTemp.Fin,
                ChargeEstimee          = taskTemp.ChargeEstimee,
                Progres                = taskTemp.Progres,
                IdProj                 = taskTemp.IdProj,
                CollabId               = taskTemp.CollabId,
                SuperTache             = taskTemp.SuperTache,
                Depends                = dal.GetPreviousTask((int)id),
                _superTaskList         = potentialSuperTask,
                _collaboratorList      = listCollaborator,
                _EligiblePreviousTasks = listEligiblePreviousTasks,
            };

            var selected = dal.GetPreviousTask((int)id);

            this.ViewBag.DependsMod = new MultiSelectList(listEligiblePreviousTasks, "Id", "Nom", selected);
            model.DependsMod        = new List <int>();

            foreach (var pt in selected)
            {
                model.DependsMod.Add(pt);
            }

            return(View("TaskModification", model));
        }
Exemple #26
0
        public IActionResult SaveNewCollab(CollabViewModel model)
        {
            Dal    dal = new Dal();
            string h   = "";

            for (int i = 0; i < model.CollabStatus.Length; i++)
            {
                h += Char.ToUpper(model.CollabStatus[i]);
            }
            Collaborateurs nCollab = new Collaborateurs
            {
                Identifiant = model.CollabId,
                Nom         = model.CollabLastName,
                Prenom      = model.CollabFirstName,
                Mail        = model.CollabMail,
                Mdp         = model.CollabPasswrd,
                Statut      = h
            };

            bool saved = dal.MakeNewCollab(nCollab);

            if (saved)
            {
                dal.AddNotification(nCollab.Id, null, null, "Bienvenue sur Leaf ! N'hésitez pas à contacter un administrateur en cas de problèmes ou si vous avez des questions", DateTime.Now);
                if (model.Statut == ViewModel.LoginPartialViewModel.StatutEnum.SuperAdmin)
                {
                    var modlist = new CollaborateursViewModel {
                        Collaborateurs = dal.AllCollaborateurs
                    };
                    return(View("CollabList", modlist));
                }
                else
                {
                    var modlist = new CollaborateursViewModel {
                        Collaborateurs = dal.AllCollaborateurs.FindAll(c => !c.Statut.Contains("ADMIN"))
                    };
                    return(View("CollabList", modlist));
                }
            }

            return(View("CollabCreation", model));
        }
        /// <summary>
        /// Prepration to display the formular to modify a task
        /// </summary>
        /// <param name="id">The id of the task to modify</param>
        /// <returns>a ClientCreationViewModel to display the task modification formular</returns>
        public IActionResult ClientModification(int?id)
        {
            Dal            dal = new Dal();
            Collaborateurs c   = dal.GetCollaborateurs(HttpContext.User.Identity.Name);

            Leaf.DAL.ScaffoldedModels.Client clientModif;
            clientModif = dal.GetClient((int)id);

            var model = new ClientCreationViewModel
            {
                Clientnew    = clientModif,
                Company      = clientModif.Compagnie,
                Adress       = clientModif.Adresse,
                ReferentName = clientModif.Nom,
                //ReferentSurname = clientModif.Prenom,
                ReferentMail   = clientModif.Mail,
                ReferentPhone  = clientModif.Telephone,
                IsModification = true
            };

            return(View("ClientModification", model));
        }
Exemple #28
0
 public List <Tache> GetTaches(Collaborateurs c)
 {
     //Projet p1 = new Projet() { Nom = "2D" };
     //Projet p2 = new Projet() { Nom = "Zhou" };
     //Tache t1 = new Tache
     //{
     //    Id = 0,
     //    Debut = new DateTime(2017, 09, 24),
     //    Fin = new DateTime(2017, 09, 28),
     //    Nom = "Implémenter back-face culling",
     //    IdProjNavigation = p1
     //};
     //Tache t2 = new Tache
     //{
     //    Id = 0,
     //    Debut = new DateTime(2017, 10, 01),
     //    Fin = new DateTime(2017, 10, 09),
     //    Nom = "Ajout de l'interface",
     //    IdProjNavigation = p2
     //};
     return(bdd.Tache.Where(t => t.Collab == c).ToList());
     //return new List<Tache>() { t1, t2 };
 }
        /// <summary>
        /// To prepare the display
        /// </summary>
        /// <param name="id">The id of the project to modify</param>
        /// <returns>A View containing a ProjectViewModel</returns>
        public IActionResult ProjectModification(int?id)
        {
            Dal            dal = new Dal();
            Collaborateurs c   = dal.GetCollaborateurs(HttpContext.User.Identity.Name);

            Leaf.DAL.ScaffoldedModels.Projet projectToModify = dal.GetProjet((int)id);
            projectToModify.ClientNavigation      = dal.GetClient(projectToModify.Client);
            projectToModify.ResponsableNavigation = dal.GetCollaborateurs(projectToModify.Responsable);

            var model = new ProjectViewModel
            {
                Project             = projectToModify,
                ProjectName         = projectToModify.Nom,
                ProjectClient       = projectToModify.Client,
                ProjectLeader       = projectToModify.Responsable,
                StartDate           = projectToModify.Debut,
                EndDate             = projectToModify.Echeance,
                _clients            = dal.GetClients(c),
                _projectManagerList = dal.getProjectManagers()
            };

            return(View(model));
        }
        public IActionResult SaveProjectModification(ProjectViewModel model, int?id)
        {
            Dal dal = new Dal();

            if (ModelState.IsValid)
            {
                Projet projectTemp = new Projet();

                projectTemp.Id  = (int)id;
                projectTemp.Nom = model.ProjectName;

                projectTemp.Debut    = model.StartDate;
                projectTemp.Echeance = model.EndDate;

                projectTemp.Client      = model.ProjectClient;
                projectTemp.Responsable = model.ProjectLeader;

                bool result = dal.ModifyProject(projectTemp);

                if (result)
                {
                    Collaborateurs c           = dal.GetCollaborateurs(HttpContext.User.Identity.Name);
                    var            returnModel = new ProjectsViewModel
                    {
                        projets = dal.GetProjets(c)
                    };
                    foreach (var projet in returnModel.projets)
                    {
                        projet.ClientNavigation      = dal.GetClient(projet.Client);
                        projet.ResponsableNavigation = dal.GetCollaborateurs(projet.Responsable);
                    }
                    return(View("ProjectList", returnModel));
                }
            }

            return(View(model));
        }