Exemple #1
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));
        }
Exemple #2
0
        public IActionResult CollabList()
        {
            Dal dal = new Dal();
            var p   = dal.GetCollaborateurs(HttpContext.User.Identity.Name);

            if (p.Statut == "SUPER_ADMIN")
            {
                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));
            }
        }
Exemple #3
0
        public IActionResult ModCollab(CollabViewModel model, int?id)
        {
            Dal    dal = new Dal();
            string h   = "";
            var    m   = dal.GetCollaborateurs((int)id);

            for (int i = 0; i < model.CollabStatus.Length; i++)
            {
                h += Char.ToUpper(model.CollabStatus[i]);
            }
            m.Statut      = h;
            m.Identifiant = model.CollabId;
            m.Nom         = model.CollabLastName;
            m.Prenom      = model.CollabFirstName;
            m.Mail        = model.CollabMail;
            m.Mdp         = model.CollabPasswrd;
            bool s = dal.ModifyCollab(m);

            if (s)
            {
                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));
        }